@Test
public void test_transferSvcAccountOwner_transferSvcAccountOwner_failed_get_svc_details() throws Exception {

    String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
    UserDetails userDetails = getMockUser(true);
    String svcAccName = "testacc02";
    String _path = TVaultConstants.SVC_ACC_ROLES_PATH + svcAccName;
    Response metaResponse = getMockResponse(HttpStatus.OK, true, "{\"data\":{\n" +
            "  \"groups\": {\n" +
            "    \"group1\": \"read\"\n" +
            "  },\n" +
            "  \"aws-roles\": {\n" +
            "    \"role1\": \"read\"\n" +
            "  },\n" +
            "  \"app-roles\": {\n" +
            "    \"role2\": \"read\"\n" +
            "  },\n" +
            "  \"managedBy\": \"user2\",\n" +
            "  \"name\": \"testacc02\",\n" +
            "  \"adGroup\": \"gp1\",\n" +
            "  \"appID\": \"appid1\",\n" +
            "  \"appName\": \"appname1\",\n" +
            "  \"appTag\": \"tag1\",\n" +
            "  \"initialPasswordReset\": \"true\",\n" +
            "  \"users\": {\n" +
            "    \"user2\": \"write\"\n" +
            "  }\n" +
            "}}");
    when(reqProcessor.process("/sdb", "{\"path\":\"" + _path + "\"}", token)).thenReturn(metaResponse);
    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);
    String encodedFilter = "(&(userPrincipalName=test*)(objectClass=user)(!(CN=null)))";
    List<ADUserAccount> list = new ArrayList<>();
    ADUserAccount adUserAccount = new ADUserAccount();
    adUserAccount.setUserId("user.user11");
    adUserAccount.setUserName("user11");
    adUserAccount.setDisplayName("user user11");
    adUserAccount.setGivenName("user11");
    adUserAccount.setUserEmail("user11@abc.com");
    list.add(adUserAccount);
    ReflectionTestUtils.setField(serviceAccountsService, "ldapTemplate", ldapTemplate);
    when(ldapTemplate.search(Mockito.anyString(), Mockito.anyString(), Mockito.any(AttributesMapper.class))).thenReturn(null);
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.MULTI_STATUS).body("{\"errors\":[\"Failed to transfer service account ownership. Unable to read Service account details\"]}");
    ResponseEntity<String> responseEntityActual =  serviceAccountsService.transferSvcAccountOwner(userDetails, token, svcAccName);
    assertEquals(HttpStatus.MULTI_STATUS, responseEntityActual.getStatusCode());
    assertEquals(responseEntityExpected, responseEntityActual);
}