use of org.candlepin.model.Content in project candlepin by candlepin.
the class ProductTranslatorTest method initSourceObject.
@Override
protected Product initSourceObject() {
Product source = new Product();
Map<String, String> attributes = new HashMap<>();
attributes.put("attrib_1", "attrib_value_1");
attributes.put("attrib_2", "attrib_value_2");
attributes.put("attrib_3", "attrib_value_3");
Collection<String> depProdIds = new LinkedList<>();
depProdIds.add("dep_prod_1");
depProdIds.add("dep_prod_2");
depProdIds.add("dep_prod_3");
source.setUuid("test_uuid");
source.setId("test_id");
source.setName("test_name");
source.setMultiplier(10L);
source.setAttributes(attributes);
source.setDependentProductIds(depProdIds);
source.setLocked(true);
for (int i = 0; i < 3; ++i) {
Content content = TestUtil.createContent("content-" + i);
content.setUuid(content.getId() + "_uuid");
source.addContent(content, true);
}
return source;
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ProductManagerTest method testAddContentToProduct.
@Test
public void testAddContentToProduct() {
Owner owner = this.createOwner("test-owner-1", "Test Owner 1");
Product product = this.createProduct("p1", "prod1");
Content content = this.createContent("c1", "content1", owner);
this.ownerProductCurator.mapProductToOwners(product, owner);
ProductDTO pdto = this.modelTranslator.translate(product, ProductDTO.class);
ContentDTO cdto = this.modelTranslator.translate(content, ContentDTO.class);
pdto.addContent(cdto, true);
Product output = this.productManager.updateProduct(pdto, owner, false);
assertNotEquals(product, output);
assertTrue(output.hasContent(content.getId()));
verifyZeroInteractions(this.mockEntCertGenerator);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ProductManagerTest method testRemoveContentFromProductForBadOwner.
@Test(expected = IllegalStateException.class)
public void testRemoveContentFromProductForBadOwner() {
Owner owner = this.createOwner("test-owner", "Test Owner");
Owner owner2 = this.createOwner("test-owner-2", "Test Owner");
Product product = TestUtil.createProduct("p1", "prod1");
Content content = TestUtil.createContent("c1");
product.addContent(content, true);
this.contentCurator.create(content);
this.productCurator.create(product);
this.ownerProductCurator.mapProductToOwner(product, owner);
this.ownerContentCurator.mapContentToOwner(content, owner);
ProductDTO pdto = this.modelTranslator.translate(product, ProductDTO.class);
boolean removed = pdto.removeContent(content.getId());
assertTrue(removed);
Product output = this.productManager.updateProduct(pdto, owner2, false);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ProductTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(Product source, ProductDTO dto, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getUuid(), dto.getUuid());
assertEquals(source.getMultiplier(), dto.getMultiplier());
assertEquals(source.getId(), dto.getId());
assertEquals(source.getName(), dto.getName());
assertEquals(source.getAttributes(), dto.getAttributes());
assertEquals(source.getDependentProductIds(), dto.getDependentProductIds());
assertNotNull(dto.getProductContent());
if (childrenGenerated) {
for (ProductContent pc : source.getProductContent()) {
for (ProductDTO.ProductContentDTO pcdto : dto.getProductContent()) {
Content content = pc.getContent();
ContentDTO cdto = pcdto.getContent();
assertNotNull(cdto);
assertNotNull(cdto.getId());
if (cdto.getId().equals(content.getId())) {
assertEquals(pc.isEnabled(), pcdto.isEnabled());
// Pass the content off to the ContentTranslatorTest to verify it
this.contentTranslatorTest.verifyOutput(content, cdto, true);
}
}
}
} else {
assertTrue(dto.getProductContent().isEmpty());
}
} else {
assertNull(dto);
}
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class ProductTranslatorTest method initSourceObject.
@Override
protected Product initSourceObject() {
Product source = new Product();
Map<String, String> attributes = new HashMap<>();
attributes.put("attrib_1", "attrib_value_1");
attributes.put("attrib_2", "attrib_value_2");
attributes.put("attrib_3", "attrib_value_3");
Collection<String> depProdIds = new LinkedList<>();
depProdIds.add("dep_prod_1");
depProdIds.add("dep_prod_2");
depProdIds.add("dep_prod_3");
source.setId("test_id");
source.setName("test_name");
source.setAttributes(attributes);
source.setDependentProductIds(depProdIds);
source.setUuid("test_uuid");
source.setMultiplier(3L);
for (int i = 0; i < 3; ++i) {
Content content = TestUtil.createContent("content-" + i);
source.addContent(content, true);
}
return source;
}
Aggregations