use of org.jboss.pnc.dto.ProductMilestoneRef in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldNotUpdateCurrentToClosedMilestone.
@Test
public void shouldNotUpdateCurrentToClosedMilestone() throws ClientException {
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
ProductVersion productVersion = client.getSpecific(productVersionsId);
Map<String, ProductMilestoneRef> milestones = productVersion.getProductMilestones();
ProductMilestoneRef closedMilestoneRef = null;
for (ProductMilestoneRef milestone : milestones.values()) {
if (milestone.getVersion().equals("1.0.0.Build4")) {
closedMilestoneRef = milestone;
break;
}
}
assertThat(closedMilestoneRef.getEndDate()).isNotNull();
ProductVersion updatedWithClosedMilestone = productVersion.toBuilder().currentProductMilestone(closedMilestoneRef).build();
assertThatThrownBy(() -> client.update(productVersionsId, updatedWithClosedMilestone)).isInstanceOf(ClientException.class);
}
use of org.jboss.pnc.dto.ProductMilestoneRef in project pnc by project-ncl.
the class ProductReleaseProviderTest method createNewProductReleaseDTO.
private org.jboss.pnc.dto.ProductRelease createNewProductReleaseDTO(String version, Integer id) {
// when
ProductMilestone milestone = prepareNewProductMilestone();
when(productRepository.queryById(milestone.getProductVersion().getProduct().getId())).thenReturn(milestone.getProductVersion().getProduct());
when(productVersionRepository.queryById(milestone.getProductVersion().getId())).thenReturn(milestone.getProductVersion());
when(productMilestoneRepository.queryById(milestone.getId())).thenReturn(milestone);
ProductMilestoneRef ref = productMilestoneMapper.toRef(milestone);
ProductVersionRef productVersionRef = productVersionMapper.toRef(milestone.getProductVersion());
org.jboss.pnc.dto.ProductRelease.Builder releaseDTO = org.jboss.pnc.dto.ProductRelease.builder().version(version).productVersion(productVersionRef).productMilestone(ref);
if (id != null) {
return releaseDTO.id(id.toString()).build();
} else {
return releaseDTO.build();
}
}
use of org.jboss.pnc.dto.ProductMilestoneRef in project pnc by project-ncl.
the class ProductVersionProviderTest method testShouldThrowWhenCurrentMilestoneIsClosed.
@Test
public void testShouldThrowWhenCurrentMilestoneIsClosed() {
String newVersion = "19.0";
org.jboss.pnc.dto.ProductVersion withClosedMilestone = provider.getSpecific("2");
ProductMilestoneRef closedMilestone = withClosedMilestone.getProductMilestones().values().iterator().next();
org.jboss.pnc.dto.ProductVersion updated = withClosedMilestone.toBuilder().currentProductMilestone(closedMilestone).build();
ProductMilestone closedReturn = new ProductMilestone();
closedReturn.setId(Integer.parseInt(closedMilestone.getId()));
closedReturn.setEndDate(new Date());
when(milestoneRepository.queryById(anyInt())).thenReturn(closedReturn);
assertThatThrownBy(() -> provider.update(withClosedMilestone.getId(), updated)).isInstanceOf(InvalidEntityException.class);
}
Aggregations