From 533270301799a04c9f65fce10590d9d33dd8ea76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Dyda?= Date: Wed, 26 Oct 2022 20:42:44 +0200 Subject: [PATCH] Invalid case test. --- .../logic/TestWeWillStealYourFlatProduct.java | 62 ++++++++++++++++++- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/demo/02/src/test/java/pl/amu/edu/demo/logic/TestWeWillStealYourFlatProduct.java b/demo/02/src/test/java/pl/amu/edu/demo/logic/TestWeWillStealYourFlatProduct.java index 9d444f4..1191caa 100644 --- a/demo/02/src/test/java/pl/amu/edu/demo/logic/TestWeWillStealYourFlatProduct.java +++ b/demo/02/src/test/java/pl/amu/edu/demo/logic/TestWeWillStealYourFlatProduct.java @@ -1,19 +1,75 @@ package pl.amu.edu.demo.logic; import org.junit.jupiter.api.Test; +import pl.amu.edu.demo.data.Address; +import pl.amu.edu.demo.data.Housing; +import pl.amu.edu.demo.data.Person; +import pl.amu.edu.demo.data.WeWillStealYourFlatCheckResult; + +import java.time.LocalDate; + +import static org.assertj.core.api.Assertions.assertThat; public class TestWeWillStealYourFlatProduct { @Test public void shouldBeValid() { // given - /* preconditions */ + var person = Person.builder() + .displayName("Miś Uszatek") + .firstName("Miś") + .lastName("Uszatek") + .birthDate(LocalDate.of(1957, 3, 6)) + .housing( + Housing.builder() + .address( + Address.builder() + .withAddressLine1("Stumilowy las 5") + .withZipCode("99-999") + .build() + ).isApartment(true) + .area(36.0) + .build() + ).isMarried(false) + .build(); + var logic = new WeWillStealYourFlatProduct(); // when - /* when we perform an action */ + var result = logic.check(person); // then - /* assert that everything works as expected */ + assertThat(result).isNotNull(); + assertThat(result).isEqualTo(WeWillStealYourFlatCheckResult.ELIGIBLE); + } + + @Test + public void shouldNotBeValid() { + // given + var person = Person.builder() + .displayName("Maksymilian Paradys") + .firstName("Maxymilian") + .lastName("Paradys") + .birthDate(LocalDate.of(1958, 11, 19)) + .housing( + Housing.builder() + .address( + Address.builder() + .withAddressLine1("Blockhaus C") + .withZipCode("99-119") + .build() + ).isApartment(false) + .area(6543.0) + .build() + ).isMarried(true) + .build(); + var logic = new WeWillStealYourFlatProduct(); + + // when + var result = logic.check(person); + + // then + assertThat(result).isNotNull(); + assertThat(result).isEqualTo(WeWillStealYourFlatCheckResult.NOT_ELIGIBLE); } }