@Test
public void test_updateOnboardedServiceAccount_createrole_failure() throws Exception {

    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.MULTI_STATUS).body("{\"errors\":[\"Failed to update onboarded Service Account.\"]}");
    String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
    UserDetails userDetails = getMockUser(true);
    ServiceAccount serviceAccount = generateServiceAccount("testacc02", "testacc01");
    Response response = getMockResponse(HttpStatus.OK, true, "{\"keys\":[\"testacc02\"]}");
    when(reqProcessor.process("/ad/serviceaccount/onboardedlist","{}",token)).thenReturn(response);
    Response onboardResponse = getMockResponse(HttpStatus.BAD_REQUEST, true, "{}");
    when(reqProcessor.process(eq("/ad/serviceaccount/onboard"), Mockito.any(), eq(token))).thenReturn(onboardResponse);
    List<ADServiceAccount> allServiceAccounts = new ArrayList<>();
    allServiceAccounts.add(generateADServiceAccount("testacc02"));
    ReflectionTestUtils.setField(serviceAccountsService, "ldapTemplate", ldapTemplate);
    when(ldapTemplate.search(Mockito.anyString(), Mockito.any(), Mockito.any(AttributesMapper.class))).thenReturn(allServiceAccounts);
    ResponseEntity<String> responseEntityActual =  serviceAccountsService.updateOnboardedServiceAccount(token, serviceAccount, userDetails);
    assertEquals(HttpStatus.MULTI_STATUS, responseEntityActual.getStatusCode());
    assertEquals(responseEntityExpected, responseEntityActual);
}