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());
});
}
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();
}
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();
}
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);
}
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;
}
Aggregations