use of org.candlepin.model.Content in project candlepin by candlepin.
the class ContentManagerTest method testUpdateContentConvergeWithExisting.
@Test
@Parameters({ "false", "true" })
public void testUpdateContentConvergeWithExisting(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 content1 = this.createContent("c1", "content-1", owner1);
Content content2 = this.createContent("c1", "updated content", owner2);
ContentDTO update = TestUtil.createContentDTO("c1", "updated content");
product.addContent(content1, true);
product = this.productCurator.merge(product);
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content1, owner1));
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content2, owner1));
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content1, owner2));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content2, owner2));
Content output = this.contentManager.updateContent(update, owner1, regenCerts);
assertEquals(content2.getUuid(), output.getUuid());
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content1, owner1));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content2, owner1));
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content1, owner2));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content2, 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.model.Content in project candlepin by candlepin.
the class ContentManagerTest method testRemoveContent.
@Test
@Parameters({ "false", "true" })
public void testRemoveContent(boolean regenCerts) {
Owner owner = this.createOwner("test-owner-1", "Test Owner 1");
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);
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner));
try {
this.beginTransaction();
this.contentManager.removeContent(owner, content, regenCerts);
this.commitTransaction();
} catch (RuntimeException e) {
this.rollbackTransaction();
}
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content, owner));
assertNotNull(this.contentCurator.find(content.getUuid()));
assertEquals(0, this.ownerContentCurator.getOwnerCount(content));
if (regenCerts) {
verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner)), anyCollectionOf(Product.class), anyBoolean());
} else {
verifyZeroInteractions(this.mockEntCertGenerator);
}
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ContentManagerTest method testUpdateContentThatDoesntExist.
@Test(expected = IllegalStateException.class)
public void testUpdateContentThatDoesntExist() {
Owner owner = this.createOwner("test-owner", "Test Owner");
Content content = TestUtil.createContent("c1", "content-1");
ContentDTO update = TestUtil.createContentDTO("c1", "new_name");
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content, owner));
this.contentManager.updateContent(update, owner, false);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ContentManagerTest method testRemoveContentDivergeFromExisting.
@Test
@Parameters({ "false", "true" })
public void testRemoveContentDivergeFromExisting(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, owner2);
Content content = this.createContent("c1", "content-1", owner1, owner2);
product.addContent(content, true);
product = this.productCurator.merge(product);
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner1));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner2));
try {
this.beginTransaction();
this.contentManager.removeContent(owner1, content, regenCerts);
this.commitTransaction();
} catch (RuntimeException e) {
this.rollbackTransaction();
}
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content, owner1));
assertTrue(this.ownerContentCurator.isContentMappedToOwner(content, owner2));
assertNotNull(this.contentCurator.find(content.getUuid()));
if (regenCerts) {
verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner1)), anyCollectionOf(Product.class), anyBoolean());
} else {
verifyZeroInteractions(this.mockEntCertGenerator);
}
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class EntitlerTest method mockContentImport.
private void mockContentImport(Owner owner, Content... contents) {
Map<String, Content> contentMap = new HashMap<>();
for (Content content : contents) {
contentMap.put(content.getId(), content);
}
this.mockContentImport(owner, contentMap);
}
Aggregations