use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method removePoolsForExpiredUpdate.
@Test
public void removePoolsForExpiredUpdate() {
Product prod = this.createProduct(owner);
prod.setAttribute(Product.Attributes.VIRT_LIMIT, "3");
prod = 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);
List<Pool> pools = poolCurator.listByOwner(owner).list();
assertEquals(2, pools.size());
poolDto.setStartDate(new Date(System.currentTimeMillis() - 5 * 24 * 60 * 60 * 1000));
poolDto.setEndDate(new Date(System.currentTimeMillis() - 3 * 24 * 60 * 60 * 1000));
ownerResource.updatePool(owner.getKey(), poolDto);
pools = poolCurator.listByOwner(owner).list();
assertEquals(0, pools.size());
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method createBonusPool.
@Test
public void createBonusPool() {
Product prod = this.createProduct(owner);
prod.setAttribute(Product.Attributes.VIRT_LIMIT, "2");
productCurator.merge(prod);
Pool pool = TestUtil.createPool(owner, prod);
pool.setUpstreamPoolId("upstream-" + pool.getId());
assertEquals(0, poolCurator.listByOwner(owner).list().size());
PoolDTO poolDto = this.modelTranslator.translate(pool, PoolDTO.class);
ownerResource.createPool(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"));
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class PoolResourceTest method testListConsumerFiltering.
@Test
public void testListConsumerFiltering() {
setupPrincipal(new ConsumerPrincipal(passConsumer, owner1));
List<PoolDTO> pools = poolResource.list(null, passConsumer.getUuid(), null, false, null, adminPrincipal, null);
assertEquals(2, pools.size());
verify(attrUtil, times(1)).setCalculatedAttributes((List<Pool>) argThat(IsCollectionWithSize.hasSize(2)), any(Date.class));
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class PoolResourceTest method ownerAdminCannotListAnotherOwnersPools.
@Test(expected = NotFoundException.class)
public void ownerAdminCannotListAnotherOwnersPools() {
List<PoolDTO> pools = poolResource.list(owner1.getId(), null, null, false, null, adminPrincipal, null);
assertEquals(2, pools.size());
Principal anotherPrincipal = setupPrincipal(owner2, Access.ALL);
securityInterceptor.enable();
poolResource.list(owner1.getId(), null, null, false, null, anotherPrincipal, null);
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method enrichPool.
@Test
public void enrichPool() {
Product prod = this.createProduct(owner);
prod.setAttribute(Product.Attributes.VIRT_ONLY, "true");
prod.setMultiplier(2L);
productCurator.merge(prod);
Pool pool = TestUtil.createPool(owner, prod);
pool.setQuantity(100L);
assertEquals(0, poolCurator.listByOwner(owner).list().size());
PoolDTO poolDto = this.modelTranslator.translate(pool, PoolDTO.class);
ownerResource.createPool(owner.getKey(), poolDto);
List<Pool> pools = poolCurator.listByOwner(owner).list();
assertEquals(1, pools.size());
assertTrue(Boolean.parseBoolean(pools.get(0).getAttributeValue(Product.Attributes.VIRT_ONLY)));
assertEquals(200L, pools.get(0).getQuantity().intValue());
}
Aggregations