Search in sources :

Example 6 with ContentDTO

use of org.candlepin.dto.manifest.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 7 with ContentDTO

use of org.candlepin.dto.manifest.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 8 with ContentDTO

use of org.candlepin.dto.manifest.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 9 with ContentDTO

use of org.candlepin.dto.manifest.v1.ContentDTO in project candlepin by candlepin.

the class TestUtil method createContentDTO.

public static ContentDTO createContentDTO(String id, String name) {
    ContentDTO dto = new ContentDTO();
    dto.setId(id);
    dto.setName(name);
    return dto;
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) ProductContentDTO(org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO)

Example 10 with ContentDTO

use of org.candlepin.dto.manifest.v1.ContentDTO in project candlepin by candlepin.

the class ContentManagerTest method testCreateContentThatAlreadyExists.

@Test(expected = IllegalStateException.class)
public void testCreateContentThatAlreadyExists() {
    Owner owner = this.createOwner("test-owner", "Test Owner");
    ContentDTO dto = TestUtil.createContentDTO("c1", "content-1");
    dto.setLabel("test-label");
    dto.setType("test-test");
    dto.setVendor("test-vendor");
    Content output = this.contentManager.createContent(dto, owner);
    // Verify the creation worked
    assertNotNull(output);
    assertEquals(output, this.ownerContentCurator.getContentById(owner, dto.getId()));
    // This should fail, since it already exists
    this.contentManager.createContent(dto, owner);
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) Content(org.candlepin.model.Content) Test(org.junit.Test)

Aggregations

ContentDTO (org.candlepin.dto.api.v1.ContentDTO)35 Test (org.junit.Test)28 Owner (org.candlepin.model.Owner)26 Content (org.candlepin.model.Content)25 Product (org.candlepin.model.Product)13 ProductDTO (org.candlepin.dto.api.v1.ProductDTO)7 ContentDTO (org.candlepin.dto.manifest.v1.ContentDTO)7 ProductContent (org.candlepin.model.ProductContent)7 LinkedList (java.util.LinkedList)5 ProductContentDTO (org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO)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