@Test void savePhotosWithPlace() { Place place = ModelUtils.getPlace(); Photo photo = ModelUtils.getPhoto(); Photo photoTest = ModelUtils.getPhoto(); photoTest.setPlace(place); when(photoService.findByName(anyString())).thenReturn(Optional.empty()); proposePlaceService.savePhotosWithPlace(Collections.singletonList(photo), place); assertEquals(Collections.singletonList(photoTest), Collections.singletonList(photo)); }
@Override public void savePhotosWithPlace(List<Photo> photos, Place place) { photos.forEach(photo -> { if (photoService.findByName(photo.getName()).isPresent()) { throw new BadRequestException(ErrorMessage.PHOTO_IS_PRESENT); } photo.setPlace(place); }); }
ProposePlaceServiceImpl implements ProposePlaceService { @Override public void savePhotosWithPlace(List<Photo> photos, Place place) { photos.forEach(photo -> { if (photoService.findByName(photo.getName()).isPresent()) { throw new BadRequestException(ErrorMessage.PHOTO_IS_PRESENT); } photo.setPlace(place); }); } }
ProposePlaceServiceImpl implements ProposePlaceService { @Override public void savePhotosWithPlace(List<Photo> photos, Place place) { photos.forEach(photo -> { if (photoService.findByName(photo.getName()).isPresent()) { throw new BadRequestException(ErrorMessage.PHOTO_IS_PRESENT); } photo.setPlace(place); }); }  }
ProposePlaceServiceImpl implements ProposePlaceService { @Override public void savePhotosWithPlace(List<Photo> photos, Place place) { photos.forEach(photo -> { if (photoService.findByName(photo.getName()).isPresent()) { throw new BadRequestException(ErrorMessage.PHOTO_IS_PRESENT); } photo.setPlace(place); }); }  @Override void checkLocationValues(LocationAddressAndGeoDto dto); @Override void checkInputTime(Set<OpeningHoursDto> dto); @Override void savePhotosWithPlace(List<Photo> photos, Place place); @Override void saveDiscountValuesWithPlace(Set<DiscountValue> discountValues, Place place); }
ProposePlaceServiceImpl implements ProposePlaceService { @Override public void savePhotosWithPlace(List<Photo> photos, Place place) { photos.forEach(photo -> { if (photoService.findByName(photo.getName()).isPresent()) { throw new BadRequestException(ErrorMessage.PHOTO_IS_PRESENT); } photo.setPlace(place); }); }  @Override void checkLocationValues(LocationAddressAndGeoDto dto); @Override void checkInputTime(Set<OpeningHoursDto> dto); @Override void savePhotosWithPlace(List<Photo> photos, Place place); @Override void saveDiscountValuesWithPlace(Set<DiscountValue> discountValues, Place place);  }