EntitlementCertificateGenerator { @Transactional public EntitlementCertificate generateEntitlementCertificate(Pool pool, Entitlement entitlement) { Map<String, Product> products = new HashMap<>(); Map<String, Entitlement> entitlements = new HashMap<>(); Map<String, PoolQuantity> poolQuantities = new HashMap<>(); products.put(pool.getId(), pool.getProduct()); entitlements.put(pool.getId(), entitlement); poolQuantities.put(pool.getId(), new PoolQuantity(pool, entitlement.getQuantity())); return this.generateEntitlementCertificates(entitlement.getConsumer(), products, poolQuantities, entitlements, true).get(pool.getId()); } @Inject  EntitlementCertificateGenerator(EntitlementCertificateCurator entitlementCertificateCurator,
        EntitlementCertServiceAdapter entCertServiceAdapter, EntitlementCurator entitlementCurator,
        PoolCurator poolCurator, EventSink eventSink, EventFactory eventFactory,
        ProductCurator productCurator, ContentAccessManager contentAccessManager,
        OwnerCurator ownerCurator); @Transactional Map<String, EntitlementCertificate> generateEntitlementCertificates(Consumer consumer,
        Map<String, Product> products, Map<String, PoolQuantity> poolQuantities,
        Map<String, Entitlement> entitlements, boolean save); @Transactional EntitlementCertificate generateEntitlementCertificate(Pool pool, Entitlement entitlement); @Transactional EntitlementCertificate generateEntitlementCertificate(Pool pool, Entitlement entitlement,
        boolean updateEntitlement); @Transactional void regenerateCertificatesOf(Entitlement entitlement, boolean lazy); @Transactional void regenerateCertificatesOf(Iterable<Entitlement> entitlements, boolean lazy); @Transactional void regenerateCertificatesByEntitlementIds(Iterable<String> entitlementIds, boolean lazy); @Transactional void regenerateCertificatesOf(Consumer consumer, boolean lazy); @Transactional void regenerateCertificatesOf(String environmentId, Collection<String> contentIds,
        boolean lazy); @Transactional void regenerateCertificatesOf(Owner owner, String productId, boolean lazy); @Transactional void regenerateCertificatesOf(Owner owner, Product product, boolean lazy); @Transactional void regenerateCertificatesOf(Collection<Owner> owners, Collection<Product> products,
        boolean lazy);  }
@Test public void testGenerateEntitlementCertificate() throws GeneralSecurityException, IOException { this.ecGenerator = new EntitlementCertificateGenerator(this.mockEntCertCurator, this.mockEntCertAdapter, this.mockEntitlementCurator, this.mockPoolCurator, this.mockEventSink, this.mockEventFactory, this.mockProductCurator, this.mockContentAccessManager, this.mockOwnerCurator); Consumer consumer = mock(Consumer.class); Pool pool = mock(Pool.class); Product product = mock(Product.class); when(pool.getId()).thenReturn("Swift"); when(pool.getProduct()).thenReturn(product); Entitlement entitlement = mock(Entitlement.class); when(entitlement.getConsumer()).thenReturn(consumer); Map<String, Product> expectedProducts = new HashMap<>(); expectedProducts.put("Swift", product); Map<String, Entitlement> expected = new HashMap<>(); expected.put("Swift", entitlement); Map<String, PoolQuantity> poolQuantityMap = new HashMap<>(); poolQuantityMap.put("Swift", new PoolQuantity(pool, 0)); ecGenerator.generateEntitlementCertificate(pool, entitlement); verify(mockEntCertAdapter).generateEntitlementCerts(eq(consumer), eq(poolQuantityMap), eq(expected), eq(expectedProducts), eq(true)); }