Invalid case test.

This commit is contained in:
Paweł Dyda 2022-10-26 20:42:44 +02:00
parent bee1feb93c
commit 5332703017

View File

@ -1,19 +1,75 @@
package pl.amu.edu.demo.logic; package pl.amu.edu.demo.logic;
import org.junit.jupiter.api.Test; 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 { public class TestWeWillStealYourFlatProduct {
@Test @Test
public void shouldBeValid() { public void shouldBeValid() {
// given // 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
/* when we perform an action */ var result = logic.check(person);
// then // 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);
} }
} }