use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method testCanFilterOutDevPoolsByAttribute.
@Test
public void testCanFilterOutDevPoolsByAttribute() throws Exception {
Principal principal = setupPrincipal(owner, Access.ALL);
Product p = this.createProduct(owner);
Pool pool1 = TestUtil.createPool(owner, p);
pool1.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
poolCurator.create(pool1);
Product p2 = this.createProduct(owner);
Pool pool2 = TestUtil.createPool(owner, p2);
poolCurator.create(pool2);
List<KeyValueParameter> params = new ArrayList<>();
List<PoolDTO> pools = ownerResource.listPools(owner.getKey(), null, null, null, null, true, null, null, params, false, false, null, null, principal, null);
assertEquals(2, pools.size());
params = new ArrayList<>();
params.add(createKeyValueParam(Pool.Attributes.DEVELOPMENT_POOL, "!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(pool2, pools.get(0));
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method testOwnerAdminCanGetPools.
@Test
public void testOwnerAdminCanGetPools() {
Principal principal = setupPrincipal(owner, Access.ALL);
Product p = this.createProduct(owner);
Pool pool1 = TestUtil.createPool(owner, p);
Pool pool2 = TestUtil.createPool(owner, p);
poolCurator.create(pool1);
poolCurator.create(pool2);
List<PoolDTO> pools = ownerResource.listPools(owner.getKey(), null, null, null, null, true, null, null, new ArrayList<>(), false, false, null, null, principal, null);
assertEquals(2, pools.size());
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method consumerListPoolsGetCalculatedAttributes.
@Test
public void consumerListPoolsGetCalculatedAttributes() {
Product p = this.createProduct(owner);
Pool pool1 = TestUtil.createPool(owner, p);
poolCurator.create(pool1);
Consumer c = this.createConsumer(owner);
Principal principal = setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
List<PoolDTO> pools = ownerResource.listPools(owner.getKey(), c.getUuid(), null, p.getId(), null, true, null, null, new ArrayList<>(), false, false, null, null, principal, null);
assertEquals(1, pools.size());
PoolDTO returnedPool = pools.get(0);
assertNotNull(returnedPool.getCalculatedAttributes());
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method testUnmappedGuestConsumerCanListPoolsForFuture.
@Test
public void testUnmappedGuestConsumerCanListPoolsForFuture() {
Consumer c = this.createConsumer(owner);
c.setFact("virt.is_guest", "true");
c.setFact("virt.uuid", "system_uuid");
consumerCurator.merge(c);
Principal principal = setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
Date now = new Date();
Product p = this.createProduct(owner);
Pool pool1 = TestUtil.createPool(owner, p);
pool1.setAttribute(Pool.Attributes.VIRT_ONLY, "true");
pool1.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
pool1.setAttribute(Pool.Attributes.PHYSICAL_ONLY, "false");
pool1.setAttribute(Pool.Attributes.UNMAPPED_GUESTS_ONLY, "true");
pool1.setStartDate(now);
pool1.setEndDate(new Date(now.getTime() + 1000L * 60 * 60 * 24 * 365));
Pool pool2 = TestUtil.createPool(owner, p);
pool2.setAttribute(Pool.Attributes.VIRT_ONLY, "true");
pool2.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
pool2.setAttribute(Pool.Attributes.PHYSICAL_ONLY, "false");
pool2.setAttribute(Pool.Attributes.UNMAPPED_GUESTS_ONLY, "true");
pool2.setStartDate(new Date(now.getTime() + 2 * 1000L * 60 * 60 * 24 * 365));
pool2.setEndDate(new Date(now.getTime() + 3 * 1000L * 60 * 60 * 24 * 365));
poolCurator.create(pool1);
poolCurator.create(pool2);
List<PoolDTO> nowList = ownerResource.listPools(owner.getKey(), c.getUuid(), null, null, null, false, new Date(), null, new ArrayList<>(), false, false, null, null, principal, null);
assertEquals(1, nowList.size());
assert (nowList.get(0).getId().equals(pool1.getId()));
Date activeOn = new Date(pool2.getStartDate().getTime() + 1000L * 60 * 60 * 24);
List<PoolDTO> futureList = ownerResource.listPools(owner.getKey(), c.getUuid(), null, null, null, false, activeOn, null, new ArrayList<>(), false, false, null, null, principal, null);
assertEquals(1, futureList.size());
assert (futureList.get(0).getId().equals(pool2.getId()));
}
use of org.candlepin.dto.api.v1.PoolDTO in project candlepin by candlepin.
the class OwnerResourceTest method updatePool.
@Test
public void updatePool() {
Product prod = this.createProduct(owner);
Pool pool = TestUtil.createPool(owner, prod);
pool.setSubscriptionSubKey("master");
PoolDTO poolDto = this.modelTranslator.translate(pool, PoolDTO.class);
poolDto = ownerResource.createPool(owner.getKey(), poolDto);
List<Pool> createdPools = poolCurator.listByOwner(owner).list();
assertEquals(1, createdPools.size());
assertEquals(pool.getQuantity(), createdPools.get(0).getQuantity());
poolDto.setQuantity(10L);
ownerResource.updatePool(owner.getKey(), poolDto);
List<Pool> updatedPools = poolCurator.listByOwner(owner).list();
assertEquals(1, updatedPools.size());
assertEquals(10L, updatedPools.get(0).getQuantity().longValue());
}
Aggregations