@Test
public void test_resetSvcAccPassword_bad_request() {

    UserDetails userDetails = getMockUser(true);
    String token = userDetails.getClientToken();
    String svcAccName = "testacc03";
    // for createAccountRole
    ServiceAccount serviceAccount = generateServiceAccount("testacc02","testacc01");
    serviceAccount.setAutoRotate(true);
    ServiceAccountTTL serviceAccountTTL = new ServiceAccountTTL();
    serviceAccountTTL.setRole_name(serviceAccount.getName());
    serviceAccountTTL.setService_account_name(serviceAccount.getName() + "@aaa.bbb.ccc.com") ;
    serviceAccountTTL.setTtl(serviceAccount.getTtl());
    String svc_account_payload = getJSON(serviceAccountTTL);
    when(JSONUtil.getJSON(Mockito.any(ServiceAccountTTL.class))).thenReturn(svc_account_payload);
    Response onboardResponse = getMockResponse(HttpStatus.OK, true, "{\"messages\":[\"Successfully created service account role.\"]}");
    when(reqProcessor.process("/ad/serviceaccount/onboard", svc_account_payload, token)).thenReturn(onboardResponse);
    //
    // for getOnboarderdServiceAccountDetails
    Map<String,Object> rqstParams = new HashMap<>();
    rqstParams.put("service_account_name",svcAccName);
    rqstParams.put("ttl", 10);
    rqstParams.put("last_vault_rotation", "2018-05-24T17:14:38.677370855Z");
    rqstParams.put("password_last_set","2018-05-24T17:14:38.6038495Z");
    Response svcAccDetailsRes = getMockResponse(HttpStatus.OK, true, getJSON(rqstParams));
    when(reqProcessor.process("/ad/serviceaccount/details","{\"role_name\":\""+svcAccName+"\"}",token)).thenReturn(svcAccDetailsRes);
    // end getOnboarderdServiceAccountDetails
    // System under test
    String expectedOutput = "{\"errors\":[\"Unable to reset password details for the given service account. Failed to read the updated password after setting ttl to 1 second.\"]}";
    Response pwdResetResponse = getMockResponse(HttpStatus.BAD_REQUEST, true, expectedOutput);
    when(reqProcessor.process("/ad/serviceaccount/resetpwd","{\"role_name\":\""+svcAccName+"\"}",token)).thenReturn(pwdResetResponse);
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(expectedOutput);
    when(reqProcessor.process(eq("/sdb"),Mockito.any(),eq(token))).thenReturn(getMockResponse(HttpStatus.OK, true, "{\"data\":{\"initialPasswordReset\":true,\"managedBy\":\"normaluser\",\"name\":\"svc_vault_test5\",\"users\":{\"normaluser\":\"sudo\"}}}"));
    ResponseEntity<String> responseEntity = serviceAccountsService.resetSvcAccPassword(token, svcAccName, userDetails);
    assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
    assertEquals(responseEntityExpected, responseEntity);
}