Search in sources :

Example 21 with ContentDTO

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

the class ProductDataTranslatorTest method verifyOutput.

@Override
protected void verifyOutput(ProductData 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());
        if (childrenGenerated) {
            assertNotNull(dto.getProductContent());
            for (ProductContentData pc : source.getProductContent()) {
                for (ProductContentDTO pcdto : dto.getProductContent()) {
                    ContentData 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.contentDataTranslatorTest.verifyOutput(content, cdto, childrenGenerated);
                    }
                }
            }
        } else {
            assertNull(dto.getProductContent());
        }
    } else {
        assertNull(dto);
    }
}
Also used : ProductContentDTO(org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO) ContentDTO(org.candlepin.dto.api.v1.ContentDTO) ContentData(org.candlepin.model.dto.ContentData) ProductContentData(org.candlepin.model.dto.ProductContentData) ProductContentDTO(org.candlepin.dto.api.v1.ProductDTO.ProductContentDTO) ProductContentData(org.candlepin.model.dto.ProductContentData)

Example 22 with ContentDTO

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

the class ContentResourceTest method testUpdateContentNoLongerSupported.

@Test(expected = BadRequestException.class)
public void testUpdateContentNoLongerSupported() {
    final String contentId = "10";
    ContentDTO contentDTO = mock(ContentDTO.class);
    cr.updateContent(contentId, contentDTO);
    verify(cc, never()).find(any());
    verify(cc, never()).merge(any());
    verify(productCurator, never()).getProductsByContent(any(), any());
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Test(org.junit.Test)

Example 23 with ContentDTO

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

the class ContentResourceTest method getContent.

@Test
public void getContent() {
    Owner owner = mock(Owner.class);
    Content content = mock(Content.class);
    CandlepinQuery cqmock = mock(CandlepinQuery.class);
    ContentDTO expected = this.modelTranslator.translate(content, ContentDTO.class);
    when(cqmock.list()).thenReturn(Arrays.asList(owner));
    when(oc.listAll()).thenReturn(cqmock);
    when(cc.lookupByUuid(eq("10"))).thenReturn(content);
    ContentDTO output = cr.getContent("10");
    assertEquals(expected, output);
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) Content(org.candlepin.model.Content) EmptyCandlepinQuery(org.candlepin.model.EmptyCandlepinQuery) CandlepinQuery(org.candlepin.model.CandlepinQuery) Test(org.junit.Test)

Example 24 with ContentDTO

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

the class OwnerContentResourceTest method createContent.

@Test
public void createContent() {
    Owner owner = this.createOwner("test_owner");
    ContentDTO cdto = TestUtil.createContentDTO("test_content");
    cdto.setLabel("test-label");
    cdto.setType("test-test");
    cdto.setVendor("test-vendor");
    assertNull(this.ownerContentCurator.getContentById(owner, cdto.getId()));
    ContentDTO output = this.ownerContentResource.createContent(owner.getKey(), cdto);
    assertNotNull(output);
    assertEquals(cdto.getId(), output.getId());
    Content entity = this.ownerContentCurator.getContentById(owner, cdto.getId());
    assertNotNull(entity);
    assertEquals(cdto.getName(), entity.getName());
    assertEquals(cdto.getLabel(), entity.getLabel());
    assertEquals(cdto.getType(), entity.getType());
    assertEquals(cdto.getVendor(), entity.getVendor());
}
Also used : ContentDTO(org.candlepin.dto.api.v1.ContentDTO) Owner(org.candlepin.model.Owner) Content(org.candlepin.model.Content) Test(org.junit.Test)

Example 25 with ContentDTO

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

the class OwnerContentResourceTest method listContent.

@Test
public void listContent() throws Exception {
    Owner owner = this.createOwner("test_owner");
    Content content = this.createContent("test_content", "test_content", owner);
    ContentDTO cdto = this.modelTranslator.translate(content, ContentDTO.class);
    CandlepinQuery<ContentDTO> response = this.ownerContentResource.listContent(owner.getKey());
    assertNotNull(response);
    Collection<ContentDTO> received = response.list();
    assertEquals(1, received.size());
    assertTrue(received.contains(cdto));
}
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