Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Copyright 2010 JBoss Inc
    * 
    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
    * use this file except in compliance with the License. You may obtain a copy of
    * the License at
    * 
    * http://www.apache.org/licenses/LICENSE-2.0
    * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   * License for the specific language governing permissions and limitations under
   * the License.
   */
  
  package org.drools.workbench.models.guided.dtable.backend;
  
  import java.util.List;
  
  import org.junit.Test;
  
  import static org.junit.Assert.*;
  
  public class GuidedDTDRLPersistenceTest {
  
      @Test
      public void test2Rules() throws Exception {
          GuidedDecisionTable52 dt = new GuidedDecisionTable52();
  
          dt.setTableName"michael" );
  
          AttributeCol52 attr = new AttributeCol52();
          attr.setAttribute"salience" );
          attr.setDefaultValuenew DTCellValue52"66" ) );
          dt.getAttributeCols().addattr );
  
          Pattern52 p1 = new Pattern52();
          p1.setBoundName"f1" );
          p1.setFactType"Driver" );
  
          ConditionCol52 con = new ConditionCol52();
          con.setFactField"age" );
          con.setHeader"Driver f1 age" );
          con.setOperator"==" );
          p1.getChildColumns().addcon );
  
         ConditionCol52 con2 = new ConditionCol52();
         con2.setFactField"name" );
         con2.setHeader"Driver f1 name" );
         con2.setOperator"==" );
         p1.getChildColumns().addcon2 );
 
         ConditionCol52 con3 = new ConditionCol52();
         con3.setFactField"rating" );
         con3.setHeader"Driver rating" );
         con3.setOperator"==" );
         p1.getChildColumns().addcon3 );
 
         dt.getConditions().addp1 );
 
         Pattern52 p2 = new Pattern52();
         p2.setBoundName"f2" );
         p2.setFactType"Driver" );
 
         ConditionCol52 con4 = new ConditionCol52();
         con4.setHeader"Driver 2 pimp" );
         con4.setFactField"(not needed)" );
         p2.getChildColumns().addcon4 );
 
         dt.getConditions().addp2 );
 
         ActionInsertFactCol52 ins = new ActionInsertFactCol52();
         ins.setBoundName"ins" );
         ins.setFactType"Cheese" );
         ins.setFactField"price" );
         ins.setType. );
         dt.getActionCols().addins );
 
         ActionRetractFactCol52 ret = new ActionRetractFactCol52();
         dt.getActionCols().addret );
 
         ActionSetFieldCol52 set = new ActionSetFieldCol52();
         set.setBoundName"f1" );
         set.setFactField"goo1" );
         set.setType. );
         dt.getActionCols().addset );
 
         ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
         set2.setBoundName"f1" );
         set2.setFactField"goo2" );
         set2.setDefaultValuenew DTCellValue52"whee" ) );
         set2.setType. );
         dt.getActionCols().addset2 );
 
         dt.setData( DataUtilities.makeDataListsnew String[][]{
                 new String[]{ "1""desc""42""33""michael""age * 0.2""age > 7""6.60""true""gooVal1""f2" },
                 new String[]{ "2""desc""66""39""bob""age * 0.3""age > 7""6.60""""gooVal1""whee" }
         } ) );
 
         GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
         String drl = p.marshaldt );
 
         assertTruedrl.indexOf"from row number" ) > -1 );
         assertTruedrl.indexOf"rating == ( age * 0.2 )" ) > 0 );
         assertTruedrl.indexOf"f2 : Driver( eval( age > 7 ))" ) > 0 );
         assertTruedrl.indexOf"rating == ( age * 0.3 )" ) > drl.indexOf"rating == ( age * 0.2 )" ) );
         assertTruedrl.indexOf"f1.setGoo2( \"whee\" )" ) > 0 );
         assertTruedrl.indexOf"salience 66" ) > 0 );
     }
 
     @Test
     public void testAttribs() {
         GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
         String[] row = new String[]{ "1""desc""a""" };
 
         List<BaseColumnallColumns = new ArrayList<BaseColumn>();
         allColumns.addnew RowNumberCol52() );
         allColumns.addnew DescriptionCol52() );
         List<AttributeCol52attributeCols = new ArrayList<AttributeCol52>();
 
         RuleModel rm = new RuleModel();
         RuleAttribute[] orig = rm.attributes;
         p.doAttribsallColumns,
                      attributeCols,
                      DataUtilities.makeDataRowListrow ),
                      rm );
 
         assertSameorig,
                     rm.attributes );
 
         AttributeCol52 col1 = new AttributeCol52();
         col1.setAttribute"salience" );
         AttributeCol52 col2 = new AttributeCol52();
         col2.setAttribute"agenda-group" );
         attributeCols.addcol1 );
         attributeCols.addcol2 );
         allColumns.addAllattributeCols );
 
         p.doAttribsallColumns,
                      attributeCols,
                      DataUtilities.makeDataRowListrow ),
                      rm );
 
         assertEquals( 1,
                       rm.attributes.length );
         assertEquals"salience",
                       rm.attributes[ 0 ].getAttributeName() );
         assertEquals"a",
                       rm.attributes[ 0 ].getValue() );
 
         row = new String[]{ "1""desc""a""b" };
         p.doAttribsallColumns,
                      attributeCols,
                      DataUtilities.makeDataRowListrow ),
                      rm );
         assertEquals( 2,
                       rm.attributes.length );
         assertEquals"salience",
                       rm.attributes[ 0 ].getAttributeName() );
         assertEquals"a",
                       rm.attributes[ 0 ].getValue() );
         assertEquals"agenda-group",
                       rm.attributes[ 1 ].getAttributeName() );
         assertEquals"b",
                       rm.attributes[ 1 ].getValue() );
 
     }
 
     @Test
     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)" ) );
     }
 
     @Test
     public void testCellVal() {
         GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
         assertFalsep.validCellnull ) );
         assertFalsep.validCell"" ) );
         assertFalsep.validCell"  " ) );
     }
 
     @Test
     public void testInOperator() {
         GuidedDecisionTable52 dt = new GuidedDecisionTable52();
         dt.setTableName"michael" );
 
         AttributeCol52 attr = new AttributeCol52();
         attr.setAttribute"salience" );
         attr.setDefaultValuenew DTCellValue52"66" ) );
         dt.getAttributeCols().addattr );
 
         Pattern52 p1 = new Pattern52();
         p1.setBoundName"f1" );
         p1.setFactType"Driver" );
 
         ConditionCol52 con = new ConditionCol52();
         con.setFactField"age" );
         con.setHeader"Driver f1 age" );
         con.setOperator"==" );
         p1.getChildColumns().addcon );
 
         ConditionCol52 con2 = new ConditionCol52();
         con2.setFactField"name" );
         con2.setHeader"Driver f1 name" );
         con2.setOperator"in" );
         p1.getChildColumns().addcon2 );
 
         ConditionCol52 con3 = new ConditionCol52();
         con3.setFactField"rating" );
         con3.setHeader"Driver rating" );
         con3.setOperator"==" );
         p1.getChildColumns().addcon3 );
 
         ConditionCol52 con4 = new ConditionCol52();
         con4.setHeader"Driver 2 pimp" );
         con4.setFactField"(not needed)" );
         p1.getChildColumns().addcon4 );
 
         dt.getConditions().addp1 );
 
         ActionInsertFactCol52 ins = new ActionInsertFactCol52();
         ins.setBoundName"ins" );
         ins.setFactType"Cheese" );
         ins.setFactField"price" );
         ins.setType. );
         dt.getActionCols().addins );
 
         ActionRetractFactCol52 ret = new ActionRetractFactCol52();
         dt.getActionCols().addret );
 
         ActionSetFieldCol52 set = new ActionSetFieldCol52();
         set.setBoundName"f1" );
         set.setFactField"goo1" );
         set.setType. );
         dt.getActionCols().addset );
 
         ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
         set2.setBoundName"f1" );
         set2.setFactField"goo2" );
         set2.setDefaultValuenew DTCellValue52"whee" ) );
         set2.setType. );
         dt.getActionCols().addset2 );
 
         dt.setData( DataUtilities.makeDataListsnew String[][]{
                 new String[]{ "1""desc""42""33""michael, manik""age * 0.2""age > 7""6.60""true""gooVal1""f2" },
                 new String[]{ "2""desc""""39""bob, frank""age * 0.3""age > 7""6.60""""gooVal1"null }
         } ) );
 
         GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
         String drl = p.marshaldt );
 
         assertTruedrl.indexOf"name in ( \"michael\"," ) > 0 );
 
     }
 
     @Test
     public void testInterpolate() {
         GuidedDecisionTable52 dt = new GuidedDecisionTable52();
         dt.setTableName"michael" );
 
         AttributeCol52 attr = new AttributeCol52();
         attr.setAttribute"salience" );
         attr.setDefaultValuenew DTCellValue52"66" ) );
         dt.getAttributeCols().addattr );
 
         Pattern52 p1 = new Pattern52();
         p1.setBoundName"f1" );
         p1.setFactType"Driver" );
 
         ConditionCol52 con = new ConditionCol52();
         con.setFactField"age" );
         con.setHeader"Driver f1 age" );
         con.setOperator"==" );
         p1.getChildColumns().addcon );
 
         ConditionCol52 con2 = new ConditionCol52();
         con2.setFactField"name" );
         con2.setHeader"Driver f1 name" );
         con2.setOperator"==" );
         p1.getChildColumns().addcon2 );
 
         ConditionCol52 con3 = new ConditionCol52();
         con3.setFactField"rating" );
         con3.setHeader"Driver rating" );
         con3.setOperator"==" );
         p1.getChildColumns().addcon3 );
 
         dt.getConditions().addp1 );
 
         Pattern52 p2 = new Pattern52();
         p2.setBoundName"f2" );
         p2.setFactType"Driver" );
 
         ConditionCol52 con4 = new ConditionCol52();
         con4.setHeader"Driver 2 pimp" );
         con4.setFactField"this.hasSomething($param)" );
         p2.getChildColumns().addcon4 );
 
         dt.getConditions().addp2 );
 
         ActionInsertFactCol52 ins = new ActionInsertFactCol52();
         ins.setBoundName"ins" );
         ins.setFactType"Cheese" );
         ins.setFactField"price" );
         ins.setType. );
         dt.getActionCols().addins );
 
         ActionRetractFactCol52 ret = new ActionRetractFactCol52();
         dt.getActionCols().addret );
 
         ActionSetFieldCol52 set = new ActionSetFieldCol52();
         set.setBoundName"f1" );
         set.setFactField"goo1" );
         set.setType. );
         dt.getActionCols().addset );
 
         ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
         set2.setBoundName"f1" );
         set2.setFactField"goo2" );
         set2.setDefaultValuenew DTCellValue52"whee" ) );
         set2.setType. );
         dt.getActionCols().addset2 );
 
         dt.setData( DataUtilities.makeDataListsnew String[][]{
                 new String[]{ "1""desc""42""33""michael""age * 0.2""BAM""6.60""true""gooVal1""f2" },
                 new String[]{ "2""desc""66""39""bob""age * 0.3""BAM""6.60""""gooVal1""whee" }
         } ) );
 
         GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
         String drl = p.marshaldt );
 
         assertTruedrl.indexOf"from row number" ) > -1 );
         assertTruedrl.indexOf"rating == ( age * 0.2 )" ) > 0 );
         assertTruedrl.indexOf"f2 : Driver( eval( this.hasSomething(BAM) ))" ) > 0 );
         assertTruedrl.indexOf"rating == ( age * 0.3 )" ) > drl.indexOf"rating == ( age * 0.2 )" ) );
         assertTruedrl.indexOf"f1.setGoo2( \"whee\" )" ) > 0 );
         assertTruedrl.indexOf"salience 66" ) > 0 );
     }
 
     @Test
     public void testLHS() {
         GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
         String[] row = new String[]{ "1""desc""a""mike""33 + 1""age > 6""stilton" };
         String[][] data = new String[ 1 ][];
         data[ 0 ] = row;
 
         List<BaseColumnallColumns = new ArrayList<BaseColumn>();
         List<CompositeColumn<? extends BaseColumn>> allPatterns = new ArrayList<CompositeColumn<? extends BaseColumn>>();
         allColumns.addnew RowNumberCol52() );
         allColumns.addnew DescriptionCol52() );
         allColumns.addnew MetadataCol52() );
 
         Pattern52 p1 = new Pattern52();
         p1.setBoundName"p1" );
         p1.setFactType"Person" );
         allPatterns.addp1 );
 
         ConditionCol52 col = new ConditionCol52();
         col.setFactField"name" );
         col.setOperator"==" );
         p1.getChildColumns().addcol );
         allColumns.addcol );
 
         ConditionCol52 col2 = new ConditionCol52();
         col2.setFactField"age" );
         col2.setOperator"<" );
         p1.getChildColumns().addcol2 );
         allColumns.addcol2 );
 
         ConditionCol52 col3 = new ConditionCol52();
         p1.getChildColumns().addcol3 );
         allColumns.addcol3 );
 
         Pattern52 p2 = new Pattern52();
         p2.setBoundName"c" );
         p2.setFactType"Cheese" );
         allPatterns.addp2 );
 
         ConditionCol52 col4 = new ConditionCol52();
         col4.setFactField"type" );
         col4.setOperator"==" );
         p2.getChildColumns().addcol4 );
         allColumns.addcol4 );
 
         RuleModel rm = new RuleModel();
 
         //When using a TemplateDataProvider the assumption is that we 
         //have a "complete" decision table including AnalysisCol52
         allColumns.addnew AnalysisCol52() );
 
         List<DTCellValue52rowData = DataUtilities.makeDataRowListrow );
         TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProviderallColumns,
                                                                                  rowData );
 
         p.doConditionsallColumns,
                         allPatterns,
                         rowDataProvider,
                         rowData,
                         DataUtilities.makeDataListsdata ),
                         rm );
         assertEquals( 2,
                       rm.lhs.length );
 
         assertEquals"Person",
                       ( (FactPatternrm.lhs[ 0 ] ).getFactType() );
         assertEquals"p1",
                       ( (FactPatternrm.lhs[ 0 ] ).getBoundName() );
 
         assertEquals"Cheese",
                       ( (FactPatternrm.lhs[ 1 ] ).getFactType() );
         assertEquals"c",
                       ( (FactPatternrm.lhs[ 1 ] ).getBoundName() );
 
         // examine the first pattern
         FactPattern person = (FactPatternrm.lhs[ 0 ];
         assertEquals( 3,
                       person.getConstraintList().getConstraints().length );
         SingleFieldConstraint cons = (SingleFieldConstraintperson.getConstraint( 0 );
                       cons.getConstraintValueType() );
         assertEquals"name",
                       cons.getFieldName() );
         assertEquals"==",
                       cons.getOperator() );
         assertEquals"mike",
                       cons.getValue() );
 
         cons = (SingleFieldConstraintperson.getConstraint( 1 );
                       cons.getConstraintValueType() );
         assertEquals"age",
                       cons.getFieldName() );
         assertEquals"<",
                       cons.getOperator() );
         assertEquals"33 + 1",
                       cons.getValue() );
 
         cons = (SingleFieldConstraintperson.getConstraint( 2 );
                       cons.getConstraintValueType() );
         assertEquals"age > 6",
                       cons.getValue() );
 
         // examine the second pattern
         FactPattern cheese = (FactPatternrm.lhs[ 1 ];
         assertEquals( 1,
                       cheese.getConstraintList().getConstraints().length );
         cons = (SingleFieldConstraintcheese.getConstraint( 0 );
         assertEquals"type",
                       cons.getFieldName() );
         assertEquals"==",
                       cons.getOperator() );
         assertEquals"stilton",
                       cons.getValue() );
                       cons.getConstraintValueType() );
     }
 
     @Test
     public void testLHSBindings() {
         GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
         String[] row = new String[]{ "1""desc""mike""33 + 1""age > 6" };
         String[][] data = new String[ 1 ][];
         data[ 0 ] = row;
 
         List<BaseColumnallColumns = new ArrayList<BaseColumn>();
         List<CompositeColumn<? extends BaseColumn>> allPatterns = new ArrayList<CompositeColumn<? extends BaseColumn>>();
         allColumns.addnew RowNumberCol52() );
         allColumns.addnew DescriptionCol52() );
 
         Pattern52 p1 = new Pattern52();
         p1.setBoundName"p1" );
         p1.setFactType"Person" );
         allPatterns.addp1 );
 
         ConditionCol52 col = new ConditionCol52();
         col.setFactField"name" );
         col.setOperator"==" );
         col.setBinding"$name" );
         p1.getChildColumns().addcol );
         allColumns.addcol );
 
         ConditionCol52 col2 = new ConditionCol52();
         col2.setFactField"age" );
         col2.setOperator"<" );
         col2.setBinding"$name" );
         p1.getChildColumns().addcol2 );
         allColumns.addcol2 );
 
         ConditionCol52 col3 = new ConditionCol52();
         col3.setBinding"$name" );
         p1.getChildColumns().addcol3 );
         allColumns.addcol3 );
 
         //When using a TemplateDataProvider the assumption is that we 
         //have a "complete" decision table including AnalysisCol52
         allColumns.addnew AnalysisCol52() );
 
         List<DTCellValue52rowData = DataUtilities.makeDataRowListrow );
         TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProviderallColumns,
                                                                                  rowData );
 
         RuleModel rm = new RuleModel();
 
         p.doConditionsallColumns,
                         allPatterns,
                         rowDataProvider,
                         rowData,
                         DataUtilities.makeDataListsdata ),
                         rm );
         assertEquals( 1,
                       rm.lhs.length );
 
         assertEquals"Person",
                       ( (FactPatternrm.lhs[ 0 ] ).getFactType() );
         assertEquals"p1",
                       ( (FactPatternrm.lhs[ 0 ] ).getBoundName() );
 
         // examine the first pattern
         FactPattern person = (FactPatternrm.lhs[ 0 ];
         assertEquals( 3,
                       person.getConstraintList().getConstraints().length );
 
         SingleFieldConstraint cons = (SingleFieldConstraintperson.getConstraint( 0 );
                       cons.getConstraintValueType() );
         assertEquals"name",
                       cons.getFieldName() );
         assertEquals"==",
                       cons.getOperator() );
         assertEquals"mike",
                       cons.getValue() );
         assertEquals"$name",
                       cons.getFieldBinding() );
 
         cons = (SingleFieldConstraintperson.getConstraint( 1 );
                       cons.getConstraintValueType() );
         assertEquals"age",
                       cons.getFieldName() );
         assertEquals"<",
                       cons.getOperator() );
         assertEquals"33 + 1",
                       cons.getValue() );
         assertNullcons.getFieldBinding() );
 
         cons = (SingleFieldConstraintperson.getConstraint( 2 );
                       cons.getConstraintValueType() );
         assertEquals"age > 6",
                       cons.getValue() );
         assertNullcons.getFieldBinding() );
 
     }
 
     @Test
     public void testLHSNotPattern() {
         GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
         String[] row = new String[]{ "1""desc""a""mike""33 + 1""age > 6""stilton" };
         String[][] data = new String[ 1 ][];
         data[ 0 ] = row;
 
         List<BaseColumnallColumns = new ArrayList<BaseColumn>();
         List<CompositeColumn<? extends BaseColumn>> allPatterns = new ArrayList<CompositeColumn<? extends BaseColumn>>();
         allColumns.addnew RowNumberCol52() );
         allColumns.addnew DescriptionCol52() );
         allColumns.addnew MetadataCol52() );
 
         Pattern52 p1 = new Pattern52();
         p1.setNegatedtrue );
         p1.setBoundName"p1" );
         p1.setFactType"Person" );
         allPatterns.addp1 );
 
         ConditionCol52 col = new ConditionCol52();
         col.setFactField"name" );
         col.setOperator"==" );
         p1.getChildColumns().addcol );
         allColumns.addcol );
 
         ConditionCol52 col2 = new ConditionCol52();
         col2.setFactField"age" );
         col2.setOperator"<" );
         p1.getChildColumns().addcol2 );
         allColumns.addcol2 );
 
         ConditionCol52 col3 = new ConditionCol52();
         p1.getChildColumns().addcol3 );
         allColumns.addcol3 );
 
         Pattern52 p2 = new Pattern52();
         p2.setBoundName"c" );
         p2.setFactType"Cheese" );
         allPatterns.addp2 );
 
         ConditionCol52 col4 = new ConditionCol52();
         col4.setFactField"type" );
         col4.setOperator"==" );
         p2.getChildColumns().addcol4 );
         allColumns.addcol4 );
 
         //When using a TemplateDataProvider the assumption is that we 
         //have a "complete" decision table including AnalysisCol52
         allColumns.addnew AnalysisCol52() );
 
         List<DTCellValue52rowData = DataUtilities.makeDataRowListrow );
         TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProviderallColumns,
                                                                                  rowData );
 
         RuleModel rm = new RuleModel();
 
         p.doConditionsallColumns,
                         allPatterns,
                         rowDataProvider,
                         rowData,
                         DataUtilities.makeDataListsdata ),
                         rm );
 
         String drl = BRDRLPersistence.getInstance().marshalrm );
 
         assertEquals( 2,
                       rm.lhs.length );
 
         assertEquals"Person",
                       ( (FactPatternrm.lhs[ 0 ] ).getFactType() );
         assertEquals"p1",
                       ( (FactPatternrm.lhs[ 0 ] ).getBoundName() );
 
         assertEquals"Cheese",
                       ( (FactPatternrm.lhs[ 1 ] ).getFactType() );
         assertEquals"c",
                       ( (FactPatternrm.lhs[ 1 ] ).getBoundName() );
 
         // examine the first pattern
         FactPattern person = (FactPatternrm.lhs[ 0 ];
         assertEquals( 3,
                       person.getConstraintList().getConstraints().length );
         SingleFieldConstraint cons = (SingleFieldConstraintperson.getConstraint( 0 );
                       cons.getConstraintValueType() );
         assertEquals"name",
                       cons.getFieldName() );
         assertEquals"==",
                       cons.getOperator() );
         assertEquals"mike",
                       cons.getValue() );
 
         cons = (SingleFieldConstraintperson.getConstraint( 1 );
                       cons.getConstraintValueType() );
         assertEquals"age",
                       cons.getFieldName() );
         assertEquals"<",
                       cons.getOperator() );
         assertEquals"33 + 1",
                       cons.getValue() );
 
         cons = (SingleFieldConstraintperson.getConstraint( 2 );
                       cons.getConstraintValueType() );
         assertEquals"age > 6",
                       cons.getValue() );
 
         assertEqualsperson.isNegated(),
                       true );
 
         assertTruedrl.indexOf"not Person(" ) > 0 );
 
         // examine the second pattern
         FactPattern cheese = (FactPatternrm.lhs[ 1 ];
         assertEquals( 1,
                       cheese.getConstraintList().getConstraints().length );
         cons = (SingleFieldConstraintcheese.getConstraint( 0 );
         assertEquals"type",
                       cons.getFieldName() );
         assertEquals"==",
                       cons.getOperator() );
         assertEquals"stilton",
                       cons.getValue() );
                       cons.getConstraintValueType() );
 
         assertEqualscheese.isNegated(),
                       false );
 
         assertTruedrl.indexOf"c : Cheese(" ) > 0 );
 
     }
 
     @Test
     public void testLHSOtherwisePatternBoolean() {
         GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
         String[][] row = new String[ 2 ][];
         String[][] data = new String[ 2 ][];
         row[ 0 ] = new String[]{ "1""desc1""true""false" };
         List<DTCellValue52rowDTModel0 = DataUtilities.makeDataRowListrow[ 0 ] );
         data[ 0 ] = row[ 0 ];
 
         row[ 1 ] = new String[]{ "3""desc3"nullnull };
         List<DTCellValue52rowDTModel1 = DataUtilities.makeDataRowListrow[ 1 ] );
         rowDTModel1.get( 2 ).setOtherwisetrue );
         rowDTModel1.get( 3 ).setOtherwisetrue );
         data[ 1 ] = row[ 1 ];
 
         List<BaseColumnallColumns = new ArrayList<BaseColumn>();
         List<CompositeColumn<? extends BaseColumn>> allPatterns = new ArrayList<CompositeColumn<? extends BaseColumn>>();
         allColumns.addnew RowNumberCol52() );
         allColumns.addnew DescriptionCol52() );
 
         Pattern52 p1 = new Pattern52();
         p1.setBoundName"p1" );
         p1.setFactType"Person" );
         allPatterns.addp1 );
 
         ConditionCol52 col = new ConditionCol52();
         col.setFactField"alive" );
         col.setFieldType. );
         col.setOperator"==" );
         p1.getChildColumns().addcol );
         allColumns.addcol );
 
         Pattern52 p2 = new Pattern52();
         p2.setBoundName"p2" );
         p2.setFactType"Person" );
         allPatterns.addp2 );
 
         ConditionCol52 col2 = new ConditionCol52();
         col2.setFactField"alive" );
         col2.setFieldType. );
         col2.setOperator"!=" );
         p2.getChildColumns().addcol2 );
         allColumns.addcol2 );
 
         RuleModel rm = new RuleModel();
 
         //When using a TemplateDataProvider the assumption is that we 
         //have a "complete" decision table including AnalysisCol52
         allColumns.addnew AnalysisCol52() );
 
         TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProviderallColumns,
                                                                                   rowDTModel0 );
 
         p.doConditionsallColumns,
                         allPatterns,
                         rowDataProvider0,
                         rowDTModel0,
                         DataUtilities.makeDataListsdata ),
                         rm );
         String drl0 = BRDRLPersistence.getInstance().marshalrm );
 
         assertEquals( 2,
                       rm.lhs.length );
         assertEquals"Person",
                       ( (FactPatternrm.lhs[ 0 ] ).getFactType() );
         assertEquals"p1",
                       ( (FactPatternrm.lhs[ 0 ] ).getBoundName() );
 
         assertEquals"Person",
                       ( (FactPatternrm.lhs[ 1 ] ).getFactType() );
         assertEquals"p2",
                       ( (FactPatternrm.lhs[ 1 ] ).getBoundName() );
         assertTruedrl0.indexOf"p1 : Person( alive == true )" ) > 0 );
         assertTruedrl0.indexOf"p2 : Person( alive != false )" ) > 0 );
 
         TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProviderallColumns,
                                                                                   rowDTModel1 );
 
         p.doConditionsallColumns,
                         allPatterns,
                         rowDataProvider1,
                         rowDTModel1,
                         DataUtilities.makeDataListsdata ),
                         rm );
         String drl1 = BRDRLPersistence.getInstance().marshalrm );
 
         assertEquals( 2,
                       rm.lhs.length );
         assertEquals"Person",
                       ( (FactPatternrm.lhs[ 0 ] ).getFactType() );
         assertEquals"p1",
                       ( (FactPatternrm.lhs[ 0 ] ).getBoundName() );
 
         assertEquals"Person",
                       ( (FactPatternrm.lhs[ 1 ] ).getFactType() );
         assertEquals"p2",
                       ( (FactPatternrm.lhs[ 1 ] ).getBoundName() );
         assertTruedrl1.indexOf"p1 : Person( alive not in ( true )" ) > 0 );
         assertTruedrl1.indexOf"p2 : Person( alive in ( false )" ) > 0 );
 
     }
 
     @Test
     public void testLHSOtherwisePatternDate() {
<