Search in sources :

Example 26 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class ProductDataTranslatorTest method initSourceObject.

@Override
protected ProductData initSourceObject() {
    ProductData source = new ProductData();
    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;
}
Also used : ProductData(org.candlepin.model.dto.ProductData) HashMap(java.util.HashMap) Content(org.candlepin.model.Content) LinkedList(java.util.LinkedList)

Example 27 with Content

use of org.candlepin.model.Content 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)

Example 28 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class ContentTranslatorTest method initSourceObject.

@Override
protected Content initSourceObject() {
    Content source = new Content();
    source.setUuid("test_value");
    source.setMetadataExpire(3L);
    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.setModifiedProductIds(Arrays.asList("1", "2", "3"));
    source.setArches("test_value");
    return source;
}
Also used : Content(org.candlepin.model.Content)

Example 29 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class X509V3ExtensionUtilTest method testPrefixLogic.

@Test
public void testPrefixLogic() {
    Owner owner = new Owner("Test Corporation");
    Product p = new Product("JarJar", "Binks");
    Content c = new Content();
    c.setContentUrl("/some/path");
    ProductContent pc = new ProductContent(p, c, true);
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is", pc));
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is/", pc));
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is///", pc));
    c.setContentUrl("some/path");
    assertEquals("/some/path", util.createFullContentPath(null, pc));
    assertEquals("/some/path", util.createFullContentPath("", pc));
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is/", pc));
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is", pc));
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is///", pc));
    c.setContentUrl("///////some/path");
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is/", pc));
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is", pc));
    assertEquals("/this/is/some/path", util.createFullContentPath("/this/is///", pc));
    assertEquals("/some/path", util.createFullContentPath(null, pc));
    assertEquals("/some/path", util.createFullContentPath("", pc));
    c.setContentUrl("http://some/path");
    assertEquals("http://some/path", util.createFullContentPath("/this/is", pc));
    c.setContentUrl("https://some/path");
    assertEquals("https://some/path", util.createFullContentPath("/this/is", pc));
    c.setContentUrl("ftp://some/path");
    assertEquals("ftp://some/path", util.createFullContentPath("/this/is", pc));
    c.setContentUrl("file://some/path");
    assertEquals("file://some/path", util.createFullContentPath("/this/is", pc));
}
Also used : Owner(org.candlepin.model.Owner) ProductContent(org.candlepin.model.ProductContent) Content(org.candlepin.model.Content) Product(org.candlepin.model.Product) ProductContent(org.candlepin.model.ProductContent) Test(org.junit.Test)

Example 30 with Content

use of org.candlepin.model.Content in project candlepin by candlepin.

the class PoolManagerTest method buildContent.

private Content buildContent(Owner owner) {
    Content content = new Content();
    int rand = TestUtil.randomInt();
    HashSet<String> modifiedProductIds = new HashSet<>(Arrays.asList("mpid-a-" + rand, "mpid-d-" + rand, "mpid-c-" + rand));
    content.setId("cid" + rand);
    content.setContentUrl("https://www.content_url.com/" + rand);
    content.setGpgUrl("https://www.gpg_url.com/" + rand);
    content.setLabel("content_label-" + rand);
    content.setName("content-" + rand);
    content.setReleaseVersion("content_releasever-" + rand);
    content.setRequiredTags("content_tags-" + rand);
    content.setType("content_type-" + rand);
    content.setVendor("content_vendor-" + rand);
    content.setArches("content_arches-" + rand);
    content.setModifiedProductIds(modifiedProductIds);
    // Since CPM sets all inbound products and content as "locked," we do this to ensure we
    // don't always trigger a change because the lock state looks different from our mocks.
    content.setLocked(true);
    return content;
}
Also used : Content(org.candlepin.model.Content) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet)

Aggregations

Content (org.candlepin.model.Content)97 Test (org.junit.Test)45 ProductContent (org.candlepin.model.ProductContent)41 Product (org.candlepin.model.Product)40 Owner (org.candlepin.model.Owner)39 ContentDTO (org.candlepin.dto.api.v1.ContentDTO)25 HashMap (java.util.HashMap)18 EnvironmentContent (org.candlepin.model.EnvironmentContent)17 HashSet (java.util.HashSet)14 LinkedList (java.util.LinkedList)11 ProductDTO (org.candlepin.dto.api.v1.ProductDTO)10 ArrayList (java.util.ArrayList)9 Matchers.anyString (org.mockito.Matchers.anyString)9 Transactional (com.google.inject.persist.Transactional)8 Produces (javax.ws.rs.Produces)8 Parameters (junitparams.Parameters)8 ApiOperation (io.swagger.annotations.ApiOperation)7 ForbiddenException (org.candlepin.common.exceptions.ForbiddenException)7 Path (javax.ws.rs.Path)6 ProductContentDTO (org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO)6