Search in sources :

Example 6 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldGetBuildConfigurationRevision.

@Test
public void shouldGetBuildConfigurationRevision() throws Exception {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    BuildConfigurationRevision revision = client.getRevision(configurationId, 1);
    assertThat(revision.getId()).isEqualTo(configurationId);
}
Also used : BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 7 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldNotCreateWhenEnvironmentDoesNotExist.

@Test
public void shouldNotCreateWhenEnvironmentDoesNotExist() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    Environment origEnv = bc.getEnvironment();
    Environment env = Environment.builder().attributes(origEnv.getAttributes()).deprecated(origEnv.isDeprecated()).description(origEnv.getDescription()).name(origEnv.getName()).systemImageId(origEnv.getSystemImageId()).systemImageRepositoryUrl(origEnv.getSystemImageRepositoryUrl()).systemImageType(origEnv.getSystemImageType()).id("10000").build();
    BuildConfiguration newBC = BuildConfiguration.builder().name("othernameforbc2").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(env).parameters(bc.getParameters()).buildType(bc.getBuildType()).scmRepository(bc.getScmRepository()).scmRevision(bc.getScmRevision()).build();
    assertThatThrownBy(() -> client.createNew(newBC)).hasCauseInstanceOf(NotFoundException.class);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Environment(org.jboss.pnc.dto.Environment) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 8 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method createBuildConfigurationAndValidateResults.

private BuildConfiguration createBuildConfigurationAndValidateResults(String projectId, String environmentId, String repositoryConfigurationId, String name, String genericParameterValue1) throws ClientException {
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().project(ProjectRef.refBuilder().id(projectId).build()).environment(Environment.builder().id(environmentId).build()).scmRepository(SCMRepository.builder().id(repositoryConfigurationId).build()).name(name).parameters(Collections.singletonMap(PARAMETER_KEY, genericParameterValue1)).buildType(BuildType.MVN).build();
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration newBC = client.createNew(buildConfiguration);
    return newBC;
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient)

Example 9 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldFailToCreateNewBuildConfigurationBecauseIdIsNotNull.

@Test
public void shouldFailToCreateNewBuildConfigurationBecauseIdIsNotNull() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    BuildConfiguration bcNew = BuildConfiguration.builder().id(configurationId).name("newbcname").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(bc.getEnvironment()).parameters(bc.getParameters()).scmRepository(bc.getScmRepository()).buildType(bc.getBuildType()).build();
    assertThatThrownBy(() -> client.createNew(bcNew)).hasCauseInstanceOf(BadRequestException.class);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 10 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method testAddDependency.

@Test
@InSequence(20)
public void testAddDependency() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    // given
    BuildConfiguration newDependency = createBuildConfigurationAndValidateResults(projectId, environmentId, repositoryConfigurationId, "dep-" + UUID.randomUUID(), PARAMETER_KEY);
    BuildConfiguration parent = client.getSpecific(configuration3Id);
    Map<String, BuildConfigurationRef> oldDependencies = parent.getDependencies();
    assertThat(oldDependencies).doesNotContainKey(newDependency.getId());
    // when
    client.addDependency(parent.getId(), newDependency);
    // then
    RemoteCollection<BuildConfiguration> all = client.getDependencies(parent.getId());
    assertThat(all).extracting(DTOEntity::getId).containsAll(oldDependencies.keySet().stream().collect(Collectors.toList())).contains(newDependency.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) DTOEntity(org.jboss.pnc.dto.DTOEntity) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)41 ContainerTest (org.jboss.pnc.test.category.ContainerTest)37 Test (org.junit.Test)37 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)32 InSequence (org.jboss.arquillian.junit.InSequence)16 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)6 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)6 Instant (java.time.Instant)5 Build (org.jboss.pnc.dto.Build)5 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)5 SCMRepositoryClient (org.jboss.pnc.client.SCMRepositoryClient)4 HashMap (java.util.HashMap)3 ClientErrorException (javax.ws.rs.ClientErrorException)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Deployment (org.jboss.arquillian.container.test.api.Deployment)3 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)3 Arquillian (org.jboss.arquillian.junit.Arquillian)3 ClientException (org.jboss.pnc.client.ClientException)3 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)3 BuildConfigurationPatchBuilder (org.jboss.pnc.client.patch.BuildConfigurationPatchBuilder)3