EntitlementCurator extends AbstractHibernateCurator<Entitlement> { public Page<List<Entitlement>> listByOwner(Owner owner, String productId, EntitlementFilterBuilder filters, PageRequest pageRequest) { return listFilteredPages( owner != null ? owner.getId() : null, owner, "owner", productId, filters, pageRequest); } @Inject  EntitlementCurator(OwnerProductCurator ownerProductCurator, ProductCurator productCurator,
        ConsumerTypeCurator consumerTypeCurator, CandlepinQueryFactory cpQueryFactory); @Transactional Set<Entitlement> bulkUpdate(Set<Entitlement> entitlements); List<Entitlement> listByConsumer(Consumer consumer); List<Entitlement> listByConsumer(Consumer consumer, EntitlementFilterBuilder filters); List<Entitlement> listByConsumerAndPoolId(Consumer consumer, String poolId); Page<List<Entitlement>> listByConsumer(Consumer consumer, String productId,
        EntitlementFilterBuilder filters, PageRequest pageRequest); Page<List<Entitlement>> listByOwner(Owner owner, String productId,
        EntitlementFilterBuilder filters, PageRequest pageRequest); Page<List<Entitlement>> listAll(EntitlementFilterBuilder filters, PageRequest pageRequest); CandlepinQuery<Entitlement> listByOwner(Owner owner); CandlepinQuery<Entitlement> listByEnvironment(Environment environment); CandlepinQuery<Entitlement> listByEnvironment(String environmentId); CandlepinQuery<Entitlement> listByConsumerAndDate(Consumer consumer, Date activeOn); List<Entitlement> listDirty(Consumer consumer); Set<String> listEntitledProductIds(Consumer consumer, Pool pool); int markDependentEntitlementsDirty(Iterable<String> entitlementIds); Set<String> filterDistributorEntitlementIds(Iterable<String> entsIdsToFilter); @Transactional int markEntitlementsDirty(Iterable<String> entitlementIds); @Deprecated Map<Consumer, List<Entitlement>> getDistinctConsumers(List<Entitlement> entsToRevoke); @Transactional void delete(Entitlement entity); void batchDelete(Collection<Entitlement> entitlements); int batchDeleteByIds(Collection<String> entitlementIds); void unlinkEntitlements(Collection<Entitlement> entitlements); @Transactional Entitlement findByCertificateSerial(Long serial); @Transactional Entitlement replicate(Entitlement ent); @SuppressWarnings("unchecked") CandlepinQuery<Entitlement> findByStackId(Consumer consumer, String stackId); @SuppressWarnings("unchecked") CandlepinQuery<Entitlement> findByStackIds(Consumer consumer, Collection stackIds); @SuppressWarnings("unchecked") CandlepinQuery<Entitlement> findByPoolAttribute(Consumer consumer, String attributeName,
        String value); CandlepinQuery<Entitlement> findByPoolAttribute(String attributeName, String value); Entitlement findUpstreamEntitlementForStack(Consumer consumer, String stackId); Collection<String> getDependentEntitlementIdsForPools(Consumer consumer,
        Iterable<String> poolIds);  }
@Test public void listAllByOwner() { PageRequest req = createPageRequest(); EntitlementFilterBuilder filters = new EntitlementFilterBuilder(); Page<List<Entitlement>> entitlementPages = entitlementCurator.listByOwner(owner, null, filters, req); List<Entitlement> entitlements = entitlementPages.getPageData(); assertEquals(2, entitlements.size(), "should return all the entitlements:"); }
@Test public void listByOwnerWithPagingNoFiltering() { PageRequest req = createPageRequest(); req.setPerPage(1); EntitlementFilterBuilder filters = new EntitlementFilterBuilder(); Page<List<Entitlement>> entitlementPages = entitlementCurator.listByOwner(owner, null, filters, req); List<Entitlement> entitlements = entitlementPages.getPageData(); assertEquals(1, entitlements.size(), "should return only single entitlement per page:"); }
@Test public void listByOwnerWithPagingAndFiltering() { PageRequest req = createPageRequest(); EntitlementFilterBuilder filters = new EntitlementFilterBuilder(); filters.addAttributeFilter("pool_attr_1", "attr1"); Page<List<Entitlement>> entitlementPages = entitlementCurator.listByOwner(owner, null, filters, req); List<Entitlement> entitlements = entitlementPages.getPageData(); assertEquals(1, entitlements.size(), "should match only one out of two entitlements:"); Pool p = entitlements.get(0).getPool(); assertTrue(p.hasAttribute("pool_attr_1"), "Did not find ent by pool attribute 'pool_attr_1'"); assertEquals(p.getAttributeValue("pool_attr_1"), "attr1"); }