use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class LinkHeaderResponseFilterTest method testGetPrevPage.
@Test
public void testGetPrevPage() {
Page<Object> p = new Page<>();
p.setMaxRecords(55);
PageRequest pr = new PageRequest();
p.setPageRequest(pr);
pr.setPerPage(10);
pr.setPage(3);
assertEquals(Integer.valueOf(2), interceptor.getPrevPage(p));
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class LinkHeaderResponseFilterTest method testGetPrevPageWhenOnFirstPage.
@Test
public void testGetPrevPageWhenOnFirstPage() {
Page<Object> p = new Page<>();
p.setMaxRecords(55);
PageRequest pr = new PageRequest();
p.setPageRequest(pr);
pr.setPerPage(10);
pr.setPage(1);
assertNull(interceptor.getPrevPage(p));
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class OwnerResourceTest method getEntitlementsForNonExistantOwner.
@Test(expected = NotFoundException.class)
public void getEntitlementsForNonExistantOwner() {
PageRequest req = new PageRequest();
req.setPage(1);
req.setPerPage(10);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.modelTranslator);
ownerres.ownerEntitlements("Taylor Swift", null, null, null, req);
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testListConditionDevPools.
@Test
public void testListConditionDevPools() {
Owner owner = createOwner();
Product p = TestUtil.createProduct("test-product", "Test Product");
productCurator.create(p);
Pool pool1 = createPool(owner, p, 10L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
pool1.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
poolCurator.create(pool1);
Pool pool2 = createPool(owner, p, 10L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
poolCurator.create(pool2);
Consumer devSystem = new Consumer("dev", "user", owner, systemType);
devSystem.setFact("dev_sku", p.getId());
devSystem.addInstalledProduct(new ConsumerInstalledProduct(p));
Consumer nonDevSystem = new Consumer("system", "user", owner, systemType);
nonDevSystem.addInstalledProduct(new ConsumerInstalledProduct(p));
Page<List<Pool>> results = poolManager.listAvailableEntitlementPools(devSystem, null, owner.getId(), null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
assertEquals(2, results.getPageData().size());
results = poolManager.listAvailableEntitlementPools(nonDevSystem, null, owner.getId(), null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
assertEquals(1, results.getPageData().size());
Pool found2 = results.getPageData().get(0);
assertEquals(pool2, found2);
}
use of org.candlepin.common.paging.PageRequest in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testListAllForConsumerExcludesErrors.
@Test
public void testListAllForConsumerExcludesErrors() {
Product p = TestUtil.createProduct("test-product", "Test Product");
productCurator.create(p);
Page<List<Pool>> results = poolManager.listAvailableEntitlementPools(parentSystem, null, 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 will 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(parentSystem, null, 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(4, results.getPageData().size());
}
Aggregations