Search in sources :

Example 6 with ContentDTO

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);
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) ProductContent(org.candlepin.model.ProductContent) Content(org.candlepin.model.Content) Product(org.candlepin.model.Product) ProductDTO(org.candlepin.dto.api.v1.ProductDTO) Test(org.junit.Test)

Example 7 with ContentDTO

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;
}
Also used : ContentDTO(org.candlepin.dto.manifest.v1.ContentDTO)

Example 8 with ContentDTO

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;
}
Also used : ProductContentDTO(org.candlepin.dto.manifest.v1.ProductDTO.ProductContentDTO) ContentDTO(org.candlepin.dto.manifest.v1.ContentDTO) HashMap(java.util.HashMap) ProductContentDTO(org.candlepin.dto.manifest.v1.ProductDTO.ProductContentDTO) ProductDTO(org.candlepin.dto.manifest.v1.ProductDTO) LinkedList(java.util.LinkedList)

Example 9 with ContentDTO

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);
    }
}
Also used : ProductContentDTO(org.candlepin.dto.manifest.v1.ProductDTO.ProductContentDTO) ContentDTO(org.candlepin.dto.manifest.v1.ContentDTO) ContentData(org.candlepin.model.dto.ContentData) ProductContentData(org.candlepin.model.dto.ProductContentData) ProductContentDTO(org.candlepin.dto.manifest.v1.ProductDTO.ProductContentDTO) ProductContentData(org.candlepin.model.dto.ProductContentData)

Example 10 with ContentDTO

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);
    }
}
Also used : EnvironmentContentDTO(org.candlepin.dto.api.v1.EnvironmentDTO.EnvironmentContentDTO) EnvironmentContentDTO(org.candlepin.dto.api.v1.EnvironmentDTO.EnvironmentContentDTO) EnvironmentContent(org.candlepin.model.EnvironmentContent) Content(org.candlepin.model.Content) EnvironmentContent(org.candlepin.model.EnvironmentContent)

Aggregations

ContentDTO (org.candlepin.dto.api.v1.ContentDTO)35 Content (org.candlepin.model.Content)30 Test (org.junit.Test)28 Owner (org.candlepin.model.Owner)26 Product (org.candlepin.model.Product)14 ProductContent (org.candlepin.model.ProductContent)9 ProductContentDTO (org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO)8 ProductDTO (org.candlepin.dto.api.v1.ProductDTO)7 ContentDTO (org.candlepin.dto.manifest.v1.ContentDTO)7 LinkedList (java.util.LinkedList)5 ProductDTO (org.candlepin.dto.manifest.v1.ProductDTO)5 Transactional (com.google.inject.persist.Transactional)4 Parameters (junitparams.Parameters)4 ContentData (org.candlepin.model.dto.ContentData)4 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 ForbiddenException (org.candlepin.common.exceptions.ForbiddenException)3 ProductContentData (org.candlepin.model.dto.ProductContentData)3