use of org.candlepin.dto.api.v1.ContentDTO 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.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class ContentDTOTranslatorTest method initSourceObject.
@Override
protected ContentDTO initSourceObject() {
ContentDTO source = new ContentDTO();
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");
return source;
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class ProductDTOTranslatorTest method initSourceObject.
@Override
protected ProductDTO initSourceObject() {
ProductDTO source = new ProductDTO();
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);
for (int i = 0; i < 3; ++i) {
ContentDTO contentDTO = new ContentDTO();
contentDTO.setId("content-dto-" + i);
contentDTO.setUuid(contentDTO.getId() + "_uuid");
ProductContentDTO pcDTO = new ProductContentDTO(contentDTO, true);
source.addProductContent(pcDTO);
}
return source;
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class ProductDTOTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(ProductDTO source, ProductData 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());
assertNotNull(dto.getProductContent());
if (childrenGenerated) {
for (ProductContentDTO pcdto : source.getProductContent()) {
for (ProductContentData pcdata : dto.getProductContent()) {
ContentDTO cdto = pcdto.getContent();
ContentData cdata = pcdata.getContent();
assertNotNull(cdata);
assertNotNull(cdata.getUuid());
if (cdata.getUuid().equals(cdto.getUuid())) {
assertEquals(pcdto.isEnabled(), pcdata.isEnabled());
// Pass the content off to the ContentTranslatorTest to verify it
this.contentDTOTranslatorTest.verifyOutput(cdto, cdata, true);
}
}
}
} else {
assertTrue(dto.getProductContent().isEmpty());
}
} else {
assertNull(dto);
}
}
use of org.candlepin.dto.api.v1.ContentDTO in project candlepin by candlepin.
the class EnvironmentTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(Environment source, EnvironmentDTO dto, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getId(), dto.getId());
assertEquals(source.getName(), dto.getName());
assertEquals(source.getDescription(), dto.getDescription());
if (childrenGenerated) {
this.ownerTranslatorTest.verifyOutput(source.getOwner(), dto.getOwner(), childrenGenerated);
assertNotNull(dto.getEnvironmentContent());
for (EnvironmentContent ec : source.getEnvironmentContent()) {
for (EnvironmentContentDTO ecdto : dto.getEnvironmentContent()) {
Content content = ec.getContent();
ContentDTO cdto = ecdto.getContent();
assertNotNull(cdto);
assertNotNull(cdto.getUuid());
if (cdto.getUuid().equals(content.getUuid())) {
assertEquals(ec.getEnabled(), ecdto.isEnabled());
// Pass the content off to the ContentTranslatorTest to verify it
this.contentTranslatorTest.verifyOutput(content, cdto, childrenGenerated);
}
}
}
} else {
assertNull(dto.getEnvironmentContent());
assertNull(dto.getOwner());
}
} else {
assertNull(dto);
}
}
Aggregations