@Test
  public void delete_by_photoDeleteForm() {

    // given
    List<Long> ids = new ArrayList<Long>();
    ids.add(expectedPhotoList.get(0).getId());
    ids.add(expectedPhotoList.get(1).getId());

    PhotoDeleteForm photoDeleteForm = new PhotoDeleteForm();
    photoDeleteForm.setIds(ids);

    when(photoRepository.findAll(ids)).thenReturn(expectedPhotoList.subList(0, 2));
    photoService.setPhotoRepository(photoRepository);
    photoService.setPhotoImageService(photoImageService);

    // execute
    List<Photo> deletedPhotos = photoService.delete(photoDeleteForm);

    // assert
    assertEquals(2, deletedPhotos.size());
    PhotoTestUtils.assertPhoto(expectedPhotoList.get(0), deletedPhotos.get(0));
    PhotoTestUtils.assertPhoto(expectedPhotoList.get(1), deletedPhotos.get(1));

    verify(photoRepository, times(1)).findAll(ids);
    verify(photoRepository, times(1)).delete(deletedPhotos);
    verify(photoImageService, times(1)).delete(ids.get(0));
    verify(photoImageService, times(1)).delete(ids.get(1));
    verifyNoMoreInteractions(photoRepository);
    verifyNoMoreInteractions(photoImageService);
  }
  @Test
  public void update() {

    // given
    Long galleryId = 2l;
    String photoTitle = "Updated titile";
    String photoDesc = "Desc photo";
    String photoSrc = "folder/img.jpg";
    Photo expectedPhoto = expectedPhotoList.get(0);
    PhotoForm photoForm = new PhotoForm();
    photoForm.setId(expectedPhoto.getId());
    photoForm.setGalleryId(galleryId);
    photoForm.setTitle(photoTitle);
    photoForm.setDescription(photoDesc);
    photoForm.setImageSrc(photoSrc);

    when(photoRepository.findOne(expectedPhoto.getId())).thenReturn(expectedPhoto);
    when(photoRepository.save(expectedPhoto)).thenReturn(expectedPhoto);
    photoService.setPhotoRepository(photoRepository);

    // execute
    Photo actualPhoto = photoService.update(photoForm);

    // assert
    PhotoTestUtils.assertPhoto(expectedPhoto, actualPhoto);
    assertEquals(photoForm.getGalleryId(), actualPhoto.getGalleryId());
    assertEquals(photoForm.getTitle(), actualPhoto.getTitle());
    assertEquals(photoForm.getDescription(), actualPhoto.getDescription());
    assertEquals(photoForm.getImageSrc(), actualPhoto.getImageSrc());

    verify(photoRepository, times(1)).findOne(expectedPhoto.getId());
    verify(photoRepository, times(1)).save(expectedPhoto);
    verifyNoMoreInteractions(photoRepository);
  }
  @Test
  public void add() {

    // given
    PhotoForm photoForm = new PhotoForm();
    photoForm.setTitle(expectedPhotoList.get(0).getTitle());
    photoForm.setDescription(expectedPhotoList.get(0).getDescription());
    photoForm.setImageSrc(expectedPhotoList.get(0).getImageSrc());

    when(photoFormConverter.convert(photoForm)).thenReturn(expectedPhotoList.get(0));
    when(photoRepository.save(expectedPhotoList.get(0))).thenReturn(expectedPhotoList.get(0));

    photoService.setPhotoFormConverter(photoFormConverter);
    photoService.setPhotoRepository(photoRepository);

    // execute
    Photo actualPhoto = photoService.add(photoForm);

    // assert
    PhotoTestUtils.assertPhoto(expectedPhotoList.get(0), actualPhoto);
    assertEquals(photoForm.getTitle(), actualPhoto.getTitle());
    assertEquals(photoForm.getDescription(), actualPhoto.getDescription());
    assertEquals(photoForm.getImageSrc(), actualPhoto.getImageSrc());
  }