@Test public void testGetByCrnFound() { when(repository.findByResourceCrn(any())).thenReturn(Optional.of(server)); DatabaseServerConfig foundServer = underTest.getByCrn(SERVER_CRN.toString()); assertEquals(server, foundServer); }
public DatabaseServerConfig getByCrn(String resourceCrn) { Crn crn = Crn.safeFromString(resourceCrn); Optional<DatabaseServerConfig> resourceOpt = repository.findByResourceCrn(crn); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No %s found with crn '%s'", DatabaseServerConfig.class.getSimpleName(), resourceCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }
DatabaseServerConfigService extends AbstractArchivistService<DatabaseServerConfig> implements ResourceBasedCrnProvider { public DatabaseServerConfig getByCrn(String resourceCrn) { Crn crn = Crn.safeFromString(resourceCrn); Optional<DatabaseServerConfig> resourceOpt = repository.findByResourceCrn(crn); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No %s found with crn '%s'", DatabaseServerConfig.class.getSimpleName(), resourceCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); } }
DatabaseServerConfigService extends AbstractArchivistService<DatabaseServerConfig> implements ResourceBasedCrnProvider { public DatabaseServerConfig getByCrn(String resourceCrn) { Crn crn = Crn.safeFromString(resourceCrn); Optional<DatabaseServerConfig> resourceOpt = repository.findByResourceCrn(crn); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No %s found with crn '%s'", DatabaseServerConfig.class.getSimpleName(), resourceCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }  }
DatabaseServerConfigService extends AbstractArchivistService<DatabaseServerConfig> implements ResourceBasedCrnProvider { public DatabaseServerConfig getByCrn(String resourceCrn) { Crn crn = Crn.safeFromString(resourceCrn); Optional<DatabaseServerConfig> resourceOpt = repository.findByResourceCrn(crn); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No %s found with crn '%s'", DatabaseServerConfig.class.getSimpleName(), resourceCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }  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 { public DatabaseServerConfig getByCrn(String resourceCrn) { Crn crn = Crn.safeFromString(resourceCrn); Optional<DatabaseServerConfig> resourceOpt = repository.findByResourceCrn(crn); if (resourceOpt.isEmpty()) { throw new NotFoundException(String.format("No %s found with crn '%s'", DatabaseServerConfig.class.getSimpleName(), resourceCrn)); } MDCBuilder.buildMdcContext(resourceOpt.get()); return resourceOpt.get(); }  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();  }