コード例 #1
0
  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;
  }
コード例 #2
0
ファイル: EntitlerTest.java プロジェクト: candlepin/candlepin
  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");
    }
  }