con4.setFactType( "Driver" );
con4.setHeader( "Driver 2 pimp" );
con4.setFactField( "(not needed)" );
dt.getConditionCols().add( con4 );
ActionInsertFactCol ins = new ActionInsertFactCol();
ins.setBoundName( "ins" );
ins.setFactType( "Cheese" );
ins.setFactField( "price" );
ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
dt.getActionCols().add( ins );
ActionRetractFactCol ret = new ActionRetractFactCol();
ret.setBoundName( "f2" );
dt.getActionCols().add( ret );
ActionSetFieldCol set = new ActionSetFieldCol();
set.setBoundName( "f1" );
set.setFactField( "goo1" );
set.setType( SuggestionCompletionEngine.TYPE_STRING );
dt.getActionCols().add( set );
ActionSetFieldCol set2 = new ActionSetFieldCol();
set2.setBoundName( "f1" );
set2.setFactField( "goo2" );
set2.setDefaultValue( "whee" );
set2.setType( SuggestionCompletionEngine.TYPE_STRING );
dt.getActionCols().add( set2 );
dt.setData( new String[][]{
new String[]{"1", "desc", "42", "33", "michael", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", null},
new String[]{"2", "desc", "", "39", "bob", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
} );
TypeSafeGuidedDecisionTable tsdt = RepositoryUpgradeHelper.convertGuidedDTModel( dt );
assertEquals( "michael",
tsdt.getTableName() );
assertEquals( 1,
tsdt.getMetadataCols().size() );
assertEquals( "legacy",
tsdt.getMetadataCols().get( 0 ).getMetadata() );
assertEquals( "yes",
tsdt.getMetadataCols().get( 0 ).getDefaultValue() );
assertEquals( 1,
tsdt.getAttributeCols().size() );
assertEquals( "salience",
tsdt.getAttributeCols().get( 0 ).getAttribute() );
assertEquals( "66",
tsdt.getAttributeCols().get( 0 ).getDefaultValue() );
assertEquals( 4,
tsdt.getConditionCols().size() );
assertEquals( "f1",
tsdt.getConditionCols().get( 0 ).getBoundName() );
assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
tsdt.getConditionCols().get( 0 ).getConstraintValueType() );
assertEquals( "age",
tsdt.getConditionCols().get( 0 ).getFactField() );
assertEquals( "Driver",
tsdt.getConditionCols().get( 0 ).getFactType() );
assertEquals( "Driver f1 age",
tsdt.getConditionCols().get( 0 ).getHeader() );
assertEquals( "==",
tsdt.getConditionCols().get( 0 ).getOperator() );
assertEquals( "f1",
tsdt.getConditionCols().get( 1 ).getBoundName() );
assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
tsdt.getConditionCols().get( 1 ).getConstraintValueType() );
assertEquals( "name",
tsdt.getConditionCols().get( 1 ).getFactField() );
assertEquals( "Driver",
tsdt.getConditionCols().get( 1 ).getFactType() );
assertEquals( "Driver f1 name",
tsdt.getConditionCols().get( 1 ).getHeader() );
assertEquals( "==",
tsdt.getConditionCols().get( 1 ).getOperator() );
assertEquals( "f1",
tsdt.getConditionCols().get( 2 ).getBoundName() );
assertEquals( BaseSingleFieldConstraint.TYPE_RET_VALUE,
tsdt.getConditionCols().get( 2 ).getConstraintValueType() );
assertEquals( "rating",
tsdt.getConditionCols().get( 2 ).getFactField() );
assertEquals( "Driver",
tsdt.getConditionCols().get( 2 ).getFactType() );
assertEquals( "Driver rating",
tsdt.getConditionCols().get( 2 ).getHeader() );
assertEquals( "==",
tsdt.getConditionCols().get( 2 ).getOperator() );
assertEquals( "f2",
tsdt.getConditionCols().get( 3 ).getBoundName() );
assertEquals( BaseSingleFieldConstraint.TYPE_PREDICATE,
tsdt.getConditionCols().get( 3 ).getConstraintValueType() );
assertEquals( "(not needed)",
tsdt.getConditionCols().get( 3 ).getFactField() );
assertEquals( "Driver",
tsdt.getConditionCols().get( 3 ).getFactType() );
assertEquals( "Driver 2 pimp",
tsdt.getConditionCols().get( 3 ).getHeader() );
assertEquals( 4,
tsdt.getActionCols().size() );
ActionInsertFactCol a1 = (ActionInsertFactCol) tsdt.getActionCols().get( 0 );
assertEquals( "ins",
a1.getBoundName() );
assertEquals( "Cheese",
a1.getFactType() );
assertEquals( "price",
a1.getFactField() );
assertEquals( SuggestionCompletionEngine.TYPE_NUMERIC,
a1.getType() );
ActionRetractFactCol a2 = (ActionRetractFactCol) tsdt.getActionCols().get( 1 );
assertEquals( "f2",
a2.getBoundName() );