protected File inexistentFile(boolean delete) throws IOException { return makeFile(delete, SOURCE_SUFFIX); }
private File makeFile(boolean delete, String suffix) { File file = nextName(suffix); if (delete) { files.add(file); } return file; }
@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 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(); } }
protected IConverter getConverter() { return getConverterTestDelegate().getConverter(); }
@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 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; } }
protected File makeTarget(boolean delete) throws IOException { return makeFile(delete, TARGET_SUFFIX); }
protected File invalidFile(boolean delete) throws IOException { return MockConversion.INPUT_ERROR.asFile(MESSAGE, makeFile(delete, SOURCE_SUFFIX)); }
protected File validFile(boolean delete) throws IOException { return MockConversion.OK.asFile(MESSAGE, makeFile(delete, SOURCE_SUFFIX)); }