Package org.drools.factconstraints.server.predefined

Examples of org.drools.factconstraints.server.predefined.IntegerConstraint


 
  public Constraint buildConstraint(ConstraintConfiguration config) {
    if (NotNullConstraint.NAME.equals(config.getConstraintName())) {
      return new NotNullConstraint();
    } else if (IntegerConstraint.NAME.equals(config.getConstraintName())) {
      return new IntegerConstraint();
    } else if (RangeConstraint.NAME.equals(config.getConstraintName())) {
      return new RangeConstraint();
    } else if (NotMatchesConstraint.NAME.equals(config.getConstraintName())) {
      return new NotMatchesConstraint();
    }else if (MatchesConstraint.NAME.equals(config.getConstraintName())) {
View Full Code Here


        conf.setFieldName("age");
    }

    @Test
    public void testValidConstraint() {
      Constraint cons = new IntegerConstraint();
     
        ValidationResult result = cons.validate(12, conf);
        assertTrue(result.isSuccess());

        result = cons.validate(new Integer("12"), conf);
        assertTrue(result.isSuccess());

        result = cons.validate("12", conf);
        assertTrue(result.isSuccess());

    }
View Full Code Here

    }

    @Test
    public void testInvalidConstraint() {
      Constraint cons = new IntegerConstraint();
     
        ValidationResult result = cons.validate(new Object(), conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("", conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("ABC", conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(null, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(new Long("12"), conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(12L, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(12.8, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());
    }
View Full Code Here

        VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();

        //VerifierConfiguration conf = new DefaultVerifierConfiguration();
        VerifierConfiguration vconf = new VerifierConfigurationImpl();

        Constraint cons = new IntegerConstraint();
        vconf.getVerifyingResources().put(ResourceFactory.newByteArrayResource(cons.getVerifierRule(conf).getBytes()), ResourceType.DRL);

        Verifier verifier = vBuilder.newVerifier(vconf);

        verifier.addResourcesToVerify(ResourceFactory.newByteArrayResource(ruleToVerify.getBytes()),
                ResourceType.DRL);
View Full Code Here

        conf.setFieldName("age");
    }

    @Test
    public void testValidConstraint() {
      Constraint cons = new IntegerConstraint();
     
        ValidationResult result = cons.validate(12, conf);
        Assert.assertTrue(result.isSuccess());

        result = cons.validate(new Integer("12"), conf);
        Assert.assertTrue(result.isSuccess());

        result = cons.validate("12", conf);
        Assert.assertTrue(result.isSuccess());

    }
View Full Code Here

    }

    @Test
    public void testInvalidConstraint() {
      Constraint cons = new IntegerConstraint();
     
        ValidationResult result = cons.validate(new Object(), conf);
        Assert.assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("", conf);
        Assert.assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("ABC", conf);
        Assert.assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(null, conf);
        Assert.assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(new Long("12"), conf);
        Assert.assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(12L, conf);
        Assert.assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(12.8, conf);
        Assert.assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());
    }
View Full Code Here

        VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();

        //VerifierConfiguration conf = new DefaultVerifierConfiguration();
        VerifierConfiguration vconf = new VerifierConfigurationImpl();

        Constraint cons = new IntegerConstraint();
        vconf.getVerifyingResources().put(ResourceFactory.newByteArrayResource(cons.getVerifierRule(conf).getBytes()), ResourceType.DRL);

        Verifier verifier = vBuilder.newVerifier(vconf);

        verifier.addResourcesToVerify(ResourceFactory.newByteArrayResource(ruleToVerify.getBytes()),
                ResourceType.DRL);
View Full Code Here

TOP

Related Classes of org.drools.factconstraints.server.predefined.IntegerConstraint

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.