use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method testCanFilterPoolsByAttribute.
@Test
public void testCanFilterPoolsByAttribute() throws Exception {
Principal principal = setupPrincipal(owner, Access.ALL);
Product p = this.createProduct(owner);
Pool pool1 = TestUtil.createPool(owner, p);
pool1.setAttribute(Product.Attributes.VIRT_ONLY, "true");
poolCurator.create(pool1);
Product p2 = this.createProduct(owner);
p2.setAttribute(Product.Attributes.CORES, "12");
productCurator.merge(p2);
Pool pool2 = TestUtil.createPool(owner, p2);
poolCurator.create(pool2);
List<KeyValueParameter> params = new ArrayList<>();
params.add(createKeyValueParam("cores", "12"));
List<PoolDTO> pools = ownerResource.listPools(owner.getKey(), null, null, null, null, true, null, null, params, false, false, null, null, principal, null);
assertEquals(1, pools.size());
assertModelEqualsDTO(pool2, pools.get(0));
params.clear();
params.add(createKeyValueParam("virt_only", "true"));
pools = ownerResource.listPools(owner.getKey(), null, null, null, null, true, null, null, params, false, false, null, null, principal, null);
assertEquals(1, pools.size());
assertModelEqualsDTO(pool1, pools.get(0));
}
use of org.candlepin.dto.api.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.api.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.api.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.api.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());
}
Aggregations