@Test
public void test_updateOnboardedServiceAccount_failure_to_read_ad_details() {

    UserDetails userDetails = getMockUser(true);
    String token = userDetails.getClientToken();
    ServiceAccount serviceAccount = generateServiceAccount("testacc02","testacc01");
    Response response = getMockResponse(HttpStatus.OK, true, "{\"keys\":[\"testacc02\"]}");
    when(reqProcessor.process("/ad/serviceaccount/onboardedlist","{}",token)).thenReturn(response);
    String expectedResponse = "{\"errors\":[\"Failed to update onboarded Service Account. Unable to read Service account details\"]}";
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(expectedResponse);
    ReflectionTestUtils.setField(serviceAccountsService, "ldapTemplate", ldapTemplate);
    when(ldapTemplate.search(Mockito.anyString(), Mockito.any(), Mockito.any(AttributesMapper.class))).thenReturn(null);
    ResponseEntity<String> responseEntity = serviceAccountsService.updateOnboardedServiceAccount(token, serviceAccount, userDetails);
    assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
    assertEquals(responseEntityExpected, responseEntity);
}