use of org.jboss.pnc.client.ProductMilestoneClient in project pnc by project-ncl.
the class AdvancedProductMilestoneClient method fallbackSupplier.
/**
* Used to retrieve latest close result through REST when WS Client loses connection and reconnects
*
* @param milestoneId Id of the ProductMilestone which was closed
* @return
* @throws RemoteResourceException
*/
private ProductMilestoneCloseResult fallbackSupplier(String milestoneId) throws RemoteResourceException {
ProductMilestoneCloseParameters parameters = new ProductMilestoneCloseParameters();
parameters.setLatest(true);
ProductMilestoneCloseResult result = null;
try (ProductMilestoneClient client = new ProductMilestoneClient(configuration)) {
result = client.getCloseResults(milestoneId, parameters).iterator().next();
}
return result;
}
use of org.jboss.pnc.client.ProductMilestoneClient in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method shouldFailToCreateMilestoneWithMalformedVersion.
@Test
public void shouldFailToCreateMilestoneWithMalformedVersion() throws IOException {
// given
ProductMilestone productMilestone = ProductMilestone.builder().productVersion(productVersion).version("1.0-ER1").build();
// when then
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
assertThatThrownBy(() -> client.createNew(productMilestone)).isInstanceOf(ClientException.class);
}
use of org.jboss.pnc.client.ProductMilestoneClient in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method shouldGetMilestoneRelease.
@Test
public void shouldGetMilestoneRelease() throws IOException, RemoteResourceException {
// given
ProductClient productClient = new ProductClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Product> products = productClient.getAll(Optional.empty(), Optional.of("name==\"" + PNC_PRODUCT_NAME + "\""));
Product product = products.iterator().next();
Map<String, ProductVersionRef> productVersions = product.getProductVersions();
Optional<ProductVersionRef> productVersion = productVersions.values().stream().filter(pv -> pv.getVersion().equals(DatabaseDataInitializer.PNC_PRODUCT_VERSION_1)).findAny();
ProductVersionClient productVersionClient = new ProductVersionClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ProductMilestone> milestones = productVersionClient.getMilestones(productVersion.get().getId(), Optional.empty(), Optional.of("version==\"" + PNC_PRODUCT_MILESTONE3 + "\""));
ProductMilestone milestone = milestones.iterator().next();
ProductMilestoneClient milestoneClient = new ProductMilestoneClient(RestClientConfiguration.asAnonymous());
// when
RemoteCollection<ProductMilestoneCloseResult> milestoneReleases = milestoneClient.getCloseResults(milestone.getId(), null);
// then
Assert.assertEquals(3, milestoneReleases.size());
// make sure the result is ordered by date
Instant previous = Instant.EPOCH;
for (Iterator<ProductMilestoneCloseResult> iter = milestoneReleases.iterator(); iter.hasNext(); ) {
ProductMilestoneCloseResult next = iter.next();
logger.debug("MilestoneRelease id: {}, StartingDate: {}.", next.getId(), next.getStartingDate());
Assert.assertTrue("Wong milestone releases order.", next.getStartingDate().isAfter(previous));
previous = next.getStartingDate();
}
// when
ProductMilestoneCloseParameters filter = new ProductMilestoneCloseParameters();
filter.setLatest(true);
RemoteCollection<ProductMilestoneCloseResult> latestMilestoneRelease = milestoneClient.getCloseResults(milestone.getId(), filter);
// then
Assert.assertEquals(1, latestMilestoneRelease.getAll().size());
// the latest one in demo data has status SUCCEEDED
Assert.assertEquals(MilestoneCloseStatus.SUCCEEDED, latestMilestoneRelease.iterator().next().getStatus());
}
use of org.jboss.pnc.client.ProductMilestoneClient in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method testGetDeliveredArtifacts.
@Test
public void testGetDeliveredArtifacts() throws ClientException {
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Artifact> all = client.getDeliveredArtifacts(milestoneId);
assertThat(all).hasSize(3);
}
use of org.jboss.pnc.client.ProductMilestoneClient in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method testGetBuilds.
@Test
public void testGetBuilds() throws ClientException {
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Build> all = client.getBuilds(milestoneId, null);
assertThat(all).hasSize(1);
}
Aggregations