use of org.candlepin.dto.manifest.v1.ContentDTO in project candlepin by candlepin.
the class ContentManagerTest method testCreateContentMergeWithExisting.
@Test
public void testCreateContentMergeWithExisting() {
Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
Content content1 = TestUtil.createContent("c1", "content-1");
Content content2 = this.createContent("c1", "content-1", owner2);
ContentDTO cdto = this.modelTranslator.translate(content1, ContentDTO.class);
Content output = this.contentManager.createContent(cdto, owner1);
assertEquals(content2.getUuid(), output.getUuid());
assertEquals(content2, output);
assertTrue(this.ownerContentCurator.isContentMappedToOwner(output, owner1));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(output, owner2));
}
use of org.candlepin.dto.manifest.v1.ContentDTO in project candlepin by candlepin.
the class ContentManagerTest method testUpdateContentDivergeFromExisting.
@Test
@Parameters({ "false", "true" })
public void testUpdateContentDivergeFromExisting(boolean regenCerts) {
Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
Product product = this.createProduct("p1", "product-1", owner1);
Content content = this.createContent("c1", "content-1", owner1, owner2);
ContentDTO update = TestUtil.createContentDTO("c1", "updated content");
product.addContent(content, true);
product = this.productCurator.merge(product);
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner1));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner2));
Content output = this.contentManager.updateContent(update, owner1, regenCerts);
assertNotEquals(output.getUuid(), content.getUuid());
assertTrue(this.ownerContentCurator.isContentMappedToOwner(output, owner1));
assertFalse(this.ownerContentCurator.isContentMappedToOwner(output, owner2));
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content, owner1));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner2));
if (regenCerts) {
verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner1)), anyCollectionOf(Product.class), anyBoolean());
} else {
verifyZeroInteractions(this.mockEntCertGenerator);
}
}
use of org.candlepin.dto.manifest.v1.ContentDTO in project candlepin by candlepin.
the class ContentManagerTest method testCreateContent.
@Test
public void testCreateContent() {
Owner owner = this.createOwner("test-owner", "Test Owner");
ContentDTO dto = TestUtil.createContentDTO("c1", "content-1");
dto.setLabel("test-label");
dto.setType("test-test");
dto.setVendor("test-vendor");
assertNull(this.ownerContentCurator.getContentById(owner, dto.getId()));
Content output = this.contentManager.createContent(dto, owner);
assertEquals(output, this.ownerContentCurator.getContentById(owner, dto.getId()));
}
use of org.candlepin.dto.manifest.v1.ContentDTO in project candlepin by candlepin.
the class ContentManagerTest method testUpdateContentNoChange.
@Test
public void testUpdateContentNoChange() {
Owner owner = this.createOwner("test-owner", "Test Owner");
Product product = this.createProduct("p1", "product-1", owner);
Content content = this.createContent("c1", "content-1", owner);
product.addContent(content, true);
product = this.productCurator.merge(product);
ContentDTO cdto = this.modelTranslator.translate(content, ContentDTO.class);
Content output = this.contentManager.updateContent(cdto, owner, true);
assertEquals(output.getUuid(), content.getUuid());
assertEquals(output, content);
verifyZeroInteractions(this.mockEntCertGenerator);
}
use of org.candlepin.dto.manifest.v1.ContentDTO in project candlepin by candlepin.
the class ProductImporter method createObject.
public ProductDTO createObject(ObjectMapper mapper, Reader reader, Owner owner) throws IOException {
ProductDTO importedProduct = mapper.readValue(reader, ProductDTO.class);
// Make sure the (UU)ID's are null, otherwise Hibernate thinks these are
// detached entities.
importedProduct.setUuid(null);
// Multiplication has already happened on the upstream candlepin. set this to 1
// so we can use multipliers on local products if necessary.
importedProduct.setMultiplier(1L);
if (importedProduct.getProductContent() != null) {
// Update attached content and ensure it isn't malformed
for (ProductDTO.ProductContentDTO pc : importedProduct.getProductContent()) {
ContentDTO content = pc.getContent();
// Clear the UUID
content.setUuid(null);
// Fix the vendor string if it is/was cleared (BZ 990113)
if (StringUtils.isBlank(content.getVendor())) {
content.setVendor("unknown");
}
// On standalone servers we will set metadata expire to 1 second so
// clients an immediately get changes to content when published on the
// server. We would use 0, but the client plugin interprets this as unset
// and ignores it completely resulting in the default yum values being
// used.
//
// We know this is a standalone server due to the fact that import is
// being used, so there is no need to guard this behavior.
content.setMetadataExpire(1L);
}
}
return importedProduct;
}
Aggregations