Search in sources :

Example 1 with Product

use of org.jboss.pnc.model.Product in project pnc by project-ncl.

the class ProductVersionProviderImpl method validateBeforeSaving.

@Override
protected void validateBeforeSaving(ProductVersion restEntity) {
    super.validateBeforeSaving(restEntity);
    Product product = productRepository.queryById(Integer.valueOf(restEntity.getProduct().getId()));
    if (product == null) {
        throw new InvalidEntityException("Product with id: " + restEntity.getProduct().getId() + " does not exist.");
    }
    Set<org.jboss.pnc.model.ProductVersion> productVersionList = product.getProductVersions();
    if (productVersionList == null) {
        return;
    }
    productVersionList.stream().filter(pv -> pv.getVersion().equals(restEntity.getVersion())).findFirst().ifPresent(pv -> {
        throw new ConflictedEntryException("Product version with version " + restEntity.getVersion() + " already exists", org.jboss.pnc.model.ProductVersion.class, pv.getId().toString());
    });
}
Also used : Product(org.jboss.pnc.model.Product) ProductVersion(org.jboss.pnc.dto.ProductVersion) ConflictedEntryException(org.jboss.pnc.facade.validation.ConflictedEntryException) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Example 2 with Product

use of org.jboss.pnc.model.Product in project pnc by project-ncl.

the class ProductReleaseProviderTest method prepareNewProductMilestone.

private ProductMilestone prepareNewProductMilestone() {
    Product product = Product.Builder.newBuilder().id(entityId.getAndIncrement()).name(Sequence.nextId().toString()).build();
    ProductVersion productVersion = ProductVersion.Builder.newBuilder().id(entityId.getAndIncrement()).version("1.2").product(product).build();
    return ProductMilestone.Builder.newBuilder().id(entityId.getAndIncrement()).productVersion(productVersion).version("1.2.3.CR1").build();
}
Also used : Product(org.jboss.pnc.model.Product) ProductVersion(org.jboss.pnc.model.ProductVersion)

Example 3 with Product

use of org.jboss.pnc.model.Product in project pnc by project-ncl.

the class ProductVersionProviderTest method testStore.

@Test
public void testStore() {
    final Integer prodId = 12;
    final String version = "17.0";
    final String abbreviation = "PNC";
    final ProductRef product = ProductRef.refBuilder().id(prodId.toString()).abbreviation(abbreviation).build();
    final Product productDB = prepareProduct(prodId, abbreviation);
    when(productRepository.queryById(prodId)).thenReturn(productDB);
    when(systemConfig.getBrewTagPattern()).thenReturn("${product_short_name}-${product_version}-HI");
    org.jboss.pnc.dto.ProductVersion productVersion = org.jboss.pnc.dto.ProductVersion.builder().productMilestones(Collections.emptyMap()).product(product).version(version).build();
    org.jboss.pnc.dto.ProductVersion stored = provider.store(productVersion);
    assertThat(stored).isNotNull();
    assertThat(stored.getId()).isNotNull();
    assertThat(stored.getVersion()).isEqualTo(version);
    assertThat(stored.getProduct().getId()).isEqualTo(prodId.toString());
    assertThat(stored.getAttributes()).isNotNull();
    assertThat(stored.getAttributes().get(Attributes.BREW_TAG_PREFIX)).isNotNull();
}
Also used : Product(org.jboss.pnc.model.Product) ProductRef(org.jboss.pnc.dto.ProductRef) Test(org.junit.Test)

Example 4 with Product

use of org.jboss.pnc.model.Product in project pnc by project-ncl.

the class ProductMilestoneFactory method prepareNewProductMilestone.

public ProductMilestone prepareNewProductMilestone(String productVersion, String milestoneVersion) {
    Product product = Product.Builder.newBuilder().id(getNextId()).name(Sequence.nextId().toString()).build();
    ProductVersion pV = ProductVersion.Builder.newBuilder().id(getNextId()).version(productVersion).product(product).build();
    return createNewProductMilestoneFromProductVersion(pV, milestoneVersion);
}
Also used : Product(org.jboss.pnc.model.Product) ProductVersion(org.jboss.pnc.model.ProductVersion)

Example 5 with Product

use of org.jboss.pnc.model.Product in project pnc by project-ncl.

the class ProductMilestoneReleaseRepositoryImplTest method createProduct.

private Product createProduct() {
    Product product = new Product();
    product.setName(RandomStringUtils.randomAlphabetic(10));
    product.setAbbreviation(RandomStringUtils.randomAlphabetic(3));
    productRepository.save(product);
    return product;
}
Also used : Product(org.jboss.pnc.model.Product)

Aggregations

Product (org.jboss.pnc.model.Product)11 ProductVersion (org.jboss.pnc.model.ProductVersion)6 Test (org.junit.Test)4 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)2 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)2 ContainerTest (org.jboss.pnc.test.category.ContainerTest)2 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 Transactional (org.jboss.arquillian.transaction.api.annotation.Transactional)1 ProductRef (org.jboss.pnc.dto.ProductRef)1 ProductVersion (org.jboss.pnc.dto.ProductVersion)1 ConflictedEntryException (org.jboss.pnc.facade.validation.ConflictedEntryException)1 InvalidEntityException (org.jboss.pnc.facade.validation.InvalidEntityException)1 BuildEnvironment (org.jboss.pnc.model.BuildEnvironment)1 ProductMilestone (org.jboss.pnc.model.ProductMilestone)1 ProductMilestoneRelease (org.jboss.pnc.model.ProductMilestoneRelease)1 ProductRelease (org.jboss.pnc.model.ProductRelease)1 Project (org.jboss.pnc.model.Project)1