|
@@ -11,9 +11,11 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
import org.mockito.Mock;
|
|
import org.mockito.Mock;
|
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
|
|
import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
|
|
|
|
|
+import scot.carricksoftware.grants.commands.people.PersonCommand;
|
|
|
import scot.carricksoftware.grants.converters.people.PersonConverter;
|
|
import scot.carricksoftware.grants.converters.people.PersonConverter;
|
|
|
import scot.carricksoftware.grants.domains.census.Census;
|
|
import scot.carricksoftware.grants.domains.census.Census;
|
|
|
import scot.carricksoftware.grants.domains.people.Person;
|
|
import scot.carricksoftware.grants.domains.people.Person;
|
|
|
|
|
+import scot.carricksoftware.grants.services.people.PersonService;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.*;
|
|
import static org.mockito.Mockito.*;
|
|
|
import static scot.carricksoftware.grants.enums.census.CensusDate.CENSUS_1881;
|
|
import static scot.carricksoftware.grants.enums.census.CensusDate.CENSUS_1881;
|
|
@@ -29,29 +31,35 @@ class UpdateRecordedYearOfBirthFailingTest {
|
|
|
@Mock
|
|
@Mock
|
|
|
private Person personMock;
|
|
private Person personMock;
|
|
|
|
|
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private PersonCommand personCommandMock;
|
|
|
|
|
+
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private PersonService personServiceMock;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Mock
|
|
@Mock
|
|
|
- CensusEntryCommand censusEntryCommandMock;
|
|
|
|
|
|
|
+ private CensusEntryCommand censusEntryCommandMock;
|
|
|
|
|
|
|
|
@Mock
|
|
@Mock
|
|
|
private PersonConverter personConverterMock;
|
|
private PersonConverter personConverterMock;
|
|
|
|
|
|
|
|
@BeforeEach
|
|
@BeforeEach
|
|
|
void setUp() {
|
|
void setUp() {
|
|
|
- updateRecordedYearOfBirth = new UpdateRecordedYearOfBirthImpl(personConverterMock);
|
|
|
|
|
|
|
+ updateRecordedYearOfBirth = new UpdateRecordedYearOfBirthImpl(personConverterMock, personServiceMock);
|
|
|
when(censusEntryCommandMock.getPerson()).thenReturn(personMock);
|
|
when(censusEntryCommandMock.getPerson()).thenReturn(personMock);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
public void theYearOfBirthIsNotUpdatedIfAgeIsInvalidTest() {
|
|
public void theYearOfBirthIsNotUpdatedIfAgeIsInvalidTest() {
|
|
|
- updateRecordedYearOfBirth = new UpdateRecordedYearOfBirthImpl(personConverterMock);
|
|
|
|
|
|
|
+ updateRecordedYearOfBirth = new UpdateRecordedYearOfBirthImpl(personConverterMock, personServiceMock);
|
|
|
when(censusEntryCommandMock.getAge()).thenReturn("3 months");
|
|
when(censusEntryCommandMock.getAge()).thenReturn("3 months");
|
|
|
when(personMock.getRecordedYearOfBirth()).thenReturn(null);
|
|
when(personMock.getRecordedYearOfBirth()).thenReturn(null);
|
|
|
when(censusEntryCommandMock.getCensus()).thenReturn(censusMock);
|
|
when(censusEntryCommandMock.getCensus()).thenReturn(censusMock);
|
|
|
when(censusMock.getCensusDate()).thenReturn(CENSUS_1881);
|
|
when(censusMock.getCensusDate()).thenReturn(CENSUS_1881);
|
|
|
updateRecordedYearOfBirth.updateRecordedYearOfBirth(censusEntryCommandMock);
|
|
updateRecordedYearOfBirth.updateRecordedYearOfBirth(censusEntryCommandMock);
|
|
|
- verify(personMock, times(0)).setRecordedYearOfBirth(anyString());
|
|
|
|
|
|
|
+ verify(personCommandMock, times(0)).setRecordedYearOfBirth(anyString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -59,7 +67,7 @@ class UpdateRecordedYearOfBirthFailingTest {
|
|
|
when(personMock.getRecordedYearOfBirth()).thenReturn("1874");
|
|
when(personMock.getRecordedYearOfBirth()).thenReturn("1874");
|
|
|
when(personMock.getRecordedYearOfBirth()).thenReturn("1800");
|
|
when(personMock.getRecordedYearOfBirth()).thenReturn("1800");
|
|
|
updateRecordedYearOfBirth.updateRecordedYearOfBirth(censusEntryCommandMock);
|
|
updateRecordedYearOfBirth.updateRecordedYearOfBirth(censusEntryCommandMock);
|
|
|
- verify(personMock,times(0)).setRecordedYearOfBirth(anyString());
|
|
|
|
|
|
|
+ verify(personCommandMock,times(0)).setRecordedYearOfBirth(anyString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|