Search in sources :

Example 6 with ProductVersionClient

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

the class ProductVersionEndpointTest method testGetBuildConfigurations.

@Test
public void testGetBuildConfigurations() throws ClientException {
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfiguration> all = client.getBuildConfigs(productVersionsId);
    assertThat(all).hasSize(2).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 7 with ProductVersionClient

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

the class ProductVersionEndpointTest method testGetSpecific.

@Test
public void testGetSpecific() throws ClientException {
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    ProductVersion dto = client.getSpecific(productVersionsId);
    // from DatabaseDataInitializer
    assertThat(dto.getVersion()).isEqualTo("1.0");
    // from DatabaseDataInitializer
    assertThat(dto.getProduct().getId()).isEqualTo(product.getId());
}
Also used : ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 8 with ProductVersionClient

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

the class ProductVersionEndpointTest method testGetMilestones.

@Test
public void testGetMilestones() throws ClientException {
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<ProductMilestone> all = client.getMilestones(productVersionsId);
    assertThat(all).hasSize(4).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
Also used : ProductMilestone(org.jboss.pnc.dto.ProductMilestone) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 9 with ProductVersionClient

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

the class ProductVersionEndpointTest method shouldUpdateGroupConfigsUsingPatch.

@Test
public void shouldUpdateGroupConfigsUsingPatch() throws PatchBuilderException, RemoteResourceException {
    // given
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    GroupConfiguration gc = GroupConfiguration.builder().name("GC patch test").build();
    GroupConfigurationClient gcc = new GroupConfigurationClient(RestClientConfiguration.asUser());
    GroupConfiguration gcToAdd = gcc.createNew(gc);
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    Map<String, GroupConfigurationRef> groupConfigs = productVersion.getGroupConfigs();
    // when
    ProductVersionPatchBuilder patchBuilder = new ProductVersionPatchBuilder();
    ProductVersionPatchBuilder patch = patchBuilder.addGroupConfigs(Collections.singletonMap(gcToAdd.getId(), gcToAdd));
    client.patch(productVersionsId2, patch);
    // then
    groupConfigs.put(gcToAdd.getId(), gcToAdd);
    ProductVersion productVersionUpdated = client.getSpecific(productVersionsId2);
    assertThat(productVersionUpdated.getGroupConfigs()).containsKeys(groupConfigs.keySet().toArray(new String[groupConfigs.keySet().size()]));
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ProductVersion(org.jboss.pnc.dto.ProductVersion) 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 10 with ProductVersionClient

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

the class ProductVersionEndpointTest method shouldNotUpdateCurrentToClosedMilestone.

@Test
public void shouldNotUpdateCurrentToClosedMilestone() throws ClientException {
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId);
    Map<String, ProductMilestoneRef> milestones = productVersion.getProductMilestones();
    ProductMilestoneRef closedMilestoneRef = null;
    for (ProductMilestoneRef milestone : milestones.values()) {
        if (milestone.getVersion().equals("1.0.0.Build4")) {
            closedMilestoneRef = milestone;
            break;
        }
    }
    assertThat(closedMilestoneRef.getEndDate()).isNotNull();
    ProductVersion updatedWithClosedMilestone = productVersion.toBuilder().currentProductMilestone(closedMilestoneRef).build();
    assertThatThrownBy(() -> client.update(productVersionsId, updatedWithClosedMilestone)).isInstanceOf(ClientException.class);
}
Also used : ProductMilestoneRef(org.jboss.pnc.dto.ProductMilestoneRef) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)25 ContainerTest (org.jboss.pnc.test.category.ContainerTest)20 Test (org.junit.Test)20 ProductVersion (org.jboss.pnc.dto.ProductVersion)17 GroupConfigurationRef (org.jboss.pnc.dto.GroupConfigurationRef)6 HashMap (java.util.HashMap)5 ProductClient (org.jboss.pnc.client.ProductClient)4 ProductVersionPatchBuilder (org.jboss.pnc.client.patch.ProductVersionPatchBuilder)4 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)4 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)4 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)3 ProductMilestoneClient (org.jboss.pnc.client.ProductMilestoneClient)2 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)2 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)2 Product (org.jboss.pnc.dto.Product)2 ValidationResponse (org.jboss.pnc.dto.response.ValidationResponse)2 BeforeClass (org.junit.BeforeClass)2 IOException (java.io.IOException)1 Instant (java.time.Instant)1 Iterator (java.util.Iterator)1