use of org.candlepin.dto.rules.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);
}
use of org.candlepin.dto.rules.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());
}
use of org.candlepin.dto.rules.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());
}
use of org.candlepin.dto.rules.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());
}
use of org.candlepin.dto.rules.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());
}
Aggregations