Entitler { public List<Entitlement> bindByPoolQuantities(String consumeruuid, Map<String, Integer> poolIdAndQuantities) throws EntitlementRefusedException { Consumer c = consumerCurator.findByUuid(consumeruuid); return bindByPoolQuantities(c, poolIdAndQuantities); } @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 bindByPoolString() throws EntitlementRefusedException { String poolid = "pool10"; Entitlement ent = mock(Entitlement.class); List<Entitlement> eList = new ArrayList<>(); eList.add(ent); when(cc.findByUuid(eq("abcd1234"))).thenReturn(consumer); Map<String, Integer> pQs = new HashMap<>(); pQs.put(poolid, 1); when(pm.entitleByPools(eq(consumer), eq(pQs))).thenReturn(eList); List<Entitlement> ents = entitler.bindByPoolQuantities("abcd1234", pQs); assertNotNull(ents); assertEquals(ent, ents.get(0)); }
@Test public void nullPool() throws EntitlementRefusedException { String poolid = "foo"; Consumer c = TestUtil.createConsumer(); Map<String, Integer> pQs = new HashMap<>(); pQs.put(poolid, 1); when(cc.findByUuid(eq(c.getUuid()))).thenReturn(c); when(pm.entitleByPools(eq(c), eq(pQs))).thenThrow(new IllegalArgumentException()); assertThrows(BadRequestException.class, () -> entitler.bindByPoolQuantities(c.getUuid(), pQs)); }