WorkloadDetailsController { @ApiOperation(value = "${WorkloadDetailsController.getApprolesFromCwm.value}", notes = "${WorkloadDetailsController.getApprolesFromCwm.notes}") @GetMapping(value="/v2/serviceaccounts/cwm/approles", produces="application/json") public ResponseEntity<String> getWorkloadDetails(HttpServletRequest request, @RequestHeader(value="vault-token") String token){ UserDetails userDetails = (UserDetails) ((HttpServletRequest) request).getAttribute("UserDetails"); return workloadDetailsService.getWorkloadDetails(token, userDetails); }  @ApiOperation(value = "${WorkloadDetailsController.getApprolesFromCwm.value}", notes = "${WorkloadDetailsController.getApprolesFromCwm.notes}") @GetMapping(value="/v2/serviceaccounts/cwm/approles", produces="application/json") ResponseEntity<String> getWorkloadDetails(HttpServletRequest request, @RequestHeader(value="vault-token") String token); @ApiOperation(value = "${WorkloadDetailsController.getApprolesFromCwm.appname.value}", notes = "$" + "{WorkloadDetailsController.getApprolesFromCwm.appname.notes}") @GetMapping(value="/v2/serviceaccounts/cwm/appdetails/appname", produces="application/json") ResponseEntity<String> getWorkloadDetailsByAPIName(HttpServletRequest request,
															  @RequestHeader(value="vault-token") String token, @RequestParam(
			"appName" ) String appName);  }
@Test public void test_getWorkloadDetails() throws Exception { String responseMessage = "[{\"appName\":\"app1\",\"appTag\":\"app1\",\"appID\":\"app\"},{\"appName\":\"app2\",\"appTag\":\"app2\",\"appID\":\"ap2\"}]"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(workloadDetailsService.getWorkloadDetails("5PDrOhsy4ig8L3EpsJZSLAMg", userDetails)).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.get("/v2/serviceaccounts/cwm/approles") .requestAttr("UserDetails", userDetails) .header("vault-token", token) .header("Content-Type", "application/json;charset=UTF-8")) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }