VaultAuthControllerV2 { @PostMapping(value="/v2/auth/tvault/login",produces="application/json") @ApiOperation(value = "${VaultAuthControllerV2.login.value}", notes = "${VaultAuthControllerV2.login.notes}") public ResponseEntity<String> login(@RequestBody UserLogin user){ return vaultAuthService.login(user); }  @PostMapping(value="/v2/auth/tvault/login",produces="application/json") @ApiOperation(value = "${VaultAuthControllerV2.login.value}", notes = "${VaultAuthControllerV2.login.notes}") ResponseEntity<String> login(@RequestBody UserLogin user); @GetMapping(value="/v2/auth/tvault/renew",produces="application/json") @ApiOperation(value = "${VaultAuthControllerV2.renew.value}", notes = "${VaultAuthControllerV2.renew.notes}") ResponseEntity<String> renew(@RequestHeader(value="vault-token") String token); @PostMapping(value="/v2/auth/tvault/lookup",produces="application/json") @ApiOperation(value = "${VaultAuthControllerV2.lookup.value}", notes = "${VaultAuthControllerV2.lookup.notes}") ResponseEntity<String> lookup(@RequestHeader(value="vault-token") String token); @GetMapping(value="/auth/tvault/revoke",produces="application/json") @ApiOperation(value = "${VaultAuthControllerV2.revoke.value}", notes = "${VaultAuthControllerV2.revoke.notes}") @ApiResponses(value={ @ApiResponse(code = 204, message = "Revoked Successfully") }) ResponseEntity<String> revoke(@RequestHeader(value="vault-token") String token);  }
@Test public void test_login() throws Exception { UserLogin userLogin = new UserLogin("safeadmin", "safeadmin"); String inputJson =new ObjectMapper().writeValueAsString(userLogin); String responseMessage = "{\"messages\":[\"Username User created\"]}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseMessage); when(vaultAuthService.login(Mockito.any())).thenReturn(responseEntityExpected); mockMvc.perform(MockMvcRequestBuilders.post("/v2/auth/tvault/login") .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg") .header("Content-Type", "application/json;charset=UTF-8") .content(inputJson)) .andExpect(status().isOk()) .andExpect(content().string(containsString(responseMessage))); }