AuditMessageController { @RequestMapping(method = RequestMethod.GET, value = "/audit/messages") @ResponseBody public List<AuditMessageItem> getAuditMessages(@RequestParam(value = "previousAuditMessageIndex", defaultValue = "0") long previousIndex) throws IOException { List<AuditMessage> messages = auditor.messagesSince(previousIndex); return with(messages).convert(new Converter<AuditMessage, AuditMessageItem>() { @Override public AuditMessageItem convert(AuditMessage auditMessage) { return AuditMessageItem.from(auditMessage); } }); } @Autowired  AuditMessageController(Auditor auditor); @RequestMapping(method = RequestMethod.GET, value = "/audit/messages") @ResponseBody List<AuditMessageItem> getAuditMessages(@RequestParam(value = "previousAuditMessageIndex", defaultValue = "0") long previousIndex);  }
@Test public void shouldGetAuditMessagesSinceGivenTime() throws IOException { AuditMessageController controller = new AuditMessageController(auditor); when(auditor.messagesSince(10)).thenReturn(messages()); List<AuditMessageItem> messageItems = controller.getAuditMessages(10); assertThat(messageItems, hasSameItemsAs(expectedMessageItems())); }