use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testListAllForActKeyExcludesErrors.
@Test
public void testListAllForActKeyExcludesErrors() {
Product p = TestUtil.createProduct("test-product", "Test Product");
productCurator.create(p);
ActivationKey ak = new ActivationKey();
Pool akpool = new Pool();
akpool.setAttribute(Pool.Attributes.PHYSICAL_ONLY, "true");
ak.addPool(akpool, 1L);
Page<List<Pool>> results = poolManager.listAvailableEntitlementPools(null, ak, parentSystem.getOwnerId(), null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
assertEquals(4, results.getPageData().size());
// Creating a pool with no entitlements available, which does not trigger
// a rules error:
Pool pool = createPool(o, p, 0L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
poolCurator.create(pool);
results = poolManager.listAvailableEntitlementPools(null, ak, parentSystem.getOwnerId(), null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
// Pool in error should not be included. Should have the same number of
// initial pools.
assertEquals(5, results.getPageData().size());
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testListForConsumerExcludesWarnings.
@Test
public void testListForConsumerExcludesWarnings() {
Page<List<Pool>> results = poolManager.listAvailableEntitlementPools(parentSystem, null, parentSystem.getOwnerId(), (String) null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
assertEquals(4, results.getPageData().size());
Pool pool = createPool(o, socketLimitedProduct, 100L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
poolCurator.create(pool);
parentSystem.setFact("cpu.cpu_socket(s)", "4");
results = poolManager.listAvailableEntitlementPools(parentSystem, null, parentSystem.getOwnerId(), (String) null, null, null, false, new PoolFilterBuilder(), new PageRequest(), false, false, null);
// Pool in error should not be included. Should have the same number of
// initial pools.
assertEquals(4, results.getPageData().size());
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class PoolCuratorTest method testCorrectPagingWhenLastPage.
@Test
public void testCorrectPagingWhenLastPage() {
for (int i = 0; i < 5; i++) {
Pool pool = TestUtil.createPool(owner, product);
pool.setStartDate(TestUtil.createDate(2011, 1, 2));
pool.setEndDate(TestUtil.createDate(2011, 3, 2));
poolCurator.create(pool);
}
PageRequest req = new PageRequest();
req.setPage(3);
req.setPerPage(2);
Date activeOn = TestUtil.createDate(2011, 2, 2);
Page<List<Pool>> page = poolCurator.listAvailableEntitlementPools(null, owner, product.getId(), null, activeOn, new PoolFilterBuilder(), req, false, false, false, null);
assertEquals(Integer.valueOf(5), page.getMaxRecords());
assertEquals(1, page.getPageData().size());
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class PoolCuratorTest method availablePoolsCanFilterByEmptyValueAttribute.
@Test
public void availablePoolsCanFilterByEmptyValueAttribute() throws Exception {
Date activeDate = TestUtil.createDate(2000, 3, 2);
Pool pool1 = createPool(owner, product, 100L, activeDate, TestUtil.createDate(2005, 3, 2));
poolCurator.create(pool1);
Product product2 = TestUtil.createProduct();
product2.setAttribute("empty-attr", "");
product2 = this.createProduct(product2, owner);
Pool pool2 = createPool(owner, product2, 100L, activeDate, TestUtil.createDate(2005, 3, 2));
poolCurator.create(pool2);
PageRequest req = new PageRequest();
req.setPage(1);
req.setPerPage(10);
req.setOrder(PageRequest.Order.ASCENDING);
req.setSortBy("id");
PoolFilterBuilder filters = new PoolFilterBuilder();
filters.addAttributeFilter("empty-attr", "");
Page<List<Pool>> page = poolCurator.listAvailableEntitlementPools(null, owner.getId(), (Collection<String>) null, null, activeDate, filters, req, false, false, false, null);
List<Pool> results = page.getPageData();
assertEquals(1, results.size());
assertEquals(pool2.getId(), results.get(0).getId());
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class PoolCuratorTest method testCorrectPagingWhenResultsLessThanPageSize.
@Test
public void testCorrectPagingWhenResultsLessThanPageSize() {
for (int i = 0; i < 5; i++) {
Pool pool = TestUtil.createPool(owner, product);
pool.setStartDate(TestUtil.createDate(2011, 1, 2));
pool.setEndDate(TestUtil.createDate(2011, 3, 2));
poolCurator.create(pool);
}
PageRequest req = new PageRequest();
req.setPage(1);
req.setPerPage(10);
Date activeOn = TestUtil.createDate(2011, 2, 2);
Page<List<Pool>> page = poolCurator.listAvailableEntitlementPools(null, owner, product.getId(), null, activeOn, new PoolFilterBuilder(), req, false, false, false, null);
assertEquals(Integer.valueOf(5), page.getMaxRecords());
assertEquals(5, page.getPageData().size());
}
Aggregations