Package org.springframework.rules.constraint

Examples of org.springframework.rules.constraint.Constraint


  }

  public void testMethodInvokingRule() {
    TestBean b = new TestBean();
    Constraint p = constraints.method(b, "isTooMuch", "max");
    assertTrue(p.test(new Integer(26)));
    assertFalse(p.test(new Integer(25)));
  }
View Full Code Here


    assertTrue(p.test(new Integer(26)));
    assertFalse(p.test(new Integer(25)));
  }

  public void testRegExpConstraint() {
    Constraint p = constraints.regexp("a*b");
    assertTrue(p.test("aaaaab"));
    assertFalse(p.test("bbbbbba"));
  }
 
View Full Code Here

    p.setZip("zip");
    assertTrue(r.test(p));
  }

  public void testMaxLengthConstraint() {
    Constraint p = new StringLengthConstraint(5);
    assertTrue(p.test(null));
    assertTrue(p.test(new Integer(12345)));
    assertFalse(p.test(new Integer(123456)));
    assertTrue(p.test("12345"));
    assertFalse(p.test("123456"));
  }
View Full Code Here

    assertTrue(p.test("12345"));
    assertFalse(p.test("123456"));
  }

  public void testMinLengthConstraint() {
    Constraint p = new StringLengthConstraint(RelationalOperator.GREATER_THAN_EQUAL_TO, 5);
    assertFalse(p.test(null));
    assertTrue(p.test(new Integer(12345)));
    assertFalse(p.test(new Integer(1234)));
    assertTrue(p.test("1234567890"));
    assertFalse(p.test("1234"));
  }
View Full Code Here

    assertTrue(p.test("1234567890"));
    assertFalse(p.test("1234"));
  }

  public void testRangeConstraint() {
    Constraint p = new Range(new Integer(0), new Integer(10));
    assertTrue(p.test(new Integer(0)));
    assertTrue(p.test(new Integer(10)));
    assertFalse(p.test(new Integer(-1)));
    assertFalse(p.test(new Integer(11)));
  }
View Full Code Here

    assertFalse(xor.test("12345"));
  }

  public void testNot() {
    Number n = new Integer("25");
    Constraint p = constraints.bind(EqualTo.instance(), n);
    Not not = new Not(p);
    assertTrue(not.test(new Integer(24)));
    assertFalse(not.test(new Integer("25")));
  }
View Full Code Here

  }

  void visit(And and) {
    Iterator it = and.iterator();
    while (it.hasNext()) {
      Constraint p = (Constraint) it.next();
      visitorSupport.invokeVisit(this, p);
    }
  }
View Full Code Here

  }

  void visit(Or or) {
    Iterator it = or.iterator();
    while (it.hasNext()) {
      Constraint p = (Constraint) it.next();
      visitorSupport.invokeVisit(this, p);
    }
  }
View Full Code Here

            throw new IllegalArgumentException(constraint.toString());
        }
    }

    public void pop(boolean result) {
        Constraint p = (Constraint)levels.pop();
        if (logger.isDebugEnabled()) {
            logger.debug("Top [" + p + "] popped; result was " + result
                    + "; stack now has " + levels.size() + " elements");
        }
        if (levels.isEmpty()) {
View Full Code Here

    collection.add("Item 2");
    collection.add("Item 3");
    collection.add("Item 4");
    collection.add("Item 5");
    IteratorTemplate template = new IteratorTemplate(collection.iterator());
    assertTrue(template.allTrue(new Constraint() {
      public boolean test(Object o) {
        return ((String)o).startsWith("Item");
      }
    }));
    try {
      assertEquals(false, template.allTrue(new Constraint() {
        public boolean test(Object o) {
          return ((String)o).startsWith("Element");
        }
      }));
      fail("Should have failed");
View Full Code Here

TOP

Related Classes of org.springframework.rules.constraint.Constraint

Copyright © 2018 www.massapicom. 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.