### Question:
LdapConfigService extends AbstractArchivistService<LdapConfig> { public LdapConfig createLdapConfig(LdapConfig ldapConfig) { String accountId = crnService.getCurrentAccountId(); return createLdapConfig(ldapConfig, accountId); }  LdapConfig createLdapConfig(LdapConfig ldapConfig); LdapConfig createLdapConfig(LdapConfig ldapConfig, String accountId); LdapConfig get(String environmentCrn); List<LdapConfig> findAllByEnvironmentAndAccountIdEvenIfArchived(String environmentCrn, String accountId); Optional<LdapConfig> find(String environmentCrn, String accountId, String clusterName); void delete(String environmentCrn); void delete(String environmentCrn, String accountId); void delete(String environmentCrn, String accountId, String clusterName); void deleteAllInEnvironment(String environmentCrn, String accountId); String testConnection(String environmentCrn, LdapConfig ldapConfig); @Override JpaRepository repository();  }### Answer:
@Test public void testCreateKerberosConfig() { LdapConfig ldapConfig = new LdapConfig(); ldapConfig.setEnvironmentCrn(ENVIRONMENT_ID); Mockito.when(crnService.getCurrentAccountId()).thenReturn(ACCOUNT_ID); Mockito.when(crnService.createCrn(ACCOUNT_ID, Crn.ResourceType.LDAP)).thenReturn(RESOURCE_CRN); Mockito.when(ldapConfigRepository.save(ldapConfig)).thenReturn(ldapConfig); underTest.createLdapConfig(ldapConfig); assertNotNull(ldapConfig.getResourceCrn()); }
@Test public void testCreateKerberosConfigWhenThereIsAlreadyExisted() { LdapConfig ldapConfig = new LdapConfig(); ldapConfig.setEnvironmentCrn(ENVIRONMENT_ID); Mockito.when(crnService.getCurrentAccountId()).thenReturn(ACCOUNT_ID); Mockito.when(ldapConfigRepository.findByAccountIdAndEnvironmentCrnAndClusterNameIsNullAndArchivedIsFalse(ACCOUNT_ID, ENVIRONMENT_ID)) .thenReturn(Optional.of(new LdapConfig())); BadRequestException ex = Assertions.assertThrows(BadRequestException.class, () -> { underTest.createLdapConfig(ldapConfig); }); assertEquals("LdapConfig in the [accountId] account's [environmentId] environment is already exists", ex.getMessage()); }