Search in sources :

Example 56 with Owner

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

the class OwnerTranslatorTest method initSourceObject.

@Override
protected Owner initSourceObject() {
    Owner parent = null;
    for (int i = 0; i < 3; ++i) {
        Owner owner = new Owner();
        owner.setId("owner_id-" + i);
        owner.setKey("owner_key-" + i);
        owner.setDisplayName("owner_name-" + i);
        owner.setParentOwner(parent);
        owner.setContentPrefix("content_prefix-" + i);
        owner.setDefaultServiceLevel("service_level-" + i);
        owner.setUpstreamConsumer(this.upstreamConsumerTranslatorTest.initSourceObject());
        owner.setLogLevel("log_level-" + i);
        owner.setAutobindDisabled(true);
        owner.setContentAccessModeList(String.format("cam%1$d-a,cam%1$d-b,cam%1$d-c", i));
        owner.setContentAccessMode(String.format("cam%d-b", i));
        owner.setLastRefreshed(new Date());
        parent = owner;
    }
    return parent;
}
Also used : Owner(org.candlepin.model.Owner) Date(java.util.Date)

Example 57 with Owner

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

the class ProductManagerTest method testRemoveProductDivergeFromExisting.

@Test
public void testRemoveProductDivergeFromExisting() {
    Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
    Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
    Product product = this.createProduct("p1", "prod1", owner1, owner2);
    assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner1));
    assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner2));
    this.productManager.removeProduct(owner1, product);
    assertFalse(this.ownerProductCurator.isProductMappedToOwner(product, owner1));
    assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner2));
    assertNotNull(this.productCurator.find(product.getUuid()));
    assertEquals(1, this.ownerProductCurator.getOwnerCount(product));
    verifyZeroInteractions(this.mockEntCertGenerator);
}
Also used : Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) Test(org.junit.Test)

Example 58 with Owner

use of org.candlepin.model.Owner 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 59 with Owner

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

the class ProductManagerTest method testRemoveContentFromProductForBadOwner.

@Test(expected = IllegalStateException.class)
public void testRemoveContentFromProductForBadOwner() {
    Owner owner = this.createOwner("test-owner", "Test Owner");
    Owner owner2 = this.createOwner("test-owner-2", "Test Owner");
    Product product = TestUtil.createProduct("p1", "prod1");
    Content content = TestUtil.createContent("c1");
    product.addContent(content, true);
    this.contentCurator.create(content);
    this.productCurator.create(product);
    this.ownerProductCurator.mapProductToOwner(product, owner);
    this.ownerContentCurator.mapContentToOwner(content, owner);
    ProductDTO pdto = this.modelTranslator.translate(product, ProductDTO.class);
    boolean removed = pdto.removeContent(content.getId());
    assertTrue(removed);
    Product output = this.productManager.updateProduct(pdto, owner2, false);
}
Also used : 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 60 with Owner

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

the class ProductManagerTest method testRemoveProductWithSubscriptions.

@Test(expected = IllegalStateException.class)
public void testRemoveProductWithSubscriptions() {
    long now = System.currentTimeMillis();
    Owner owner = this.createOwner("test-owner", "Test Owner");
    Product product = this.createProduct("p1", "prod1", owner);
    Pool pool = this.createPool(owner, product, 1L, new Date(now - 86400), new Date(now + 86400));
    this.productManager.removeProduct(owner, product);
}
Also used : Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Owner (org.candlepin.model.Owner)405 Test (org.junit.Test)254 Product (org.candlepin.model.Product)153 Consumer (org.candlepin.model.Consumer)127 Pool (org.candlepin.model.Pool)79 Date (java.util.Date)72 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)71 ArrayList (java.util.ArrayList)58 Produces (javax.ws.rs.Produces)52 ConsumerType (org.candlepin.model.ConsumerType)52 ApiOperation (io.swagger.annotations.ApiOperation)50 HashSet (java.util.HashSet)44 Entitlement (org.candlepin.model.Entitlement)44 Path (javax.ws.rs.Path)42 HashMap (java.util.HashMap)41 ApiResponses (io.swagger.annotations.ApiResponses)40 Content (org.candlepin.model.Content)39 BadRequestException (org.candlepin.common.exceptions.BadRequestException)37 Subscription (org.candlepin.model.dto.Subscription)32 List (java.util.List)29