### Question:
AddDerivativeProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Message in = exchange.getIn(); String binaryUri = (String) in.getHeader(FCREPO_URI); String binaryId = PIDs.get(binaryUri).getId(); Path derivativeFinalPath = setDerivativeFinalPath(binaryId); final ExecResult result = (ExecResult) in.getBody(); try { if (result.getExitValue() != 0) { String stdout = result.getStdout() == null ? "" : IOUtils.toString(result.getStdout(), UTF_8).trim(); String stderr = result.getStderr() == null ? "" : IOUtils.toString(result.getStderr(), UTF_8).trim(); log.error("Failed to generate derivative for {}: {} {}", binaryId, stdout, stderr); return; } String derivativeTmpPath = IOUtils.toString(result.getStdout(), UTF_8).trim(); derivativeTmpPath += "." + fileExtension; moveFile(derivativeTmpPath, derivativeFinalPath); log.info("Added derivative for {} from {}", binaryUri, derivativeFinalPath); } catch (IOException e) { String stderr = ""; if (result != null && result.getStderr() != null) { stderr = IOUtils.toString(result.getStderr(), UTF_8).trim(); } log.error("Failed to generated derivative to {} for {}: {}", derivativeBasePath, binaryId, stderr); throw e; } } AddDerivativeProcessor(String fileExtension, String derivativeBasePath); @Override void process(Exchange exchange); boolean needsRun(Exchange exchange); void cleanupTempFile(Exchange exchange);  }### Answer:
@Test public void createEnhancementTest() throws Exception { mvFile = new File(finalDir.getAbsolutePath() + "/"+ fileName + ".PNG"); processor.process(exchange); assertTrue(mvFile.exists()); }
@Test public void executionFailedTest() throws Exception { when(result.getExitValue()).thenReturn(1); mvFile = new File(finalDir.getAbsolutePath() + "/"+ fileName + ".PNG"); processor.process(exchange); assertFalse(mvFile.exists()); }
@Test(expected = IOException.class) public void resultFileDoesNotExistTest() throws Exception { when(result.getStdout()).thenReturn(new ByteArrayInputStream(".png".getBytes())); processor.process(exchange); }