@Test public void testGetByNameNotFound() { thrown.expect(NotFoundException.class); when(repository.findByEnvironmentIdAndName("id", db.getName())).thenReturn(Optional.empty()); underTest.getByName(db.getName(), "id"); }
public DatabaseConfig getByName(String name, String environmentCrn) { Optional<DatabaseConfig> resourceOpt = repository.findByEnvironmentIdAndName(environmentCrn, name); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No database found with name '%s' in environment '%s'", name, environmentCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public DatabaseConfig getByName(String name, String environmentCrn) { Optional<DatabaseConfig> resourceOpt = repository.findByEnvironmentIdAndName(environmentCrn, name); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No database found with name '%s' in environment '%s'", name, environmentCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); } }
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public DatabaseConfig getByName(String name, String environmentCrn) { Optional<DatabaseConfig> resourceOpt = repository.findByEnvironmentIdAndName(environmentCrn, name); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No database found with name '%s' in environment '%s'", name, environmentCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }  }
DatabaseConfigService extends AbstractArchivistService<DatabaseConfig> implements ResourceIdProvider, ResourceBasedCrnProvider { public DatabaseConfig getByName(String name, String environmentCrn) { Optional<DatabaseConfig> resourceOpt = repository.findByEnvironmentIdAndName(environmentCrn, name); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No database found with name '%s' in environment '%s'", name, environmentCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }  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 DatabaseConfig getByName(String name, String environmentCrn) { Optional<DatabaseConfig> resourceOpt = repository.findByEnvironmentIdAndName(environmentCrn, name); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No database found with name '%s' in environment '%s'", name, environmentCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }  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();  }