use of org.jboss.pnc.client.ClientException in project pnc by project-ncl.
the class EnvironmentEndpointTest method shouldFailToSaveEnvironmentAsUser.
@Test
@InSequence(30)
public void shouldFailToSaveEnvironmentAsUser() {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asUser());
Environment.Builder environmentBuilder = Environment.builder().name("OpenJDK 14.0; Mvn 3.6.5").description("OpenJDK 14.0; Mvn 3.6.5").systemImageId("builder-rhel-8-j14-mvn3.6.5:1.0").systemImageRepositoryUrl("quay.io/rh-newcastle").systemImageType(SystemImageType.DOCKER_IMAGE);
Exception caught = null;
try {
client.createNew(environmentBuilder.build());
} catch (ClientException e) {
caught = e;
}
Assertions.assertThat(caught).isNotNull();
Assertions.assertThat(caught.getCause()).isInstanceOf(javax.ws.rs.ForbiddenException.class);
}
use of org.jboss.pnc.client.ClientException in project pnc by project-ncl.
the class ProductEndpointTest method shouldFailToSaveProductWithSpaceInAbbreviation.
@Test
public void shouldFailToSaveProductWithSpaceInAbbreviation() {
ProductClient client = new ProductClient(RestClientConfiguration.asUser());
Product product = Product.builder().name("New Ab re via ted product").abbreviation("abb re viation").description("The newst product of them all. Now with spaces.").build();
try {
client.createNew(product);
fail("Exception should be thrown");
} catch (ClientException ex) {
// OK
}
}
use of org.jboss.pnc.client.ClientException in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method testGetBuildConfigurationForARepository.
@Test
public void testGetBuildConfigurationForARepository() throws ClientException {
BuildConfigurationClient buildConfigurationClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
SCMRepository scmRepository = repositoryClient.getAll(null, null).iterator().next();
Iterator<BuildConfiguration> allConfigsIterator = buildConfigurationClient.getAll().iterator();
BuildConfiguration buildConfiguration1 = allConfigsIterator.next().toBuilder().scmRepository(scmRepository).build();
BuildConfiguration buildConfiguration2 = allConfigsIterator.next().toBuilder().scmRepository(scmRepository).build();
buildConfigurationClient.update(buildConfiguration1.getId(), buildConfiguration1);
buildConfigurationClient.update(buildConfiguration2.getId(), buildConfiguration2);
RemoteCollection<BuildConfiguration> buildConfigs = repositoryClient.getBuildConfigs(scmRepository.getId());
assertThat(buildConfigs).usingElementComparatorIgnoringFields("modificationTime", "creationUser", "modificationUser").contains(buildConfiguration1, buildConfiguration2).allSatisfy((bc -> scmRepository.equals(bc.getScmRepository())));
}
use of org.jboss.pnc.client.ClientException in project pnc by project-ncl.
the class WebSocketClientTest method groupBuildToFinish.
private Boolean groupBuildToFinish(String groupBuildId) {
GroupBuild build = null;
try {
build = new GroupBuildClient(RestClientConfiguration.asUser()).getSpecific(groupBuildId);
assertThat(build).isNotNull();
if (!build.getStatus().isFinal())
return false;
} catch (RemoteResourceNotFoundException e) {
fail(String.format("Group Build with id:%s not present", groupBuildId), e);
} catch (ClientException e) {
fail("Client has failed in an unexpected way.", e);
}
return true;
}
Aggregations