Search in sources :

Example 31 with BuildConfigurationClient

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

the class BuildConfigurationEndpointTest method shouldCloneBuildConfiguration.

@Test
@InSequence(20)
public void shouldCloneBuildConfiguration() throws ClientException {
    // given
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration original = client.getSpecific(configurationId);
    assertThat(original.getProductVersion()).isNotNull();
    assertThat(original.getGroupConfigs()).isNotEmpty();
    BuildConfiguration parent = client.getSpecific(configuration4Id);
    assertThat(parent.getDependencies()).containsKey(configurationId);
    // when
    BuildConfiguration clone = client.clone(original.getId());
    // then
    assertThat(clone.getId()).isNotEmpty();
    assertThat(clone.getProductVersion()).isNull();
    assertThat(clone.getGroupConfigs()).isEmpty();
    BuildConfiguration retrieved = client.getSpecific(clone.getId());
    BuildConfiguration retrivedParent = client.getSpecific(configuration4Id);
    assertThat(retrivedParent.getDependencies()).containsKey(configurationId);
    assertThat(retrivedParent.getDependencies()).doesNotContainKey(clone.getId());
    assertThat(clone).isEqualToIgnoringGivenFields(original, "id", "name", "groupConfigs", "creationTime", "modificationTime", "modificationTime", "productVersion", "creationUser", "modificationUser");
    assertThat(retrieved).isEqualToIgnoringGivenFields(clone, "modificationTime", "creationUser", // close
    "modificationUser");
// of
// transaction
// changes
// the modification time -
// WONTFIX
}
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) InSequence(org.jboss.arquillian.junit.InSequence)

Example 32 with BuildConfigurationClient

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

the class BuildConfigurationEndpointTest method shouldReturn404WhenRevisionToRestoreDoesNotExist.

// TODO Test will fail due to issue: NCL-4473, remove @Ignore when fixed.
@Ignore
@Test
public void shouldReturn404WhenRevisionToRestoreDoesNotExist() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    assertThatThrownBy(() -> client.restoreRevision(configurationId, 9999)).hasCauseInstanceOf(NotFoundException.class);
}
Also used : BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) Ignore(org.junit.Ignore) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 33 with BuildConfigurationClient

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

the class BuildConfigurationEndpointTest method shouldDeleteDependencyWithPatch.

@Test
@InSequence(100)
public void shouldDeleteDependencyWithPatch() throws Exception {
    // given
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration gc = null;
    for (BuildConfiguration bc1 : bcClient.getAll()) {
        if (!bc1.getDependencies().isEmpty()) {
            gc = bc1;
            break;
        }
    }
    assertThat(gc).isNotNull();
    BuildConfiguration toRemove = bcClient.getSpecific(gc.getDependencies().keySet().iterator().next());
    BuildConfigurationPatchBuilder builder = new BuildConfigurationPatchBuilder();
    builder.removeDependencies(Collections.singletonList(toRemove.getId()));
    // when
    bcClient.patch(gc.getId(), builder);
    // then
    BuildConfiguration refresh = bcClient.getSpecific(gc.getId());
    assertThat(refresh.getDependencies().keySet()).doesNotContain(toRemove.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationPatchBuilder(org.jboss.pnc.client.patch.BuildConfigurationPatchBuilder) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 34 with BuildConfigurationClient

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

the class BuildConfigurationEndpointTest method testGetAllWithLatest.

@Test
@InSequence(10)
public void testGetAllWithLatest() throws RemoteResourceException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfigurationWithLatestBuild> bcsWithLatest = client.getAllWithLatestBuild();
    BuildsFilterParameters filter = new BuildsFilterParameters();
    filter.setLatest(true);
    // from DatabaseDataInitializer
    assertThat(bcsWithLatest).hasSize(5);
    for (BuildConfigurationWithLatestBuild bc : bcsWithLatest.getAll()) {
        List<Build> associatedBuilds = new ArrayList<>(client.getBuilds(bc.getId(), filter).getAll());
        if (bc.getLatestBuild() != null) {
            assertThat(associatedBuilds).isNotEmpty();
            assertThat(bc.getLatestBuild().getId()).isEqualTo(associatedBuilds.get(0).getId());
        }
    }
}
Also used : Build(org.jboss.pnc.dto.Build) BuildConfigurationWithLatestBuild(org.jboss.pnc.dto.BuildConfigurationWithLatestBuild) ArrayList(java.util.ArrayList) BuildConfigurationWithLatestBuild(org.jboss.pnc.dto.BuildConfigurationWithLatestBuild) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 35 with BuildConfigurationClient

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

the class BuildConfigurationEndpointTest method testGetDependants.

@Test
@InSequence(30)
public void testGetDependants() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    List<String> allDependantIds = client.getDependants(configuration2Id).getAll().stream().map(BuildConfiguration::getId).collect(Collectors.toList());
    assertThat(allDependantIds).containsOnly(configuration3Id);
}
Also used : BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) 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