use of com.sequenceiq.redbeams.exception.NotFoundException in project cloudbreak by hortonworks.
the class DatabaseServerConfigServiceTest method testGetByCrnsNotFound.
@Test
public void testGetByCrnsNotFound() {
Set<String> crnSet = Set.of(SERVER_CRN.toString(), SERVER_2_CRN.toString());
Set<DatabaseServerConfig> serverSet = Set.of(server);
when(repository.findByResourceCrnIn(Set.of(SERVER_CRN, SERVER_2_CRN))).thenReturn(serverSet);
NotFoundException exception = assertThrows(NotFoundException.class, () -> underTest.getByCrns(crnSet));
assertThat(exception.getMessage(), containsString("found with crn(s) " + SERVER_2_CRN));
}
use of com.sequenceiq.redbeams.exception.NotFoundException in project cloudbreak by hortonworks.
the class DatabaseServerConfigService method getByClusterCrn.
public DatabaseServerConfig getByClusterCrn(String environmentCrn, String clusterCrn) {
DatabaseServerConfig databaseServerConfig = findByEnvironmentCrnAndClusterCrn(environmentCrn, clusterCrn).orElseThrow(() -> new NotFoundException(String.format("No %s found with cluster CRN '%s' in environment '%s'", DatabaseServerConfig.class.getSimpleName(), clusterCrn, environmentCrn)));
MDCBuilder.buildMdcContext(databaseServerConfig);
return databaseServerConfig;
}
use of com.sequenceiq.redbeams.exception.NotFoundException in project cloudbreak by hortonworks.
the class DatabaseConfigService method getByCrn.
public DatabaseConfig getByCrn(String resourceCrn) {
Crn crn = Crn.safeFromString(resourceCrn);
Optional<DatabaseConfig> resourceOpt = repository.findByResourceCrn(crn);
if (resourceOpt.isEmpty()) {
throw new NotFoundException(String.format("No database found with crn '%s'", resourceCrn));
}
MDCBuilder.buildMdcContext(resourceOpt.get());
return resourceOpt.get();
}
use of com.sequenceiq.redbeams.exception.NotFoundException in project cloudbreak by hortonworks.
the class DatabaseServerConfigService method getByCrn.
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();
}
use of com.sequenceiq.redbeams.exception.NotFoundException in project cloudbreak by hortonworks.
the class DatabaseServerV4ControllerTest method testUpdateClusterCrn.
@Test
public void testUpdateClusterCrn() {
when(service.findByEnvironmentCrnAndClusterCrn(ENVIRONMENT_CRN, CLUSTER_CRN)).thenReturn(Optional.of(server));
underTest.updateClusterCrn(ENVIRONMENT_CRN, CLUSTER_CRN, CLUSTER_CRN1, USER_CRN);
when(service.findByEnvironmentCrnAndClusterCrn(ENVIRONMENT_CRN, CLUSTER_CRN)).thenThrow(new NotFoundException("Not found"));
try {
underTest.updateClusterCrn(ENVIRONMENT_CRN, CLUSTER_CRN, CLUSTER_CRN1, USER_CRN);
Assert.fail("NotFoundException should have been thrown");
} catch (NotFoundException notFoundException) {
}
}
Aggregations