private Pool findPool(String poolId) {
    Pool pool = poolCurator.find(poolId);

    if (pool == null) {
      throw new BadRequestException(i18n.tr("Pool with id {0} could not be found.", poolId));
    }
    return pool;
  }
Example #2
0
  private void bindByPoolErrorTest(String msg) {
    try {
      String poolid = "pool10";
      Pool pool = mock(Pool.class);
      Map<String, ValidationResult> fakeResult = new HashMap<String, ValidationResult>();
      fakeResult.put(poolid, fakeOutResult(msg));
      EntitlementRefusedException ere = new EntitlementRefusedException(fakeResult);

      when(pool.getId()).thenReturn(poolid);
      when(poolCurator.find(eq(poolid))).thenReturn(pool);
      Map<String, Integer> pQs = new HashMap<String, Integer>();
      pQs.put(poolid, 1);
      when(pm.entitleByPools(eq(consumer), eq(pQs))).thenThrow(ere);
      entitler.bindByPoolQuantity(consumer, poolid, 1);
    } catch (EntitlementRefusedException e) {
      fail(msg + ": threw unexpected error");
    }
  }