### Question:
CdrEventProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { final Message in = exchange.getIn(); Document document = MessageUtil.getDocumentBody(in); if (document == null) { return; } String actionType = document.getRootElement().getChildTextTrim("title", ATOM_NS); if (actionType == null) { in.setHeader(CdrUpdateAction, null); return; } in.setHeader(CdrUpdateAction, actionType); String author = document.getRootElement().getChildTextTrim("name", ATOM_NS); in.setHeader("name", author); in.setBody(document); }  @Override void process(Exchange exchange);  }### Answer:
@Test public void testCreateSolrActionHeader() throws Exception { Document msg = new Document(); createAtomEntry(msg, actionType); when(message.getBody()) .thenReturn(msg); processor.process(exchange); verify(message).setHeader(CdrUpdateAction, actionType); verify(message).setBody(eq(msg)); }
@Test public void testBodyInputStream() throws Exception { Document msg = new Document(); createAtomEntry(msg, actionType); XMLOutputter outputter = new XMLOutputter(); when(message.getBody()) .thenReturn(new ByteArrayInputStream(outputter.outputString(msg).getBytes())); processor.process(exchange); verify(message).setHeader(CdrUpdateAction, actionType); verify(message).setBody(bodyCaptor.capture()); Object bodyObject = bodyCaptor.getValue(); assertTrue(bodyObject instanceof Document); }
@Test public void testBodyString() throws Exception { Document msg = new Document(); createAtomEntry(msg, actionType); XMLOutputter outputter = new XMLOutputter(); when(message.getBody()) .thenReturn(outputter.outputString(msg)); processor.process(exchange); verify(message).setHeader(CdrUpdateAction, actionType); verify(message).setBody(bodyCaptor.capture()); Object bodyObject = bodyCaptor.getValue(); assertTrue(bodyObject instanceof Document); }
@Test public void testCreateSolrNoActionHeader() throws Exception { Document msg = new Document(); createAtomEntry(msg, null); when(message.getBody()) .thenReturn(msg); processor.process(exchange); verify(message).setHeader(CdrUpdateAction, null); }