Search in sources :

Example 11 with ProductVersionClient

use of org.jboss.pnc.client.ProductVersionClient 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 12 with ProductVersionClient

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

the class ProductVersionEndpointTest method testUpdate.

@Test
public void testUpdate() throws ClientException {
    // given
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    final String version = "2.1";
    ProductVersion dto = client.getSpecific(productVersionsId2);
    ProductVersion toUpdate = dto.toBuilder().version(version).build();
    // when
    client.update(productVersionsId2, toUpdate);
    // then
    ProductVersion retrieved = client.getSpecific(dto.getId());
    assertThat(retrieved).isEqualTo(toUpdate);
    assertThat(retrieved).isEqualToIgnoringGivenFields(dto, "version");
    assertThat(retrieved.getVersion()).isEqualTo(version);
}
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 13 with ProductVersionClient

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

the class ProductVersionEndpointTest method testGetGroupConfigurations.

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

Example 14 with ProductVersionClient

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

the class PigFacade method getBrewTag.

private static String getBrewTag(ProductVersionRef versionRef) {
    try (ProductVersionClient productVersionClient = new ProductVersionClient(PncClientHelper.getPncConfiguration())) {
        String versionId = versionRef.getId();
        ProductVersion version;
        try {
            version = productVersionClient.getSpecific(versionId);
        } catch (RemoteResourceException e) {
            throw new RuntimeException("Unable to get product version for " + versionId, e);
        }
        return version.getAttributes().get("BREW_TAG_PREFIX");
    }
}
Also used : RemoteResourceException(org.jboss.pnc.client.RemoteResourceException) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient)

Example 15 with ProductVersionClient

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

the class ProductMilestoneCli method validateProductMilestoneVersion.

/**
 * Product Milestone version format is: <d>.<d>.<d>.<word> The first 2 digits must match the digit for the product
 * version
 *
 * @param productVersionId
 * @param milestoneVersion
 * @return
 */
public static boolean validateProductMilestoneVersion(String productVersionId, String milestoneVersion) throws ClientException {
    try (ProductVersionClient client = VERSION_CREATOR.newClient()) {
        ProductVersion productVersionDTO = client.getSpecific(productVersionId);
        String productVersion = productVersionDTO.getVersion();
        if (!milestoneVersion.startsWith(productVersion)) {
            return false;
        }
        String[] items = milestoneVersion.split("\\.");
        if (items.length != 4) {
            return false;
        }
        return items[2].matches("\\d+");
    }
}
Also used : ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient)

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