Browse Source

UpdateRecordedYearThrowsTest (5)

Andrew Grant 7 months ago
parent
commit
452c5dd256

+ 1 - 1
src/main/java/scot/carricksoftware/grants/services/census/censusentry/UpdateRecordedYearOfBirthImpl.java

@@ -35,7 +35,7 @@ public class UpdateRecordedYearOfBirthImpl implements UpdateRecordedYearOfBirth
         Person person = censusEntryCommand.getPerson();
         if (!isNull(person)) {
             if (isNull(person.getRecordedYearOfBirth())) {
-                if (censusEntryCommand.getBirthYear() != null) {
+                if (!isNull(censusEntryCommand.getBirthYear())) {
                     PersonCommand personCommand = personConverter.convert(person);
                     if (!isNull(personCommand)) {
                         personCommand.setRecordedYearOfBirth(censusEntryCommand.getBirthYear());

+ 2 - 1
src/test/java/scot/carricksoftware/grants/services/census/censusentry/UpdateRecordedYearThrowsTest.java

@@ -38,6 +38,7 @@ class UpdateRecordedYearThrowsTest {
     @Mock
     private Person personMock;
 
+
     @BeforeEach
     void setUp() {
         updateRecordedYearOfBirth = new UpdateRecordedYearOfBirthImpl(personConverterMock, personServiceMock);
@@ -55,9 +56,9 @@ class UpdateRecordedYearThrowsTest {
 
     @Test
     public void noPersonCommandIsThrownTest() {
-        when(personMock.getRecordedYearOfBirth()).thenReturn(null);
         when(censusEntryCommandMock.getPerson()).thenReturn(personMock);
         when(censusEntryCommandMock.getBirthYear()).thenReturn(GetRandomString());
+        when(personConverterMock.convert(personMock)).thenReturn(null);
         Exception exception = assertThrows(NullPointerException.class,
                 () -> updateRecordedYearOfBirth.updateRecordedYearOfBirth(censusEntryCommandMock));