### Question:
BinaryEnhancementProcessor implements Processor { @Override public void process(final Exchange exchange) throws Exception { final Message in = exchange.getIn(); String fcrepoBinaryUri = (String) in.getHeader(FCREPO_URI); if (fcrepoBinaryUri == null) { Document msgBody = MessageUtil.getDocumentBody(in); Element body = msgBody.getRootElement(); Element enhancementsEl = body.getChild(RUN_ENHANCEMENTS.getName(), CDR_MESSAGE_NS); if (enhancementsEl != null) { String pidValue = enhancementsEl.getChild("pid", CDR_MESSAGE_NS).getTextTrim(); PID objPid = PIDs.get(pidValue); try { RepositoryObject repoObj = repoObjLoader.getRepositoryObject(objPid); log.info("Adding enhancement headers for " + pidValue); in.setHeader(FCREPO_URI, pidValue); in.setHeader(FCREPO_RESOURCE_TYPE, String.join(",", repoObj.getTypes())); Element forceText = enhancementsEl.getChild("force", CDR_MESSAGE_NS); if (forceText != null) { in.setHeader("force", forceText.getTextTrim()); } else { in.setHeader("force", "false"); } } catch (ObjectTypeMismatchException e) { log.warn("{} is not a repository object. No enhancement headers added", objPid.getURI()); } } } }  @Override void process(final Exchange exchange); void setRepositoryObjectLoader(RepositoryObjectLoader repoObjLoader);  }### Answer:
@Test public void testUpdateHeadersText() throws Exception { setMessageBody("text/plain", true, false); processor.process(exchange); verify(message).setHeader(FCREPO_URI, RESC_URI); verify(message).setHeader(FCREPO_RESOURCE_TYPE, Binary.getURI()); }
@Test public void testUpdateHeadersImageNonCollectionThumb() throws Exception { setMessageBody("image/png", true, false); processor.process(exchange); verify(message).setHeader(FCREPO_URI, RESC_URI); verify(message).setHeader(FCREPO_RESOURCE_TYPE, Binary.getURI()); verify(message).setHeader("force", "false"); }
@Test public void testThumbForce() throws Exception { setMessageBody("image/png", true, true); processor.process(exchange); verify(message).setHeader(FCREPO_URI, RESC_URI); verify(message).setHeader(FCREPO_RESOURCE_TYPE, Binary.getURI()); verify(message).setHeader("force", "true"); }
@Test public void testThumbNoForce() throws Exception { setMessageBody("image/png", true, false); processor.process(exchange); verify(message).setHeader(FCREPO_URI, RESC_URI); verify(message).setHeader(FCREPO_RESOURCE_TYPE, Binary.getURI()); verify(message).setHeader("force", "false"); }
@Test public void testExistingUriHeader() throws Exception { when(exchange.getIn().getHeader(FCREPO_URI)).thenReturn(RESC_URI); setMessageBody("image/png", false, false); processor.process(exchange); verify(message, never()).setHeader(FCREPO_URI, RESC_URI); verify(message, never()).setHeader(FCREPO_RESOURCE_TYPE, Binary.getURI()); verify(message, never()).setHeader("force", "false"); }
@Test public void testNonBinary() throws Exception { when(repoObjLoader.getRepositoryObject(any(PID.class))).thenReturn(collObj); when(collObj.getTypes()).thenReturn(Collections.singletonList(Collection.getURI())); setMessageBody("image/*", true, false); processor.process(exchange); verify(message).setHeader(FCREPO_URI, RESC_URI); verify(message).setHeader(FCREPO_RESOURCE_TYPE, Collection.getURI()); verify(message).setHeader("force", "false"); }