MessageProcessor { public void process(byte[] content, String contentType) { try { SOAPMessage message = SoapUtil.parseMessage(content, contentType); if (isLoggable(message.getSOAPPart())) { for (LogEntry logEntry : createLogEntries(message.getSOAPPart())) { logService.createEntry(logEntry); } } } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Failed to process message: " + new String(content, IOUtil.UTF_8), e); } } }  void process(byte[] content, String contentType);  }
@Test public void testProcess() throws Exception { byte[] content = IOUtil.readBytes(ResourceUtil.getClasspathResourceAsStream("test_response.xml")); messageProcessor.process(content, "text/xml"); LogEntry logEntry = getLogEntry("47101010033"); verify(logService).createEntry(argThat(matches(logEntry))); }
@Test public void testProcessBlacklisted() throws Exception { byte[] content = IOUtil.readBytes(ResourceUtil.getClasspathResourceAsStream("test_response_blacklisted.xml")); messageProcessor.process(content, "text/xml"); verifyZeroInteractions(logService); }
@Test public void testProcessMultipleIsikukood() throws Exception { byte[] content = IOUtil.readBytes(ResourceUtil.getClasspathResourceAsStream("test_response_multiple_isikukood.xml")); messageProcessor.process(content, "text/xml"); LogEntry logEntry1 = getLogEntry("47101010033"); LogEntry logEntry2 = getLogEntry("47101010044"); verify(logService).createEntry(argThat(matches(logEntry1))); verify(logService).createEntry(argThat(matches(logEntry2))); }