Search in sources :

Example 1 with ProductMilestoneRef

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);
}
Also used : ProductMilestoneRef(org.jboss.pnc.dto.ProductMilestoneRef) ProductVersion(org.jboss.pnc.dto.ProductVersion) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 2 with ProductMilestoneRef

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();
    }
}
Also used : ProductMilestone(org.jboss.pnc.model.ProductMilestone) ProductRelease(org.jboss.pnc.model.ProductRelease) ProductMilestoneRef(org.jboss.pnc.dto.ProductMilestoneRef) ProductVersionRef(org.jboss.pnc.dto.ProductVersionRef)

Example 3 with ProductMilestoneRef

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);
}
Also used : ProductMilestone(org.jboss.pnc.model.ProductMilestone) ProductMilestoneRef(org.jboss.pnc.dto.ProductMilestoneRef) Test(org.junit.Test)

Aggregations

ProductMilestoneRef (org.jboss.pnc.dto.ProductMilestoneRef)3 ProductMilestone (org.jboss.pnc.model.ProductMilestone)2 Test (org.junit.Test)2 ProductVersionClient (org.jboss.pnc.client.ProductVersionClient)1 ProductVersion (org.jboss.pnc.dto.ProductVersion)1 ProductVersionRef (org.jboss.pnc.dto.ProductVersionRef)1 ProductRelease (org.jboss.pnc.model.ProductRelease)1 ContainerTest (org.jboss.pnc.test.category.ContainerTest)1