use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method testValidateWithExistingVersion.
@Test
public void testValidateWithExistingVersion() throws RemoteResourceException {
// with
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
ProductVersionClient productVersionClient = new ProductVersionClient(RestClientConfiguration.asUser());
final ProductMilestone milestone = productVersionClient.getMilestones("100").iterator().next();
// when
final ValidationResponse response = client.validateVersion(VersionValidationRequest.builder().productVersionId("100").version(milestone.getVersion()).build());
// then
assertThat(response.getIsValid()).isFalse();
assertThat(response.getErrorType()).isEqualTo(ValidationErrorType.DUPLICATION);
assertThat(response.getHints()).isNotEmpty();
}
use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method testCreateNew.
@Test
public void testCreateNew() throws ClientException {
// given
ProductMilestone productMilestone = ProductMilestone.builder().productVersion(productVersion).version("1.0.0.ER1").startingDate(Instant.ofEpochMilli(100_000)).plannedEndDate(Instant.ofEpochMilli(200_000)).build();
// when
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
ProductMilestone created = client.createNew(productMilestone);
assertThat(created.getId()).isNotEmpty();
ProductMilestone retrieved = client.getSpecific(created.getId());
// then
assertThat(created.getProductVersion().getId()).isEqualTo(productMilestone.getProductVersion().getId());
assertThat(retrieved.getProductVersion().getId()).isEqualTo(productMilestone.getProductVersion().getId());
assertThat(created).isEqualToIgnoringGivenFields(productMilestone, "id", "productVersion");
assertThat(retrieved).isEqualToIgnoringGivenFields(productMilestone, "id", "productVersion");
assertThat(retrieved).isEqualTo(created);
}
use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method shouldFailToCreateClosedMilestone.
@Test
public void shouldFailToCreateClosedMilestone() throws IOException {
// given
ProductMilestone closedMilestone = ProductMilestone.builder().productVersion(productVersion).version("1.0.0.ER2").startingDate(Instant.ofEpochMilli(100_000)).plannedEndDate(Instant.ofEpochMilli(200_000)).endDate(Instant.ofEpochMilli(300_000)).build();
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
// when then
assertThatThrownBy(() -> client.createNew(closedMilestone)).isInstanceOf(ClientException.class);
}
use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method testShouldFailToCloseWithNoBuilds.
@Test
public void testShouldFailToCloseWithNoBuilds() throws ClientException {
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asUser());
ProductMilestone newMilestone = ProductMilestone.builder().productVersion(productVersion).version("9.9.9.ER9").startingDate(Instant.ofEpochMilli(100_000)).plannedEndDate(Instant.ofEpochMilli(200_000)).build();
ProductMilestone created = client.createNew(newMilestone);
assertThat(created.getId()).isNotEmpty();
ProductMilestone retrieved = client.getSpecific(created.getId());
assertThatThrownBy(() -> client.closeMilestone(retrieved.getId())).hasCauseInstanceOf(BadRequestException.class);
}
use of org.jboss.pnc.dto.ProductMilestone in project pnc by project-ncl.
the class ProductMilestoneEndpointTest method prepareData.
@BeforeClass
public static void prepareData() throws Exception {
ProductClient productClient = new ProductClient(RestClientConfiguration.asAnonymous());
product = productClient.getAll().iterator().next();
productVersion = productClient.getProductVersions(product.getId()).iterator().next();
ProductVersionClient productVersionClient = new ProductVersionClient(RestClientConfiguration.asAnonymous());
Iterator<ProductMilestone> it = productVersionClient.getMilestones(productVersion.getId()).iterator();
milestone = it.next();
milestoneId = milestone.getId();
milestone2 = it.next();
}
Aggregations