String[][] expected = new String[][]{
new String[]{"1", "desc", "metar1", "saliencer1", "f1c1r1", "f1c2r1", "f2c1r1", "f2c2r1", "a1r1", "ret1", "a3r1", "a4r1"},
new String[]{"2", "desc", "metar2", "saliencer2", "f1c1r2", "f1c2r2", "f2c1r2", "f2c2r2", "a1r2", "ret1", "a3r2", "a4r2"}
};
GuidedDecisionTable52 tsdt = upgrader.upgrade( 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( 2,
tsdt.getConditions().size() );
assertEquals( "f1",
tsdt.getConditionPattern( "f1" ).getBoundName() );
assertEquals( "Driver",
tsdt.getConditionPattern( "f1" ).getFactType() );
assertEquals( "f2",
tsdt.getConditionPattern( "f2" ).getBoundName() );
assertEquals( "Person",
tsdt.getConditionPattern( "f2" ).getFactType() );
assertEquals( 2,
tsdt.getConditionPattern( "f1" ).getChildColumns().size() );
assertEquals( 2,
tsdt.getConditionPattern( "f2" ).getChildColumns().size() );
assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getConstraintValueType() );
assertEquals( "age",
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getFactField() );
assertEquals( "Driver",
tsdt.getPattern( tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ) ).getFactType() );
assertEquals( "Driver f1 age",
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getHeader() );
assertEquals( "==",
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 0 ).getOperator() );
assertEquals( BaseSingleFieldConstraint.TYPE_RET_VALUE,
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ).getConstraintValueType() );
assertEquals( "rating",
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ).getFactField() );
assertEquals( "Driver",
tsdt.getPattern( tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ) ).getFactType() );
assertEquals( "Driver rating",
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ).getHeader() );
assertEquals( "==",
tsdt.getConditionPattern( "f1" ).getChildColumns().get( 1 ).getOperator() );
assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 0 ).getConstraintValueType() );
assertEquals( "name",
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 0 ).getFactField() );
assertEquals( "Person",
tsdt.getPattern( tsdt.getConditionPattern( "f2" ).getChildColumns().get( 0 ) ).getFactType() );
assertEquals( "Person f2 name",
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 0 ).getHeader() );
assertEquals( "==",
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 0 ).getOperator() );
assertEquals( BaseSingleFieldConstraint.TYPE_PREDICATE,
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 1 ).getConstraintValueType() );
assertEquals( "(not needed)",
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 1 ).getFactField() );
assertEquals( "Person",
tsdt.getPattern( tsdt.getConditionPattern( "f2" ).getChildColumns().get( 1 ) ).getFactType() );
assertEquals( "Person f2 not needed",
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 1 ).getHeader() );
assertEquals( null,
tsdt.getConditionPattern( "f2" ).getChildColumns().get( 1 ).getOperator() );
assertEquals( 4,
tsdt.getActionCols().size() );
ActionInsertFactCol52 a1 = (ActionInsertFactCol52) tsdt.getActionCols().get( 0 );
assertEquals( "ins",
a1.getBoundName() );
assertEquals( "Cheese",
a1.getFactType() );
assertEquals( "price",
a1.getFactField() );
assertEquals( SuggestionCompletionEngine.TYPE_NUMERIC,
a1.getType() );
ActionRetractFactCol52 a2 = (ActionRetractFactCol52) tsdt.getActionCols().get( 1 );
assertNotNull( a2 );
ActionSetFieldCol52 a3 = (ActionSetFieldCol52) tsdt.getActionCols().get( 2 );
assertEquals( "f1",
a3.getBoundName() );
assertEquals( "goo1",
a3.getFactField() );
assertEquals( SuggestionCompletionEngine.TYPE_STRING,
a3.getType() );
ActionSetFieldCol52 a4 = (ActionSetFieldCol52) tsdt.getActionCols().get( 3 );
assertEquals( "f1",
a4.getBoundName() );
assertEquals( "goo2",
a4.getFactField() );
assertEquals( "whee",
a4.getDefaultValue() );
assertEquals( SuggestionCompletionEngine.TYPE_STRING,
a4.getType() );
assertEquals( 2,
tsdt.getData().size() );
for ( int i = 0; i < 2; i++ ) {
System.out.println( "Row-" + i );
StringBuilder sb = new StringBuilder();
for ( DTCellValue52 c : tsdt.getData().get( i ) ) {
sb.append( c.getStringValue() + ", " );
}
sb.delete( sb.lastIndexOf( "," ),
sb.length() );
System.out.println( sb.toString() );
}
assertEquals( new BigDecimal( 1 ),
tsdt.getData().get( 0 ).get( 0 ).getNumericValue() );
assertEquals( "desc",
tsdt.getData().get( 0 ).get( 1 ).getStringValue() );
assertEquals( "metar1",
tsdt.getData().get( 0 ).get( 2 ).getStringValue() );
assertEquals( "saliencer1",
tsdt.getData().get( 0 ).get( 3 ).getStringValue() );
assertEquals( "f1c1r1",
tsdt.getData().get( 0 ).get( 4 ).getStringValue() );
assertEquals( "f1c2r1",
tsdt.getData().get( 0 ).get( 5 ).getStringValue() );
assertEquals( "f2c1r1",
tsdt.getData().get( 0 ).get( 6 ).getStringValue() );
assertEquals( "f2c2r1",
tsdt.getData().get( 0 ).get( 7 ).getStringValue() );
assertEquals( "a1r1",
tsdt.getData().get( 0 ).get( 8 ).getStringValue() );
assertEquals( "ret1",
tsdt.getData().get( 0 ).get( 9 ).getStringValue() );
assertEquals( "a3r1",
tsdt.getData().get( 0 ).get( 10 ).getStringValue() );
assertEquals( "a4r1",
tsdt.getData().get( 0 ).get( 11 ).getStringValue() );
assertEquals( new BigDecimal( 2 ),
tsdt.getData().get( 1 ).get( 0 ).getNumericValue() );
assertEquals( "desc",
tsdt.getData().get( 1 ).get( 1 ).getStringValue() );
assertEquals( "metar2",
tsdt.getData().get( 1 ).get( 2 ).getStringValue() );
assertEquals( "saliencer2",
tsdt.getData().get( 1 ).get( 3 ).getStringValue() );
assertEquals( "f1c1r2",
tsdt.getData().get( 1 ).get( 4 ).getStringValue() );
assertEquals( "f1c2r2",
tsdt.getData().get( 1 ).get( 5 ).getStringValue() );
assertEquals( "f2c1r2",
tsdt.getData().get( 1 ).get( 6 ).getStringValue() );
assertEquals( "f2c2r2",
tsdt.getData().get( 1 ).get( 7 ).getStringValue() );
assertEquals( "a1r2",
tsdt.getData().get( 1 ).get( 8 ).getStringValue() );
assertEquals( "ret1",
tsdt.getData().get( 1 ).get( 9 ).getStringValue() );
assertEquals( "a3r2",
tsdt.getData().get( 1 ).get( 10 ).getStringValue() );
assertEquals( "a4r2",
tsdt.getData().get( 1 ).get( 11 ).getStringValue() );
isRowEquivalent( tsdt.getData().get( 0 ),
expected[0] );
isRowEquivalent( tsdt.getData().get( 1 ),
expected[1] );
}