AecuServiceMBeanImpl extends AnnotatedStandardMBean implements AecuServiceMBean { @Override public String getHistory(int start, int count) throws AecuException { List<HistoryEntry> entries = aecuService.getHistory(start, count); StringBuilder output = new StringBuilder(); for (HistoryEntry entry : entries) { output.append(entry.toString() + "\n\n"); } return output.toString(); } AecuServiceMBeanImpl(); @Override String getVersion(); @Override List<String> getFiles(String path); @Override String execute(String path); @Override String executeWithHistory(String path); @Override String getHistory(int start, int count);  }
@Test public void getHistory() throws AecuException { HistoryEntry entry = mock(HistoryEntry.class); when(entry.toString()).thenReturn(PATH); List<HistoryEntry> entries = Arrays.asList(entry); when(service.getHistory(0, 1)).thenReturn(entries); String history = bean.getHistory(0, 1); assertEquals(PATH + "\n\n", history); }