|
@@ -10,13 +10,20 @@ import org.junit.jupiter.api.Test;
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
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 org.springframework.boot.test.system.CapturedOutput;
|
|
|
|
|
+import org.springframework.boot.test.system.OutputCaptureExtension;
|
|
|
import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
|
|
import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
|
|
|
import scot.carricksoftware.grants.converters.people.PersonConverter;
|
|
import scot.carricksoftware.grants.converters.people.PersonConverter;
|
|
|
|
|
+import scot.carricksoftware.grants.domains.people.Person;
|
|
|
import scot.carricksoftware.grants.services.people.PersonService;
|
|
import scot.carricksoftware.grants.services.people.PersonService;
|
|
|
|
|
|
|
|
-import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
|
|
|
+
|
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
|
+import static org.mockito.ArgumentMatchers.any;
|
|
|
import static org.mockito.Mockito.verifyNoInteractions;
|
|
import static org.mockito.Mockito.verifyNoInteractions;
|
|
|
|
|
+import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
|
|
+@ExtendWith(OutputCaptureExtension.class)
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
class UpdateCertifiedYearOfBirthTest {
|
|
class UpdateCertifiedYearOfBirthTest {
|
|
|
|
|
|
|
@@ -31,6 +38,7 @@ class UpdateCertifiedYearOfBirthTest {
|
|
|
@Mock
|
|
@Mock
|
|
|
private BirthCertificateCommand birthCertificateCommandMock;
|
|
private BirthCertificateCommand birthCertificateCommandMock;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@BeforeEach
|
|
@BeforeEach
|
|
|
void setUp() {
|
|
void setUp() {
|
|
|
updateCertifiedYearOfBirth = new UpdateCertifiedYearOfBirthImpl(personConverterMock, personServiceMock);
|
|
updateCertifiedYearOfBirth = new UpdateCertifiedYearOfBirthImpl(personConverterMock, personServiceMock);
|
|
@@ -43,7 +51,15 @@ class UpdateCertifiedYearOfBirthTest {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test()
|
|
@Test()
|
|
|
- void nullPersonCommandTest() {
|
|
|
|
|
- assertThrows(NullPointerException.class, () -> updateCertifiedYearOfBirth.updateCertifiedYearOfBirth(null));
|
|
|
|
|
|
|
+ void nullPersonCommandTest(CapturedOutput capturedOutput) {
|
|
|
|
|
+
|
|
|
|
|
+ when(birthCertificateCommandMock.getNewBorn()).thenReturn(new Person());
|
|
|
|
|
+ when(birthCertificateCommandMock.getWhenBorn()).thenReturn("25/01/1953 01:01)");
|
|
|
|
|
+ when(personConverterMock.convert(any())).thenReturn(null);
|
|
|
|
|
+
|
|
|
|
|
+ updateCertifiedYearOfBirth.updateCertifiedYearOfBirth(birthCertificateCommandMock);
|
|
|
|
|
+
|
|
|
|
|
+ assertTrue(capturedOutput.getOut().contains("PersonCommand = null."));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|