### Question:
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public DatabaseConfig deleteByCrn(String resourceCrn) { DatabaseConfig resource = getByCrn(resourceCrn); return delete(resource); }  Set<DatabaseConfig> findAll(String environmentCrn); DatabaseConfig register(DatabaseConfig configToSave, boolean test); DatabaseConfig getByCrn(String resourceCrn); DatabaseConfig getByName(String name, String environmentCrn); DatabaseConfig getByName(String name); Set<DatabaseConfig> deleteMultipleByCrn(Set<String> resourceCrns); DatabaseConfig deleteByCrn(String resourceCrn); DatabaseConfig deleteByName(String name, String environmentCrn); String testConnection(String databaseConfigName, String environmentCrn); String testConnection(DatabaseConfig config); @Override DatabaseConfig delete(DatabaseConfig databaseConfig); DatabaseConfig delete(DatabaseConfig databaseConfig, boolean force, boolean skipDeletionOnServer); @Override JpaRepository repository(); @Override Long getResourceIdByResourceCrn(String resourceCrn); @Override Long getResourceIdByResourceName(String resourceName); @Override AuthorizationResourceType getResourceType(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount();  }### Answer:
@Test public void testDeleteByCrnRegisteredDatabase() { DatabaseConfig databaseConfig = getDatabaseConfig(ResourceStatus.USER_MANAGED, DATABASE_NAME); when(repository.findByResourceCrn(DB_CRN)).thenReturn(Optional.of(databaseConfig)); underTest.deleteByCrn(DB_CRN_STRING); assertTrue(databaseConfig.isArchived()); verify(repository).save(databaseConfig); }
@Test public void testDeleteByCrnNotFound() { thrown.expect(NotFoundException.class); when(repository.findByResourceCrn(DB_CRN)).thenReturn(Optional.empty()); underTest.deleteByCrn(DB_CRN_STRING); }
@Test public void testDeleteByCrnCreatedDatabase() { DatabaseServerConfig server = new DatabaseServerConfig(); server.setId(1L); server.setName("myserver"); DatabaseConfig databaseConfig = getDatabaseConfig(ResourceStatus.SERVICE_MANAGED, DATABASE_NAME); databaseConfig.setServer(server); when(repository.findByResourceCrn(DB_CRN)).thenReturn(Optional.of(databaseConfig)); underTest.deleteByCrn(DB_CRN_STRING); assertTrue(databaseConfig.isArchived()); verify(repository).save(databaseConfig); verify(driverFunctions).execWithDatabaseDriver(eq(server), any()); }