Beispiel #1
0
 @Test(expected = BadRequestException.class)
 public void nullPool() throws EntitlementRefusedException {
   String poolid = "foo";
   Consumer c = TestUtil.createConsumer(); // keeps me from casting null
   Map<String, Integer> pQs = new HashMap<String, Integer>();
   pQs.put(poolid, 1);
   when(cc.findByUuid(eq(c.getUuid()))).thenReturn(c);
   when(pm.entitleByPools(eq(c), eq(pQs))).thenThrow(new IllegalArgumentException());
   entitler.bindByPoolQuantities(c.getUuid(), pQs);
 }
Beispiel #2
0
  @Test
  public void bindByPoolString() throws EntitlementRefusedException {
    String poolid = "pool10";
    Entitlement ent = mock(Entitlement.class);
    List<Entitlement> eList = new ArrayList<Entitlement>();
    eList.add(ent);
    when(cc.findByUuid(eq("abcd1234"))).thenReturn(consumer);

    Map<String, Integer> pQs = new HashMap<String, Integer>();
    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));
  }