@Test public void workflowHistoryNonAdhocTest() throws Exception { WorkflowHistoryInstance instance = new WorkflowHistoryInstance(); instance.setId("id"); instance.setParticipant("participant"); instance.setRole("role"); instance.setStatus("status"); instance.setStartDate(new Date()); instance.setEndDate(new Date()); String ipAddress = "ipAddress"; String businessProecessId = "businessProecessId"; expect(mockTaskDao.getWorkflowHistory(businessProecessId, false)).andReturn(Arrays.asList(instance)); mockHttpSession.setAttribute("acm_ip_address", ipAddress); mockHttpSession.setAttribute("id", businessProecessId); replayAll(); MvcResult result = mockMvc.perform( get("/api/v1/plugin/task/history/{id}/false", businessProecessId) .accept(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andReturn(); verifyAll(); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); assertTrue(result.getResponse().getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)); String returned = result.getResponse().getContentAsString(); log.info("results: " + returned); ObjectMapper objectMapper = new ObjectMapper(); List<WorkflowHistoryInstance> foundWorkflowHistory = objectMapper.readValue(returned, objectMapper.getTypeFactory().constructParametricType(List.class, WorkflowHistoryInstance.class)); assertEquals(1, foundWorkflowHistory.size()); WorkflowHistoryInstance found = foundWorkflowHistory.get(0); assertEquals(instance.getId(), found.getId()); }
@RequestMapping(value = "/history/{id}/{adhoc}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<WorkflowHistoryInstance> getWorkflowHistory(@PathVariable("id") String id, @PathVariable("adhoc") boolean adhoc, Authentication authentication) { List<WorkflowHistoryInstance> retval = new ArrayList<>(); if (null != id) { retval = getTaskDao().getWorkflowHistory(id, adhoc); } return retval; }
WorkflowHistoryAPIController { @RequestMapping(value = "/history/{id}/{adhoc}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<WorkflowHistoryInstance> getWorkflowHistory(@PathVariable("id") String id, @PathVariable("adhoc") boolean adhoc, Authentication authentication) { List<WorkflowHistoryInstance> retval = new ArrayList<>(); if (null != id) { retval = getTaskDao().getWorkflowHistory(id, adhoc); } return retval; } }
WorkflowHistoryAPIController { @RequestMapping(value = "/history/{id}/{adhoc}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<WorkflowHistoryInstance> getWorkflowHistory(@PathVariable("id") String id, @PathVariable("adhoc") boolean adhoc, Authentication authentication) { List<WorkflowHistoryInstance> retval = new ArrayList<>(); if (null != id) { retval = getTaskDao().getWorkflowHistory(id, adhoc); } return retval; }  }
WorkflowHistoryAPIController { @RequestMapping(value = "/history/{id}/{adhoc}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<WorkflowHistoryInstance> getWorkflowHistory(@PathVariable("id") String id, @PathVariable("adhoc") boolean adhoc, Authentication authentication) { List<WorkflowHistoryInstance> retval = new ArrayList<>(); if (null != id) { retval = getTaskDao().getWorkflowHistory(id, adhoc); } return retval; }  @RequestMapping(value = "/history/{id}/{adhoc}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<WorkflowHistoryInstance> getWorkflowHistory(@PathVariable("id") String id, @PathVariable("adhoc") boolean adhoc,
            Authentication authentication); TaskDao getTaskDao(); void setTaskDao(TaskDao taskDao); }
WorkflowHistoryAPIController { @RequestMapping(value = "/history/{id}/{adhoc}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<WorkflowHistoryInstance> getWorkflowHistory(@PathVariable("id") String id, @PathVariable("adhoc") boolean adhoc, Authentication authentication) { List<WorkflowHistoryInstance> retval = new ArrayList<>(); if (null != id) { retval = getTaskDao().getWorkflowHistory(id, adhoc); } return retval; }  @RequestMapping(value = "/history/{id}/{adhoc}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<WorkflowHistoryInstance> getWorkflowHistory(@PathVariable("id") String id, @PathVariable("adhoc") boolean adhoc,
            Authentication authentication); TaskDao getTaskDao(); void setTaskDao(TaskDao taskDao);  }