コード例 #1
0
  // This exception should mention wrapping a MissingFactException
  @Test(expected = RuleExecutionException.class)
  public void testRuleFailsWhenConsumerDoesntHaveFact() {
    Product product = new Product("a-product", "A product for testing");
    product.setAttribute(PRODUCT_CPULIMITED, "2");
    productCurator.create(product);

    when(this.productAdapter.getProductById("a-product")).thenReturn(product);

    ValidationResult result =
        enforcer.preEntitlement(
            TestUtil.createConsumer(),
            entitlementPoolWithMembersAndExpiration(owner, product, 1, 2, expiryDate(2000, 1, 1)),
            1);

    assertFalse(result.isSuccessful());
    assertTrue(result.hasErrors());
    assertFalse(result.hasWarnings());
  }