AMImageProcessorImpl implements AMImageProcessor { @Override public void cleanUp(FileVersion fileVersion) throws PortalException { if (!_amImageValidator.isValid(fileVersion)) { return; } _amImageEntryLocalService.deleteAMImageEntryFileVersion(fileVersion); }  @Override void cleanUp(FileVersion fileVersion); @Override void process(FileVersion fileVersion); @Override void process(FileVersion fileVersion, String configurationEntryUuid);  }
@Test public void testCleanUpFileVersion() throws Exception { Mockito.when( _amImageValidator.isValid(Mockito.any(FileVersion.class)) ).thenReturn( true ); _amImageProcessorImpl.cleanUp(_fileVersion); Mockito.verify( _amImageEntryLocalService ).deleteAMImageEntryFileVersion( _fileVersion ); }
@Test(expected = AMRuntimeException.IOException.class) public void testCleanUpIOException() throws Exception { Mockito.when( _amImageValidator.isValid(Mockito.any(FileVersion.class)) ).thenReturn( true ); Mockito.doThrow( AMRuntimeException.IOException.class ).when( _amImageEntryLocalService ).deleteAMImageEntryFileVersion( Mockito.any(FileVersion.class) ); _amImageProcessorImpl.cleanUp(_fileVersion); }
@Test(expected = PortalException.class) public void testCleanUpPortalException() throws Exception { Mockito.when( _amImageValidator.isValid(Mockito.any(FileVersion.class)) ).thenReturn( true ); Mockito.doThrow( PortalException.class ).when( _amImageEntryLocalService ).deleteAMImageEntryFileVersion( Mockito.any(FileVersion.class) ); _amImageProcessorImpl.cleanUp(_fileVersion); }
@Test public void testCleanUpWhenNotSupported() throws Exception { Mockito.when( _amImageValidator.isValid(Mockito.any(FileVersion.class)) ).thenReturn( false ); _amImageProcessorImpl.cleanUp(_fileVersion); Mockito.verify( _amImageEntryLocalService, Mockito.never() ).deleteAMImageEntryFileVersion( _fileVersion ); }