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());
}
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);
}
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));
}
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");
}
}
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+");
}
}
Aggregations