@Test(expected = ValidationException.class) public final void testExecuteOtherUsingUrl() { final String url = "http: context.checking(new Expectations() { { oneOf(galleryItemToUpdateMock).getUrl(); will(returnValue(url)); oneOf(galleryItemMapper).findByUrl(url); will(returnValue(galleryItemExistingMock)); oneOf(galleryItemToUpdateMock).getUUID(); will(returnValue("uuid")); oneOf(galleryItemExistingMock).getUUID(); will(returnValue("notSameUuid")); } }); sut.save(galleryItemToUpdateMock); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") public void save(final T inGalleryItem) { String urlToCheck = inGalleryItem.getUrl(); T inUseGalleryItem = (T) galleryItemMapper.findByUrl(urlToCheck); if (inUseGalleryItem != null && (inUseGalleryItem.getUUID() != inGalleryItem.getUUID())) { ValidationException ve = new ValidationException(); ve.addError(URL_KEY, "Url has already been uploaded to Eureka"); throw ve; } galleryItemMapper.flush(); }
GalleryItemUpdater implements GalleryItemSaver<T> { @SuppressWarnings("unchecked") public void save(final T inGalleryItem) { String urlToCheck = inGalleryItem.getUrl(); T inUseGalleryItem = (T) galleryItemMapper.findByUrl(urlToCheck); if (inUseGalleryItem != null && (inUseGalleryItem.getUUID() != inGalleryItem.getUUID())) { ValidationException ve = new ValidationException(); ve.addError(URL_KEY, "Url has already been uploaded to Eureka"); throw ve; } galleryItemMapper.flush(); } }
GalleryItemUpdater implements GalleryItemSaver<T> { @SuppressWarnings("unchecked") public void save(final T inGalleryItem) { String urlToCheck = inGalleryItem.getUrl(); T inUseGalleryItem = (T) galleryItemMapper.findByUrl(urlToCheck); if (inUseGalleryItem != null && (inUseGalleryItem.getUUID() != inGalleryItem.getUUID())) { ValidationException ve = new ValidationException(); ve.addError(URL_KEY, "Url has already been uploaded to Eureka"); throw ve; } galleryItemMapper.flush(); } GalleryItemUpdater(
            final GalleryItemMapper<T> inGalleryItemMapper); }
GalleryItemUpdater implements GalleryItemSaver<T> { @SuppressWarnings("unchecked") public void save(final T inGalleryItem) { String urlToCheck = inGalleryItem.getUrl(); T inUseGalleryItem = (T) galleryItemMapper.findByUrl(urlToCheck); if (inUseGalleryItem != null && (inUseGalleryItem.getUUID() != inGalleryItem.getUUID())) { ValidationException ve = new ValidationException(); ve.addError(URL_KEY, "Url has already been uploaded to Eureka"); throw ve; } galleryItemMapper.flush(); } GalleryItemUpdater(
            final GalleryItemMapper<T> inGalleryItemMapper); @SuppressWarnings("unchecked") void save(final T inGalleryItem); }
GalleryItemUpdater implements GalleryItemSaver<T> { @SuppressWarnings("unchecked") public void save(final T inGalleryItem) { String urlToCheck = inGalleryItem.getUrl(); T inUseGalleryItem = (T) galleryItemMapper.findByUrl(urlToCheck); if (inUseGalleryItem != null && (inUseGalleryItem.getUUID() != inGalleryItem.getUUID())) { ValidationException ve = new ValidationException(); ve.addError(URL_KEY, "Url has already been uploaded to Eureka"); throw ve; } galleryItemMapper.flush(); } GalleryItemUpdater(
            final GalleryItemMapper<T> inGalleryItemMapper); @SuppressWarnings("unchecked") void save(final T inGalleryItem);  }