Examples of GuidedDTDRLPersistence


Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

        new String[] {"2", "desc", "", "39", "bob", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
    };



    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);


    assertTrue(drl.indexOf("from row number") > -1);
    assertTrue(drl.indexOf("rating == ( age * 0.2 )") > 0);
    assertTrue(drl.indexOf("f2 : Driver( eval( age > 7 ))") > 0);
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

                new String[] {"2", "desc", "", "39", "bob", "age * 0.3", "BAM", "6.60", "", "gooVal1", ""}
        };



        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
        String drl = p.marshal(dt);


        assertTrue(drl.indexOf("from row number") > -1);
        assertTrue(drl.indexOf("rating == ( age * 0.2 )") > 0);
        //assertTrue(drl.indexOf("f2 : Driver( eval( age > 7 ))") > 0);
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

                new String[] {"2", "desc", "", "39", "bob, frank", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
        };



        GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
        String drl = p.marshal(dt);


        assertTrue(drl.indexOf("name in (\"michael\",") > 0);
       

View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

       

    }

    public void testCellCSV() {
        GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
        assertEquals("(\"Michael\", \"Mark\", \"Peter\")", p.makeInList("Michael, Mark, Peter"));
        assertEquals("(\"Michael\")", p.makeInList("Michael"));
        assertEquals("(\"Michael\")", p.makeInList("\"Michael\""));
        assertEquals("(\"Michael\", \"Ma rk\", \"Peter\")", p.makeInList("Michael, \"Ma rk\", Peter"));
        assertEquals("(WEE WAAH)", p.makeInList("(WEE WAAH)"));
    }
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

        assertEquals("(WEE WAAH)", p.makeInList("(WEE WAAH)"));
    }


  public void testCellVal() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    assertFalse(p.validCell(null));
    assertFalse(p.validCell(""));
    assertFalse(p.validCell("  "));

  }
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

    assertFalse(p.validCell("  "));

  }

  public void testName() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    assertEquals("Row 42 XXX", p.getName("XXX", "42"));
    assertEquals("Row 42 YYY", p.getName("YYY", "42"));
  }
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

    assertEquals("Row 42 XXX", p.getName("XXX", "42"));
    assertEquals("Row 42 YYY", p.getName("YYY", "42"));
  }

  public void testAttribs() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] {"1", "desc", "a", ""};

    List<AttributeCol> attributeCols = new ArrayList<AttributeCol>();
    RuleModel rm = new RuleModel();
    RuleAttribute[] orig = rm.attributes;
    p.doAttribs(0,attributeCols, row, rm);

    assertSame(orig, rm.attributes);

    AttributeCol col1 = new AttributeCol();
    col1.attr = "salience";
    AttributeCol col2 = new AttributeCol();
    col2.attr = "agenda-group";
    attributeCols.add(col1);
    attributeCols.add(col2);

    p.doAttribs(0, attributeCols, row, rm);

    assertEquals(1, rm.attributes.length);
    assertEquals("salience", rm.attributes[0].attributeName);
    assertEquals("a", rm.attributes[0].value);

    row = new String[] {"1", "desc", "a", "b"};
    p.doAttribs(0, attributeCols, row, rm);
    assertEquals(2, rm.attributes.length);
    assertEquals("salience", rm.attributes[0].attributeName);
    assertEquals("a", rm.attributes[0].value);
    assertEquals("agenda-group", rm.attributes[1].attributeName);
    assertEquals("b", rm.attributes[1].value);
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

    assertEquals("b", rm.attributes[1].value);

  }

  public void testMetaData() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] {"1", "desc", "bar", ""};

    List<MetadataCol> metadataCols = new ArrayList<MetadataCol>();
    RuleModel rm = new RuleModel();
    RuleMetadata[] orig = rm.metadataList;
//    RuleAttribute[] orig = rm.attributes;
    p.doMetadata(metadataCols, row, rm);
//    p.doAttribs(0,metadataCols, row, rm);

    assertSame(orig, rm.metadataList);

    MetadataCol col1 = new MetadataCol();
    col1.attr = "foo";
    MetadataCol col2 = new MetadataCol();
    col2.attr = "foo2";
    metadataCols.add(col1);
    metadataCols.add(col2);

    p.doMetadata(metadataCols, row, rm);
