@Override public void onException(ConversionFormatException exception) { callback.onException(target, exception); } }
@Override public void onException(File file, Exception e) { try { reportException(e); } finally { fileConsumer.onException(file, e); } } }
@Override public void onException(Exception e) { fileConsumer.onException(file, e); }
@Override protected void onConversionFailed(RuntimeException e) { callback.onException(target, e); }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConversionFormatException.class) public void testConversionWithUnknownTargetFormatFuture() throws Exception { File target = makeTarget(false); IFileConsumer fileConsumer = mock(IFileConsumer.class); try { getConverter().convert(validFile(true)).as(validInputType()) .to(target, fileConsumer).as(UNKNOWN_TYPE) .schedule().get(); fail(); } catch (ExecutionException e) { verify(fileConsumer).onException(eq(target), any(ConversionFormatException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); throw (Exception) e.getCause(); } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConversionFormatException.class) public void testConversionWithUnknownSourceFormatFuture() throws Exception { File target = makeTarget(false); IFileConsumer fileConsumer = mock(IFileConsumer.class); try { getConverter().convert(validFile(true)).as(UNKNOWN_TYPE) .to(target, fileConsumer).as(validTargetType()) .schedule().get(); fail(); } catch (ExecutionException e) { verify(fileConsumer).onException(eq(target), any(ConversionFormatException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); throw (Exception) e.getCause(); } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConverterAccessException.class) public void testFileToFileFuture() throws Exception { IFileConsumer fileConsumer = mock(IFileConsumer.class); File target = makeTarget(false); try { getConverter() .convert(validFile(true)).as(validInputType()) .to(target, fileConsumer).as(validTargetType()) .schedule().get(); fail(); } catch (ExecutionException e) { verify(fileConsumer).onException(eq(target), any(ConverterAccessException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); assertPostConverterState(); throw (Exception) e.getCause(); } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConversionFormatException.class) public void testConversionWithUnknownTargetFormatExecute() throws Exception { File target = makeTarget(false); IFileConsumer fileConsumer = mock(IFileConsumer.class); try { getConverter().convert(validFile(true)).as(validInputType()) .to(target, fileConsumer).as(UNKNOWN_TYPE) .execute(); fail(); } catch (ConversionFormatException e) { verify(fileConsumer).onException(eq(target), any(ConversionFormatException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); throw e; } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConversionFormatException.class) public void testConversionWithUnknownSourceFormatExecute() throws Exception { File target = makeTarget(false); IFileConsumer fileConsumer = mock(IFileConsumer.class); try { getConverter().convert(validFile(true)).as(UNKNOWN_TYPE) .to(target, fileConsumer).as(validTargetType()) .execute(); fail(); } catch (ConversionFormatException e) { verify(fileConsumer).onException(eq(target), any(ConversionFormatException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); throw e; } }
@Test(timeout = DEFAULT_CONVERSION_TIMEOUT, expected = ConverterAccessException.class) public void testFileToFileExecute() throws Exception { IFileConsumer fileConsumer = mock(IFileConsumer.class); File target = makeTarget(false); try { getConverter() .convert(validFile(true)).as(validInputType()) .to(target, fileConsumer).as(validTargetType()) .execute(); fail(); } catch (ConverterAccessException e) { verify(fileConsumer).onException(eq(target), any(ConverterAccessException.class)); verifyNoMoreInteractions(fileConsumer); assertFalse(target.exists()); assertPostConverterState(); throw e; } }