use of org.candlepin.model.Content in project candlepin by candlepin.
the class ProductManagerTest method testUpdateProductContentOnSharedProduct.
// Move this to ContentManagerTest
@Test
public void testUpdateProductContentOnSharedProduct() {
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", "prod1", owner1);
Content content = this.createContent("c1", "content1", owner1);
this.ownerProductCurator.mapProductToOwners(product, owner1, owner2);
product.setProductContent(Arrays.asList(new ProductContent(product, content, true)));
this.productCurator.merge(product);
ProductDTO pdto = this.modelTranslator.translate(product, ProductDTO.class);
pdto.getProductContent(content.getId()).setEnabled(false);
Product output = this.productManager.updateProduct(pdto, owner1, false);
assertNotEquals(product, output);
assertTrue(product.hasContent(content.getId()));
assertTrue(output.hasContent(content.getId()));
assertTrue(product.getProductContent().iterator().next().isEnabled());
assertFalse(output.getProductContent().iterator().next().isEnabled());
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product, owner1));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner2));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(output, owner1));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(output, owner2));
verifyZeroInteractions(this.mockEntCertGenerator);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ContentTranslatorTest method initSourceObject.
@Override
protected Content initSourceObject() {
Content source = new Content();
source.setUuid("test_value");
source.setId("test_value");
source.setType("test_value");
source.setLabel("test_value");
source.setName("test_value");
source.setVendor("test_value");
source.setContentUrl("test_value");
source.setRequiredTags("test_value");
source.setReleaseVersion("test_value");
source.setGpgUrl("test_value");
source.setMetadataExpire(1234L);
source.setModifiedProductIds(Arrays.asList("1", "2", "3"));
source.setArches("test_value");
source.setLocked(Boolean.TRUE);
return source;
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class EnvironmentTranslatorTest method initSourceObject.
@Override
protected Environment initSourceObject() {
Environment source = new Environment();
source.setId("test_id");
source.setName("test_name");
source.setDescription("test_description");
source.setOwner(ownerTranslatorTest.initSourceObject());
Set<EnvironmentContent> environmentContents = new HashSet<>();
for (int i = 0; i < 3; ++i) {
Content content = TestUtil.createContent("content-" + i);
content.setUuid(content.getId() + "_uuid");
EnvironmentContent environmentContent = new EnvironmentContent(source, content, true);
environmentContents.add(environmentContent);
}
source.setEnvironmentContent(environmentContents);
return source;
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ContentManagerTest method testRemoveContentThatDoesntExist.
@Test(expected = IllegalStateException.class)
public void testRemoveContentThatDoesntExist() {
Owner owner = this.createOwner("test-owner", "Test Owner");
Content content = TestUtil.createContent("c1", "content-1");
assertFalse(this.ownerContentCurator.isContentMappedToOwner(content, owner));
this.contentManager.removeContent(owner, content, true);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ContentManagerTest method testUpdateContent.
@Test
@Parameters({ "false", "true" })
public void testUpdateContent(boolean regenCerts) {
Owner owner = this.createOwner("test-owner", "Test Owner");
Product product = this.createProduct("p1", "product-1", owner);
Content content = this.createContent("c1", "content-1", owner);
ContentDTO update = TestUtil.createContentDTO("c1", "new content name");
product.addContent(content, true);
product = this.productCurator.merge(product);
Content output = this.contentManager.updateContent(update, owner, regenCerts);
assertNotEquals(output.getUuid(), content.getUuid());
assertEquals(output.getName(), update.getName());
// We expect the original to be kept around as an orphan until the orphan removal job
// gets around to removing them
assertNotNull(this.contentCurator.find(content.getUuid()));
assertEquals(0, this.ownerContentCurator.getOwnerCount(content));
assertNotNull(this.ownerContentCurator.getContentById(owner, content.getId()));
// The product should have also changed in the same way as a result of the content change
assertNotNull(this.productCurator.find(product.getUuid()));
assertEquals(0, this.ownerProductCurator.getOwnerCount(product));
assertNotNull(this.ownerProductCurator.getProductById(owner, product.getId()));
if (regenCerts) {
verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner)), anyCollectionOf(Product.class), anyBoolean());
} else {
verifyZeroInteractions(this.mockEntCertGenerator);
}
}
Aggregations