@Test public void testDeleteCreatedServerWithDatabases() { when(repository.findByResourceCrn(SERVER_CRN)).thenReturn(Optional.of(server)); server.setResourceStatus(ResourceStatus.SERVICE_MANAGED); DatabaseConfig databaseConfig1 = new DatabaseConfig(); databaseConfig1.setId(1L); DatabaseConfig databaseConfig2 = new DatabaseConfig(); databaseConfig2.setId(2L); Set<DatabaseConfig> databases = new HashSet<>(); databases.add(databaseConfig1); databases.add(databaseConfig2); server.setDatabases(databases); underTest.delete(server); verify(databaseConfigService).delete(databaseConfig1, true, true); verify(databaseConfigService).delete(databaseConfig2, true, true); }
@Override public DatabaseServerConfig delete(DatabaseServerConfig resource) { if (resource.getDatabases() != null) { for (DatabaseConfig db : resource.getDatabases()) { databaseConfigService.delete(db, true, true); } } DatabaseServerConfig resourceToDelete = getByCrn(resource.getResourceCrn()).get(); DatabaseServerConfig archived = super.delete(resourceToDelete); grpcUmsClient.notifyResourceDeleted(archived.getResourceCrn().toString(), MDCUtils.getRequestId()); return archived; }
DatabaseServerConfigService extends AbstractArchivistService<DatabaseServerConfig> implements ResourceBasedCrnProvider { @Override public DatabaseServerConfig delete(DatabaseServerConfig resource) { if (resource.getDatabases() != null) { for (DatabaseConfig db : resource.getDatabases()) { databaseConfigService.delete(db, true, true); } } DatabaseServerConfig resourceToDelete = getByCrn(resource.getResourceCrn()).get(); DatabaseServerConfig archived = super.delete(resourceToDelete); grpcUmsClient.notifyResourceDeleted(archived.getResourceCrn().toString(), MDCUtils.getRequestId()); return archived; } }
DatabaseServerConfigService extends AbstractArchivistService<DatabaseServerConfig> implements ResourceBasedCrnProvider { @Override public DatabaseServerConfig delete(DatabaseServerConfig resource) { if (resource.getDatabases() != null) { for (DatabaseConfig db : resource.getDatabases()) { databaseConfigService.delete(db, true, true); } } DatabaseServerConfig resourceToDelete = getByCrn(resource.getResourceCrn()).get(); DatabaseServerConfig archived = super.delete(resourceToDelete); grpcUmsClient.notifyResourceDeleted(archived.getResourceCrn().toString(), MDCUtils.getRequestId()); return archived; }  }
DatabaseServerConfigService extends AbstractArchivistService<DatabaseServerConfig> implements ResourceBasedCrnProvider { @Override public DatabaseServerConfig delete(DatabaseServerConfig resource) { if (resource.getDatabases() != null) { for (DatabaseConfig db : resource.getDatabases()) { databaseConfigService.delete(db, true, true); } } DatabaseServerConfig resourceToDelete = getByCrn(resource.getResourceCrn()).get(); DatabaseServerConfig archived = super.delete(resourceToDelete); grpcUmsClient.notifyResourceDeleted(archived.getResourceCrn().toString(), MDCUtils.getRequestId()); return archived; }  Set<DatabaseServerConfig> findAll(Long workspaceId, String environmentCrn); DatabaseServerConfig create(DatabaseServerConfig resource, Long workspaceId, boolean test); DatabaseServerConfig update(DatabaseServerConfig resource); DatabaseServerConfig release(String resourceCrn); @Override DatabaseServerConfig delete(DatabaseServerConfig resource); DatabaseServerConfig getByName(Long workspaceId, String environmentCrn, String name); DatabaseServerConfig getByCrn(String resourceCrn); Optional<DatabaseServerConfig> getByCrn(Crn resourceCrn); Optional<DatabaseServerConfig> getByClusterCrn(String clusterCrn); DatabaseServerConfig deleteByCrn(String crn); @Override JpaRepository repository(); Set<DatabaseServerConfig> getByCrns(Set<String> crns); String testConnection(String crn); String testConnection(DatabaseServerConfig resource); String createDatabaseOnServer(String serverCrn, String databaseName, String databaseType, Optional<String> databaseDescription); @Override AuthorizationResourceType getResourceType(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); }
DatabaseServerConfigService extends AbstractArchivistService<DatabaseServerConfig> implements ResourceBasedCrnProvider { @Override public DatabaseServerConfig delete(DatabaseServerConfig resource) { if (resource.getDatabases() != null) { for (DatabaseConfig db : resource.getDatabases()) { databaseConfigService.delete(db, true, true); } } DatabaseServerConfig resourceToDelete = getByCrn(resource.getResourceCrn()).get(); DatabaseServerConfig archived = super.delete(resourceToDelete); grpcUmsClient.notifyResourceDeleted(archived.getResourceCrn().toString(), MDCUtils.getRequestId()); return archived; }  Set<DatabaseServerConfig> findAll(Long workspaceId, String environmentCrn); DatabaseServerConfig create(DatabaseServerConfig resource, Long workspaceId, boolean test); DatabaseServerConfig update(DatabaseServerConfig resource); DatabaseServerConfig release(String resourceCrn); @Override DatabaseServerConfig delete(DatabaseServerConfig resource); DatabaseServerConfig getByName(Long workspaceId, String environmentCrn, String name); DatabaseServerConfig getByCrn(String resourceCrn); Optional<DatabaseServerConfig> getByCrn(Crn resourceCrn); Optional<DatabaseServerConfig> getByClusterCrn(String clusterCrn); DatabaseServerConfig deleteByCrn(String crn); @Override JpaRepository repository(); Set<DatabaseServerConfig> getByCrns(Set<String> crns); String testConnection(String crn); String testConnection(DatabaseServerConfig resource); String createDatabaseOnServer(String serverCrn, String databaseName, String databaseType, Optional<String> databaseDescription); @Override AuthorizationResourceType getResourceType(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount();  }