DownloadHistory implements Processor { @Override public void process(Exchange exchange) throws Exception { Message msg = exchange.getIn(); User user = msg.getHeader(Configuration.USER, User.class); Content content = msg.getHeader(Configuration.CONTENT, Content.class); if (content != null) { contentManager.saveInHistory(content, user); } else { LOGGER.error("Is not a content or can't be parsed. File: {}", msg.getHeader(Configuration.FILE_NAME, String.class)); } }  @Autowired void setContentManager(ContentManager contentManager); @Override void process(Exchange exchange);  }
@Test public void shouldSaveMsgContentInHIstoryWhenReceivesAMsg() throws Exception { Mockito.when(exchange.getIn()).thenReturn(message); Mockito.when(message.getHeader(Configuration.USER, User.class)).thenReturn(user); Mockito.when(message.getHeader(Configuration.CONTENT, Content.class)).thenReturn(content); downloadHistory.process(exchange); Mockito.verify(contentManager).saveInHistory(content, user); }