@Test public void testExistingConnectionFails() { DatabaseConfig existingDatabaseConfig = new DatabaseConfig(); when(repository.findByEnvironmentIdAndName(ENVIRONMENT_CRN, DATABASE_NAME)).thenReturn(Optional.of(existingDatabaseConfig)); doAnswer((Answer) invocation -> { MapBindingResult errors = invocation.getArgument(1, MapBindingResult.class); errors.addError(new ObjectError("failed", ERROR_MESSAGE)); return null; }).when(connectionValidator).validate(any(), any()); String result = underTest.testConnection(DATABASE_NAME, ENVIRONMENT_CRN); assertEquals(ERROR_MESSAGE, result); verify(connectionValidator).validate(eq(existingDatabaseConfig), any()); }
public String testConnection(String databaseConfigName, String environmentCrn) { DatabaseConfig databaseConfig = getByName(databaseConfigName, environmentCrn); return testConnection(databaseConfig); }
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public String testConnection(String databaseConfigName, String environmentCrn) { DatabaseConfig databaseConfig = getByName(databaseConfigName, environmentCrn); return testConnection(databaseConfig); } }
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public String testConnection(String databaseConfigName, String environmentCrn) { DatabaseConfig databaseConfig = getByName(databaseConfigName, environmentCrn); return testConnection(databaseConfig); }  }
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public String testConnection(String databaseConfigName, String environmentCrn) { DatabaseConfig databaseConfig = getByName(databaseConfigName, environmentCrn); return testConnection(databaseConfig); }  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(); }
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public String testConnection(String databaseConfigName, String environmentCrn) { DatabaseConfig databaseConfig = getByName(databaseConfigName, environmentCrn); return testConnection(databaseConfig); }  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();  }