|
@@ -11,26 +11,23 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
import org.mockito.ArgumentCaptor;
|
|
import org.mockito.ArgumentCaptor;
|
|
|
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.images.ImageCommand;
|
|
|
|
|
import scot.carricksoftware.grants.commands.images.PersonImageCommand;
|
|
import scot.carricksoftware.grants.commands.images.PersonImageCommand;
|
|
|
import scot.carricksoftware.grants.commands.images.PlaceImageCommand;
|
|
import scot.carricksoftware.grants.commands.images.PlaceImageCommand;
|
|
|
-import scot.carricksoftware.grants.domains.people.Person;
|
|
|
|
|
|
|
+import scot.carricksoftware.grants.domains.images.Image;
|
|
|
import scot.carricksoftware.grants.domains.places.Place;
|
|
import scot.carricksoftware.grants.domains.places.Place;
|
|
|
import scot.carricksoftware.grants.services.images.appendiximage.AppendixImageService;
|
|
import scot.carricksoftware.grants.services.images.appendiximage.AppendixImageService;
|
|
|
import scot.carricksoftware.grants.services.images.image.ImageService;
|
|
import scot.carricksoftware.grants.services.images.image.ImageService;
|
|
|
import scot.carricksoftware.grants.services.images.personimage.PersonImageService;
|
|
import scot.carricksoftware.grants.services.images.personimage.PersonImageService;
|
|
|
import scot.carricksoftware.grants.services.images.placeimage.PlaceImageService;
|
|
import scot.carricksoftware.grants.services.images.placeimage.PlaceImageService;
|
|
|
-import scot.carricksoftware.grants.services.people.PersonService;
|
|
|
|
|
import scot.carricksoftware.grants.services.places.places.PlaceService;
|
|
import scot.carricksoftware.grants.services.places.places.PlaceService;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
import static org.mockito.Mockito.verify;
|
|
import static org.mockito.Mockito.verify;
|
|
|
import static org.mockito.Mockito.when;
|
|
import static org.mockito.Mockito.when;
|
|
|
-import static scot.carricksoftware.grants.GenerateRandomPeopleValues.GetRandomPerson;
|
|
|
|
|
import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomPlace;
|
|
import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomPlace;
|
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
-class DataLoadImagesTest {
|
|
|
|
|
|
|
+class DataLoadImagesImagePeopleAndPlacesTest {
|
|
|
|
|
|
|
|
private DataLoadImages dataLoadImages;
|
|
private DataLoadImages dataLoadImages;
|
|
|
|
|
|
|
@@ -49,8 +46,6 @@ class DataLoadImagesTest {
|
|
|
@Mock
|
|
@Mock
|
|
|
private PlaceService placeServiceMock;
|
|
private PlaceService placeServiceMock;
|
|
|
|
|
|
|
|
- @Mock
|
|
|
|
|
- private PersonService personServiceMock;
|
|
|
|
|
|
|
|
|
|
@BeforeEach
|
|
@BeforeEach
|
|
|
void setUp() {
|
|
void setUp() {
|
|
@@ -58,29 +53,20 @@ class DataLoadImagesTest {
|
|
|
personImageServiceMock,
|
|
personImageServiceMock,
|
|
|
placeImageServiceMock,
|
|
placeImageServiceMock,
|
|
|
appendixImageServiceMock,
|
|
appendixImageServiceMock,
|
|
|
- personServiceMock,
|
|
|
|
|
placeServiceMock);
|
|
placeServiceMock);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Test
|
|
|
|
|
- public void anImageIsCreatedTest() {
|
|
|
|
|
- ArgumentCaptor<ImageCommand> captor = ArgumentCaptor.forClass(ImageCommand.class);
|
|
|
|
|
- dataLoadImages.load();
|
|
|
|
|
- verify(imageServiceMock).saveImageCommand(captor.capture());
|
|
|
|
|
- assertEquals("Dalkeith", captor.getValue().getName());
|
|
|
|
|
- assertEquals("Midlothian", captor.getValue().getFileName());
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
public void aPersonImageIsCreatedTest() {
|
|
public void aPersonImageIsCreatedTest() {
|
|
|
ArgumentCaptor<PersonImageCommand> captor = ArgumentCaptor.forClass(PersonImageCommand.class);
|
|
ArgumentCaptor<PersonImageCommand> captor = ArgumentCaptor.forClass(PersonImageCommand.class);
|
|
|
- Person person = GetRandomPerson();
|
|
|
|
|
|
|
+ Image image = new Image();
|
|
|
|
|
|
|
|
- when(personServiceMock.findById(1L)).thenReturn(person);
|
|
|
|
|
|
|
+ when(imageServiceMock.findById(1L)).thenReturn(image);
|
|
|
dataLoadImages.load();
|
|
dataLoadImages.load();
|
|
|
|
|
|
|
|
verify(personImageServiceMock).savePersonImageCommand(captor.capture());
|
|
verify(personImageServiceMock).savePersonImageCommand(captor.capture());
|
|
|
- assertEquals(person, captor.getValue().getPerson());
|
|
|
|
|
|
|
+ assertEquals(image, captor.getValue().getImage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|