use of org.jboss.pnc.client.ProductClient 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.ProductClient in project pnc by project-ncl.
the class ProductEndpointTest method shouldFailToSaveProductWithSpaceInAbbreviation.
@Test
public void shouldFailToSaveProductWithSpaceInAbbreviation() {
ProductClient client = new ProductClient(RestClientConfiguration.asUser());
Product product = Product.builder().name("New Ab re via ted product").abbreviation("abb re viation").description("The newst product of them all. Now with spaces.").build();
try {
client.createNew(product);
fail("Exception should be thrown");
} catch (ClientException ex) {
// OK
}
}
use of org.jboss.pnc.client.ProductClient in project pnc by project-ncl.
the class ProductEndpointTest method before.
@Before
public void before() throws RemoteResourceException {
ProductClient client = new ProductClient(RestClientConfiguration.asAnonymous());
System.out.println("All things: ");
for (Product product : client.getAll()) {
System.out.println(" " + product);
}
System.out.println(".");
}
use of org.jboss.pnc.client.ProductClient in project pnc by project-ncl.
the class ProductEndpointTest method testGetAll.
@Test
@InSequence(10)
public void testGetAll() throws RemoteResourceException {
ProductClient client = new ProductClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Product> all = client.getAll();
// from DatabaseDataInitializer
assertThat(all).hasSize(1);
}
use of org.jboss.pnc.client.ProductClient in project pnc by project-ncl.
the class ProductEndpointTest method testGetSpecific.
@Test
public void testGetSpecific() throws ClientException {
ProductClient client = new ProductClient(RestClientConfiguration.asAnonymous());
Product dto = client.getSpecific(productId);
// from DatabaseDataInitializer
assertThat(dto.getName()).isEqualTo("Project Newcastle Demo Product");
// from
assertThat(dto.getDescription()).isEqualTo("Example Product for Project Newcastle Demo");
// DatabaseDataInitializer
}
Aggregations