use of org.jboss.pnc.client.EnvironmentClient in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method prepareData.
@SuppressWarnings("unchecked")
@BeforeClass
public static void prepareData() throws Exception {
BuildConfigurationClient bcc = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
Iterator<BuildConfiguration> it = bcc.getAll().iterator();
configurationId = it.next().getId();
configuration2Id = it.next().getId();
configuration3Id = it.next().getId();
configuration4Id = it.next().getId();
ProductClient pdc = new ProductClient(RestClientConfiguration.asAnonymous());
productId = pdc.getAll().iterator().next().getId();
EnvironmentClient ec = new EnvironmentClient(RestClientConfiguration.asAnonymous());
environmentId = ec.getAll().iterator().next().getId();
ProjectClient pjc = new ProjectClient(RestClientConfiguration.asAnonymous());
projectId = pjc.getAll().iterator().next().getId();
SCMRepositoryClient scmrc = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
final Iterator<SCMRepository> scmrIt = scmrc.getAll(null, null).iterator();
repositoryConfigurationId = scmrIt.next().getId();
repositoryConfiguration2Id = scmrIt.next().getId();
}
use of org.jboss.pnc.client.EnvironmentClient in project pnc by project-ncl.
the class EnvironmentEndpointTest method testQueryForEnvironment.
@Test
@InSequence(20)
public void testQueryForEnvironment() throws RemoteResourceException {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Environment> allNonDeprecated = client.getAll(Optional.empty(), Optional.of("deprecated==false"));
RemoteCollection<Environment> allDeprecated = client.getAll(Optional.empty(), Optional.of("deprecated==true"));
assertThat(allNonDeprecated.getAll().stream().map(Environment::isDeprecated)).containsOnly(false);
assertThat(allDeprecated.getAll().stream().map(Environment::isDeprecated)).containsOnly(true);
}
use of org.jboss.pnc.client.EnvironmentClient in project pnc by project-ncl.
the class EnvironmentEndpointTest method shouldSaveEnvironmentAndDeprecateOldOnes.
@Test
@InSequence(30)
public void shouldSaveEnvironmentAndDeprecateOldOnes() throws ClientException {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asSystem());
Environment.Builder environmentBuilder = Environment.builder().name("OpenJDK 14.0; Mvn 3.6.5").description("OpenJDK 14.0; Mvn 3.6.5").systemImageRepositoryUrl("quay.io/rh-newcastle").systemImageType(SystemImageType.DOCKER_IMAGE);
Environment envVers10 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.0").build());
String envVers10Id = envVers10.getId();
Environment envVers10RetrievedFromDB = client.getSpecific(envVers10Id);
Assertions.assertThat(envVers10RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
Assertions.assertThat(envVers10RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.0");
Assertions.assertThat(envVers10RetrievedFromDB.isDeprecated()).isEqualTo(false);
Environment envVers11 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.1").build());
String envVers11Id = envVers11.getId();
Environment envVers11RetrievedFromDB = client.getSpecific(envVers11Id);
Assertions.assertThat(envVers11RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
Assertions.assertThat(envVers11RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.1");
Assertions.assertThat(envVers11RetrievedFromDB.isDeprecated()).isEqualTo(false);
Environment envVers12 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.2").build());
String envVers12Id = envVers12.getId();
Environment envVers12RetrievedFromDB = client.getSpecific(envVers12Id);
Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
Assertions.assertThat(envVers12RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.2");
Assertions.assertThat(envVers12RetrievedFromDB.isDeprecated()).isEqualTo(false);
envVers10RetrievedFromDB = client.getSpecific(envVers10Id);
envVers11RetrievedFromDB = client.getSpecific(envVers11Id);
Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo(envVers10RetrievedFromDB.getName());
Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo(envVers11RetrievedFromDB.getName());
Assertions.assertThat(envVers12RetrievedFromDB.isDeprecated()).isEqualTo(false);
Assertions.assertThat(envVers11RetrievedFromDB.isDeprecated()).isEqualTo(true);
Assertions.assertThat(envVers10RetrievedFromDB.isDeprecated()).isEqualTo(true);
}
use of org.jboss.pnc.client.EnvironmentClient 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.EnvironmentClient in project pnc by project-ncl.
the class EnvironmentEndpointTest method testGetSpecificEnvironment.
@Test
@InSequence(20)
public void testGetSpecificEnvironment() throws ClientException {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
Environment environment = client.getSpecific(environmentId);
// from DatabaseDataInitializer
assertThat(environment.getName()).isEqualTo("Demo Environment 1");
}
Aggregations