Search in sources :

Example 16 with PoolDTO

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

the class OwnerResourceTest method cantUpdateBonusPool.

@Test(expected = BadRequestException.class)
public void cantUpdateBonusPool() {
    Product prod = this.createProduct(owner);
    prod.setAttribute(Product.Attributes.VIRT_LIMIT, "3");
    productCurator.merge(prod);
    Pool pool = TestUtil.createPool(owner, prod);
    pool.setUpstreamPoolId("upstream-" + pool.getId());
    pool.setSubscriptionSubKey("master");
    PoolDTO poolDto = this.modelTranslator.translate(pool, PoolDTO.class);
    ownerResource.createPool(owner.getKey(), poolDto);
    List<Pool> pools = poolCurator.listByOwner(owner).list();
    Pool bonusPool = null;
    for (Pool p : pools) {
        if (p.getSubscriptionSubKey().contentEquals("derived")) {
            bonusPool = p;
        }
    }
    assertNotNull(bonusPool);
    poolDto = this.modelTranslator.translate(bonusPool, PoolDTO.class);
    ownerResource.updatePool(owner.getKey(), poolDto);
}
Also used : Product(org.candlepin.model.Product) PoolDTO(org.candlepin.dto.api.v1.PoolDTO) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Example 17 with PoolDTO

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

the class OwnerResourceTest method createPool.

@Test
public void createPool() {
    Product prod = this.createProduct(owner);
    Pool pool = TestUtil.createPool(owner, prod);
    PoolDTO poolDto = this.modelTranslator.translate(pool, PoolDTO.class);
    assertEquals(0, poolCurator.listByOwner(owner).list().size());
    PoolDTO createdPoolDto = ownerResource.createPool(owner.getKey(), poolDto);
    assertEquals(1, poolCurator.listByOwner(owner).list().size());
    assertNotNull(createdPoolDto.getId());
}
Also used : Product(org.candlepin.model.Product) PoolDTO(org.candlepin.dto.api.v1.PoolDTO) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Example 18 with PoolDTO

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

the class OwnerResourceTest method createBonusPoolForUpdate.

@Test
public void createBonusPoolForUpdate() {
    Product prod = this.createProduct(owner);
    prod.setAttribute(Product.Attributes.VIRT_LIMIT, "3");
    productCurator.merge(prod);
    Pool pool = TestUtil.createPool(owner, prod);
    pool.setUpstreamPoolId("upstream-" + pool.getId());
    pool.setSubscriptionSubKey("master");
    PoolDTO poolDto = this.modelTranslator.translate(pool, PoolDTO.class);
    poolDto = ownerResource.createPool(owner.getKey(), poolDto);
    poolDto.setQuantity(100L);
    ownerResource.updatePool(owner.getKey(), poolDto);
    List<Pool> pools = poolCurator.listByOwner(owner).list();
    assertEquals(2, pools.size());
    assertTrue(pools.get(0).getSubscriptionSubKey().startsWith("master") || pools.get(1).getSubscriptionSubKey().startsWith("master"));
    assertTrue(pools.get(0).getSubscriptionSubKey().equals("derived") || pools.get(1).getSubscriptionSubKey().equals("derived"));
    assertEquals(100L, pools.get(0).getQuantity().longValue());
    assertEquals(300L, pools.get(1).getQuantity().longValue());
}
Also used : Product(org.candlepin.model.Product) PoolDTO(org.candlepin.dto.api.v1.PoolDTO) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Example 19 with PoolDTO

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

the class PoolResourceTest method testCalculatedAttributesEmpty.

@Test
public void testCalculatedAttributesEmpty() {
    PoolDTO p = poolResource.getPool(pool1.getId(), null, null, adminPrincipal);
    assertTrue(p.getCalculatedAttributes().isEmpty());
}
Also used : PoolDTO(org.candlepin.dto.api.v1.PoolDTO) Test(org.junit.Test)

Example 20 with PoolDTO

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

the class PoolResourceTest method testListForOrg.

@Test
public void testListForOrg() {
    List<PoolDTO> pools = poolResource.list(owner1.getId(), null, null, false, null, adminPrincipal, null);
    assertEquals(2, pools.size());
    Principal p = setupPrincipal(owner2, Access.ALL);
    pools = poolResource.list(owner2.getId(), null, null, false, null, p, null);
    assertEquals(1, pools.size());
}
Also used : PoolDTO(org.candlepin.dto.api.v1.PoolDTO) Principal(org.candlepin.auth.Principal) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Test(org.junit.Test)

Aggregations

PoolDTO (org.candlepin.dto.api.v1.PoolDTO)19 Pool (org.candlepin.model.Pool)18 Test (org.junit.Test)16 Product (org.candlepin.model.Product)14 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)8 Principal (org.candlepin.auth.Principal)8 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 UserPrincipal (org.candlepin.auth.UserPrincipal)5 HashSet (java.util.HashSet)3 Map (java.util.Map)3 ConsumerDTO (org.candlepin.dto.rules.v1.ConsumerDTO)3 PoolDTO (org.candlepin.dto.rules.v1.PoolDTO)3 Branding (org.candlepin.model.Branding)3 Consumer (org.candlepin.model.Consumer)3 Owner (org.candlepin.model.Owner)3 JsonJsContext (org.candlepin.policy.js.JsonJsContext)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2