//    p.doAttribs(0, metadataCols, row, rm);

    assertEquals(1, rm.metadataList.length);
    assertEquals("foo", rm.metadataList[0].attributeName);
    assertEquals("bar", rm.metadataList[0].value);

    row = new String[] {"1", "desc", "bar1", "bar2"};
    p.doMetadata(metadataCols, row, rm);
    assertEquals(2, rm.metadataList.length);
    assertEquals("foo", rm.metadataList[0].attributeName);
    assertEquals("bar1", rm.metadataList[0].value);
    assertEquals("foo2", rm.metadataList[1].attributeName);
    assertEquals("bar2", rm.metadataList[1].value);
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

    assertEquals("bar2", rm.metadataList[1].value);

  }

  public void testLHS() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] {"1", "desc", "a", "mike", "33 + 1", "age > 6", "stilton"};

    List<ConditionCol> cols = new ArrayList<ConditionCol>();
    ConditionCol col = new ConditionCol();
    col.boundName = "p1";
    col.factType = "Person";
    col.factField = "name";
    col.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
    col.operator = "==";
    cols.add(col);

    ConditionCol col2 = new ConditionCol();
    col2.boundName = "p1";
    col2.factType = "Person";
    col2.factField = "age";
    col2.constraintValueType = ISingleFieldConstraint.TYPE_RET_VALUE;
    col2.operator = "<";
    cols.add(col2);

    ConditionCol col3 = new ConditionCol();
    col3.boundName = "p1";
    col3.factType = "Person";
    col3.constraintValueType = ISingleFieldConstraint.TYPE_PREDICATE;
    cols.add(col3);

    ConditionCol col4 = new ConditionCol();
    col4.boundName = "c";
    col4.factType = "Cheese";
    col4.factField = "type";
    col4.operator = "==";
    col4.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
    cols.add(col4);

    RuleModel rm = new RuleModel();

    p.doConditions(1, cols, row, rm);
    assertEquals(2, rm.lhs.length);

    assertEquals("Person", ((FactPattern)rm.lhs[0]).factType);
    assertEquals("p1", ((FactPattern)rm.lhs[0]).boundName);
View Full Code Here

Examples of org.drools.ide.common.server.util.GuidedDTDRLPersistence

    assertEquals("stilton", cons.value);
    assertEquals(ISingleFieldConstraint.TYPE_LITERAL, cons.constraintValueType);
  }

  public void testRHS() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] {"1", "desc", "a", "a condition", "actionsetfield1", "actionsetfield2", "retract", "actioninsertfact1", "actioninsertfact2"};

    List<ActionCol> cols = new ArrayList<ActionCol>();
    ActionSetFieldCol asf1 = new ActionSetFieldCol();
    asf1.boundName = "a";
    asf1.factField = "field1";

    asf1.type = SuggestionCompletionEngine.TYPE_STRING;
    cols.add(asf1);

    ActionSetFieldCol asf2 = new ActionSetFieldCol();
    asf2.boundName = "a";
    asf2.factField = "field2";
    asf2.update = true;
    asf2.type = SuggestionCompletionEngine.TYPE_NUMERIC;
    cols.add(asf2);

    ActionRetractFactCol ret = new ActionRetractFactCol();
    ret.boundName = "ret";
    cols.add(ret);

    ActionInsertFactCol ins1 = new ActionInsertFactCol();
    ins1.boundName = "ins";
    ins1.factType = "Cheese";
    ins1.factField = "price";
    ins1.type = SuggestionCompletionEngine.TYPE_NUMERIC;
    cols.add(ins1);

    ActionInsertFactCol ins2 = new ActionInsertFactCol();
    ins2.boundName = "ins";
    ins2.factType = "Cheese";
    ins2.factField = "type";
    ins2.type = SuggestionCompletionEngine.TYPE_NUMERIC;
    cols.add(ins2);


    RuleModel rm = new RuleModel();
    p.doActions(2, cols, row, rm);
    assertEquals(3, rm.rhs.length);

    //examine the set field action that is produced
    ActionSetField a1 = (ActionSetField) rm.rhs[0];
    assertEquals("a", a1.variable);
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.