AuditTrailController extends AbstractController { @RequestMapping(value = "activityHistory.html") public String activityHistory(Model model) throws ClassNotFoundException { AuthenticatedUser currentUser = userContext.getCurrentUser(); List<HistoryDto> historyListDtos = patientAuditService .findAllHistory(currentUser.getUsername()); model.addAttribute("historys", historyListDtos); return "views/patients/activityHistory"; }  @RequestMapping(value = "activityHistory.html") String activityHistory(Model model);  }
@Test public void testActivityHistory() throws Exception { MockMvc mockMvc = MockMvcBuilders.standaloneSetup( this.auditTrailController).build(); List<HistoryDto> historyListDtos = new ArrayList<HistoryDto>(); for (int i = 0; i < 3; i++) { historyListDtos.add(mock(HistoryDto.class)); } List<HistoryDto> spyHistoryListDtoss = spy(historyListDtos); when(patientAuditService.findAllHistory(anyString())).thenReturn( spyHistoryListDtoss); mockMvc.perform(get("/patients/activityHistory.html")) .andExpect(status().isOk()) .andExpect(model().attribute("historys", historyListDtos)) .andExpect(view().name("views/patients/activityHistory")); }