Entitler { public void sendEvents(List<Entitlement> entitlements) { if (entitlements != null) { for (Entitlement entitlement : entitlements) { Event event = evtFactory.entitlementCreated(entitlement); sink.queueEvent(event); } } } @Inject  Entitler(PoolManager pm, ConsumerCurator cc, I18n i18n, EventFactory evtFactory,
        EventSink sink, EntitlementRulesTranslator messageTranslator,
        EntitlementCurator entitlementCurator, Configuration config,
        OwnerCurator ownerCurator, PoolCurator poolCurator,
        ProductManager productManager, ProductServiceAdapter productAdapter, ContentManager contentManager,
        ConsumerTypeCurator ctc); List<Entitlement> bindByPoolQuantity(Consumer consumer, String poolId, Integer quantity); List<Entitlement> bindByPoolQuantities(String consumeruuid,
        Map<String, Integer> poolIdAndQuantities); List<Entitlement> bindByPoolQuantities(Consumer consumer,
        Map<String, Integer> poolIdAndQuantities); void adjustEntitlementQuantity(Consumer consumer, Entitlement ent,
        Integer quantity); List<Entitlement> bindByProducts(String[] productIds,
        String consumeruuid, Date entitleDate, Collection<String> fromPools); List<Entitlement> bindByProducts(AutobindData data); @Transactional List<Entitlement> bindByProducts(AutobindData data, boolean force); List<PoolQuantity> getDryRun(Consumer consumer, Owner owner,
        String serviceLevelOverride); int revokeUnmappedGuestEntitlements(Consumer consumer); int revokeUnmappedGuestEntitlements(); void sendEvents(List<Entitlement> entitlements);  }
@Test public void events() { List<Entitlement> ents = new ArrayList<>(); ents.add(mock(Entitlement.class)); ents.add(mock(Entitlement.class)); Event evt1 = mock(Event.class); Event evt2 = mock(Event.class); when(ef.entitlementCreated(any(Entitlement.class))) .thenReturn(evt1) .thenReturn(evt2); entitler.sendEvents(ents); verify(sink).queueEvent(eq(evt1)); verify(sink).queueEvent(eq(evt2)); }
@Test public void noEventsWhenEntitlementsNull() { entitler.sendEvents(null); verify(sink, never()).queueEvent(any(Event.class)); }
@Test public void noEventsWhenListEmpty() { List<Entitlement> ents = new ArrayList<>(); entitler.sendEvents(ents); verify(sink, never()).queueEvent(any(Event.class)); }