Search in sources :

Example 16 with BuildConfigurationClient

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

the class GroupConfigurationEndpointTest method shouldDeleteBuildConfigWithPatch.

@Test
public void shouldDeleteBuildConfigWithPatch() throws Exception {
    // given
    GroupConfigurationClient groupConfigurationClient = new GroupConfigurationClient(RestClientConfiguration.asUser());
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    GroupConfiguration gc = groupConfigurationClient.getAll().iterator().next();
    assertThat(gc.getBuildConfigs()).isNotEmpty();
    BuildConfiguration toRemove = bcClient.getSpecific(gc.getBuildConfigs().keySet().iterator().next());
    GroupConfigurationPatchBuilder builder = new GroupConfigurationPatchBuilder();
    builder.removeBuildConfigs(Collections.singletonList(toRemove.getId()));
    // when
    groupConfigurationClient.patch(gc.getId(), builder);
    // then
    GroupConfiguration refresh = groupConfigurationClient.getSpecific(gc.getId());
    assertThat(refresh.getBuildConfigs().keySet()).doesNotContain(toRemove.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupConfigurationPatchBuilder(org.jboss.pnc.client.patch.GroupConfigurationPatchBuilder) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 17 with BuildConfigurationClient

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

the class ProductVersionEndpointTest method shouldDeleteBuildConfigWithPatch.

@Test
public void shouldDeleteBuildConfigWithPatch() throws Exception {
    // given
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    assertThat(productVersion.getBuildConfigs()).isNotEmpty();
    BuildConfiguration toRemove = bcClient.getSpecific(productVersion.getBuildConfigs().keySet().iterator().next());
    ProductVersionPatchBuilder builder = new ProductVersionPatchBuilder();
    builder.removeBuildConfigs(Collections.singletonList(toRemove.getId()));
    // when
    client.patch(productVersion.getId(), builder);
    // then
    ProductVersion refresh = client.getSpecific(productVersionsId2);
    assertThat(refresh.getBuildConfigs().keySet()).doesNotContain(toRemove.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ProductVersion(org.jboss.pnc.dto.ProductVersion) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ProductVersionPatchBuilder(org.jboss.pnc.client.patch.ProductVersionPatchBuilder) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 18 with BuildConfigurationClient

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

the class AdvancedBuildConfigurationClient method fallbackSupplier.

/**
 * Used to retrieve build through through REST when WS Client loses connection and reconnects
 *
 * @param bcId Id of the BuildConfig where the build was run
 * @return
 * @throws RemoteResourceException
 */
private Build fallbackSupplier(String bcId) throws RemoteResourceException {
    BuildsFilterParameters parameters = new BuildsFilterParameters();
    parameters.setLatest(true);
    Build build = null;
    try (BuildConfigurationClient client = new BuildConfigurationClient(configuration)) {
        build = client.getBuilds(bcId, parameters).iterator().next();
    }
    return build;
}
Also used : Build(org.jboss.pnc.dto.Build) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters)

Example 19 with BuildConfigurationClient

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

the class BuildConfigurationEndpointTest method shouldNotUpdateWhenEnvironmentDoesNotExist.

@Test
public void shouldNotUpdateWhenEnvironmentDoesNotExist() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration origBC = client.getSpecific(configurationId);
    BuildConfiguration updateBC = origBC.toBuilder().environment(Environment.builder().id("10000").build()).build();
    assertThatThrownBy(() -> client.update(configurationId, updateBC)).hasCauseInstanceOf(NotFoundException.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 20 with BuildConfigurationClient

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

the class BuildConfigurationEndpointTest method shouldGetBuildConfigurationRevisions.

@Test
public void shouldGetBuildConfigurationRevisions() throws Exception {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfigurationRevision> revisions = client.getRevisions(configurationId);
    assertThat(revisions).anySatisfy(config -> assertThat(config.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)

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