Package org.apache.ambari.server.controller.spi

Examples of org.apache.ambari.server.controller.spi.Predicate.evaluate()


        property(p2).equals("bar").or().property(p3).equals("cat").
        end().
        end().
        or().property(p4).equals("dog").toPredicate();

    Assert.assertTrue(predicate1.evaluate(resource));


    /*   (p1==fat && (p2==bar || p3==cat)) || p4 == dot   */
    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.
View Full Code Here


        property(p2).equals("bar").or().property(p3).equals("cat").
        end().
        end().
        or().property(p4).equals("dot").toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
  }


  @Test
  public void testUnbalancedBlocks() {
View Full Code Here

    /*   (p1==foo && p2==bar) || p3 == cat   */
    PredicateBuilder pb1 = new PredicateBuilder();
    Predicate predicate1 = pb1.begin().property("cat1/prop1").equals("foo").and().property("cat1/prop2").equals("bar").end().or().property("prop3").equals("cat").toPredicate();

    Assert.assertTrue(predicate1.evaluate(resource));
  }


  @Test
  public void testEqualsString() {
View Full Code Here

    resource.setProperty(p1, "foo");

    PredicateBuilder pb = new PredicateBuilder();
    Predicate predicate1 = pb.property(p1).equals("foo").toPredicate();

    Assert.assertTrue(predicate1.evaluate(resource));

    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.property(p1).equals("bar").toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
View Full Code Here

    Assert.assertTrue(predicate1.evaluate(resource));

    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.property(p1).equals("bar").toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
  }

  @Test
  public void testEqualsInteger() {
    String p1 = PropertyHelper.getPropertyId("cat1", "prop1");
View Full Code Here

    resource.setProperty(p1, 1);

    PredicateBuilder pb = new PredicateBuilder();
    Predicate predicate1 = pb.property(p1).equals(1).toPredicate();

    Assert.assertTrue(predicate1.evaluate(resource));

    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.property(p1).equals(99).toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
View Full Code Here

    Assert.assertTrue(predicate1.evaluate(resource));

    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.property(p1).equals(99).toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
  }

  @Test
  public void testEqualsFloat() {
    String p1 = PropertyHelper.getPropertyId("cat1", "prop1");
View Full Code Here

    resource.setProperty(p1, (float) 1);

    PredicateBuilder pb = new PredicateBuilder();
    Predicate predicate1 = pb.property(p1).equals(Float.valueOf(1)).toPredicate();

    Assert.assertTrue(predicate1.evaluate(resource));

    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.property(p1).equals(Float.valueOf(99)).toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
View Full Code Here

    Assert.assertTrue(predicate1.evaluate(resource));

    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.property(p1).equals(Float.valueOf(99)).toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
  }

  @Test
  public void testEqualsDouble() {
    String p1 = PropertyHelper.getPropertyId("cat1", "prop1");
View Full Code Here

    resource.setProperty(p1, 1.999);

    PredicateBuilder pb = new PredicateBuilder();
    Predicate predicate1 = pb.property(p1).equals(Double.valueOf(1.999)).toPredicate();

    Assert.assertTrue(predicate1.evaluate(resource));

    PredicateBuilder pb2 = new PredicateBuilder();
    Predicate predicate2 = pb2.property(p1).equals(Double.valueOf(99.998)).toPredicate();

    Assert.assertFalse(predicate2.evaluate(resource));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.