EntitlementCurator extends AbstractHibernateCurator<Entitlement> { public Set<String> filterDistributorEntitlementIds(Iterable<String> entsIdsToFilter) { Set<String> filteredIds = new HashSet<>(); if (entsIdsToFilter != null && entsIdsToFilter.iterator().hasNext()) { String querySql = "SELECT DISTINCT e.id " + "FROM Entitlement e, Consumer c, ConsumerType t " + "WHERE t.manifest = true AND c.typeId = t.id AND e.consumer = c AND e.id IN (:eids)"; Query query = this.getEntityManager().createQuery(querySql); int blockSize = Math.min(this.getInBlockSize(), this.getQueryParameterLimit()); for (List<String> block : Iterables.partition(entsIdsToFilter, blockSize)) { query.setParameter("eids", block); filteredIds.addAll(query.getResultList()); } } return filteredIds; } @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 testFilterOutDistributorEntitlements() { Product product = TestUtil.createProduct(); productCurator.create(product); Consumer distributor = createDistributor(owner); Pool pool = createPool(owner, product, 10L, dateSource.currentDate(), createFutureDate(1)); poolCurator.create(pool); Entitlement distributorEnt1 = bind(distributor, pool); Entitlement consumerEnt1 = bind(consumer, pool); List<String> entsToFilter = new LinkedList<>(); entsToFilter.add(distributorEnt1.getId()); entsToFilter.add(consumerEnt1.getId()); Set<String> filtered = entitlementCurator.filterDistributorEntitlementIds(entsToFilter); assertEquals(1, filtered.size()); assertTrue(filtered.contains(distributorEnt1.getId())); }