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