use of org.candlepin.dto.api.v1.ProductDTO in project candlepin by candlepin.
the class TestUtil method createProductDTO.
public static ProductDTO createProductDTO(String id, String name) {
ProductDTO dto = new ProductDTO();
dto.setId(id);
dto.setName(name);
return dto;
}
use of org.candlepin.dto.api.v1.ProductDTO 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.getId(), dto.getId());
assertEquals(source.getName(), dto.getName());
assertEquals(source.getMultiplier(), dto.getMultiplier());
assertEquals(source.getAttributes(), dto.getAttributes());
assertEquals(source.getDependentProductIds(), dto.getDependentProductIds());
assertEquals(source.isLocked(), dto.isLocked());
assertEquals(source.getHref(), dto.getHref());
assertNotNull(dto.getProductContent());
if (childrenGenerated) {
for (ProductContent pc : source.getProductContent()) {
for (ProductContentDTO pcdto : dto.getProductContent()) {
Content content = pc.getContent();
ContentDTO cdto = pcdto.getContent();
assertNotNull(cdto);
assertNotNull(cdto.getUuid());
if (cdto.getUuid().equals(content.getUuid())) {
assertEquals(pc.isEnabled(), pcdto.isEnabled());
// Pass the content off to the ContentTranslatorTest to verify it
this.contentTranslatorTest.verifyOutput(content, cdto, childrenGenerated);
}
}
}
} else {
assertTrue(dto.getProductContent().isEmpty());
}
} else {
assertNull(dto);
}
}
use of org.candlepin.dto.api.v1.ProductDTO in project candlepin by candlepin.
the class ProductManagerTest method testAddContentToSharedProduct.
@Test
@Parameters({ "false", "true" })
public void testAddContentToSharedProduct(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", "prod1", owner1);
Content content = this.createContent("c1", "content1", owner1);
this.ownerProductCurator.mapProductToOwners(product, owner1, owner2);
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, owner1, regenCerts);
assertNotEquals(product, output);
assertFalse(product.hasContent(content.getId()));
assertTrue(output.hasContent(content.getId()));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product, owner1));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner2));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(output, owner1));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(output, 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.api.v1.ProductDTO in project candlepin by candlepin.
the class ProductManagerTest method testUpdateProductThatDoesntExist.
@Test(expected = IllegalStateException.class)
public void testUpdateProductThatDoesntExist() {
Owner owner = this.createOwner("test-owner", "Test Owner");
Product product = TestUtil.createProduct("p1", "new_name");
ProductDTO update = TestUtil.createProductDTO("p1", "new_name");
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product, owner));
this.productManager.updateProduct(update, owner, false);
}
use of org.candlepin.dto.api.v1.ProductDTO in project candlepin by candlepin.
the class ProductManagerTest method testCreateProductMergeWithExisting.
@Test
public void testCreateProductMergeWithExisting() {
Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
Product product1 = TestUtil.createProduct("p1", "prod1");
Product product2 = this.createProduct("p1", "prod1", owner2);
ProductDTO pdto = this.modelTranslator.translate(product1, ProductDTO.class);
Product output = this.productManager.createProduct(pdto, owner1);
assertEquals(output.getUuid(), product2.getUuid());
assertEquals(output, product2);
assertTrue(this.ownerProductCurator.isProductMappedToOwner(output, owner1));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(output, owner2));
}
Aggregations