Search in sources :

Example 1 with EnvironmentClient

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();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) ProductClient(org.jboss.pnc.client.ProductClient) EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) ProjectClient(org.jboss.pnc.client.ProjectClient) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) SCMRepository(org.jboss.pnc.dto.SCMRepository) BeforeClass(org.junit.BeforeClass)

Example 2 with EnvironmentClient

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);
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Example 3 with EnvironmentClient

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);
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Example 4 with EnvironmentClient

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);
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) ClientException(org.jboss.pnc.client.ClientException) ClientException(org.jboss.pnc.client.ClientException) RemoteResourceException(org.jboss.pnc.client.RemoteResourceException) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with EnvironmentClient

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");
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

EnvironmentClient (org.jboss.pnc.client.EnvironmentClient)8 InSequence (org.jboss.arquillian.junit.InSequence)6 ContainerTest (org.jboss.pnc.test.category.ContainerTest)6 Test (org.junit.Test)6 Environment (org.jboss.pnc.dto.Environment)5 SCMRepositoryClient (org.jboss.pnc.client.SCMRepositoryClient)2 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)2 SCMRepository (org.jboss.pnc.dto.SCMRepository)2 BeforeClass (org.junit.BeforeClass)2 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)1 ClientException (org.jboss.pnc.client.ClientException)1 ProductClient (org.jboss.pnc.client.ProductClient)1 ProjectClient (org.jboss.pnc.client.ProjectClient)1 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)1 Project (org.jboss.pnc.dto.Project)1