MetadataAfterSave implements StorageItemAfterSave { @Override public void afterSave(StorageItem item) { if (item != null) { StorageItemMetadataCache.update(item); } }  @Override void afterSave(StorageItem item);  }
@Test public void nullStorgageItem() { processor.afterSave(null); }
@Ignore @Test public void imageStorageItem() throws URISyntaxException, IOException { Map<String, Object> metadata = new HashMap<>(); when(item.getMetadata()).thenReturn(metadata); when(item.getContentType()).thenReturn("image/png"); File file = new File(getClass().getClassLoader().getResource("com/psddev/cms/tool/file/MetadataAfterSave_Test/test.png").toURI()); when(item.getData()).thenReturn(new FileInputStream(file)); processor.afterSave(item); verify(item, Mockito.times(1)).getData(); }
@Test public void metadataException() throws IOException { Map<String, Object> metadata = new HashMap<>(); when(item.getMetadata()).thenReturn(metadata); when(item.getContentType()).thenReturn("image/png"); when(item.getData()).thenThrow(new IOException()); processor.afterSave(item); }