//
//
// }
@Test
public void testValueLists() {
GuidedDecisionTable dt = new GuidedDecisionTable();
// add cols for LHS
ConditionCol c1 = new ConditionCol();
c1.setBoundName( "c1" );
c1.setFactType( "Driver" );
c1.setFactField( "name" );
c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
dt.getConditionCols().add( c1 );
ConditionCol c1_ = new ConditionCol();
c1_.setBoundName( "c1" );
c1_.setFactType( "Driver" );
c1_.setFactField( "name" );
c1_.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
dt.getConditionCols().add( c1_ );
ConditionCol c1__ = new ConditionCol();
c1__.setBoundName( "c1" );
c1__.setFactType( "Driver" );
c1__.setFactField( "name" );
c1__.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
c1__.setValueList( "one,two,three" );
dt.getConditionCols().add( c1__ );
ConditionCol c2 = new ConditionCol();
c2.setBoundName( "c2" );
c2.setFactType( "Driver" );
c2.setFactField( "nothing" );
c2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
dt.getConditionCols().add( c2 );
ActionSetFieldCol asf = new ActionSetFieldCol();
asf.setBoundName( "c1" );
asf.setFactField( "name" );
dt.getActionCols().add( asf );
ActionInsertFactCol ins = new ActionInsertFactCol();
ins.setBoundName( "x" );
ins.setFactField( "rating" );
ins.setFactType( "Person" );
dt.getActionCols().add( ins );
ActionInsertFactCol ins_ = new ActionInsertFactCol();
ins_.setBoundName( "x" );
ins_.setFactField( "rating" );
ins_.setFactType( "Person" );
ins_.setValueList( "one,two,three" );
dt.getActionCols().add( ins_ );
ActionSetFieldCol asf_ = new ActionSetFieldCol();
asf_.setBoundName( "c1" );
asf_.setFactField( "goo" );
dt.getActionCols().add( asf_ );
ActionSetFieldCol asf__ = new ActionSetFieldCol();
asf__.setBoundName( "c1" );
asf__.setFactField( "goo" );
asf__.setValueList( "one,two,three" );
dt.getActionCols().add( asf__ );
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
sce.putDataEnumList( "Driver.name",
new String[]{"bob", "michael"} );
sce.putDataEnumList( "Person.rating",
new String[]{"1", "2"} );
String[] r = dt.getValueList( c1,
sce );
assertEquals( 2,
r.length );
assertEquals( "bob",
r[0] );
assertEquals( "michael",
r[1] );
assertEquals( 0,
dt.getValueList( c1_,
sce ).length );
r = dt.getValueList( c1__,
sce );
assertEquals( 3,
r.length );
assertEquals( "one",
r[0] );
assertEquals( "two",
r[1] );
assertEquals( "three",
r[2] );
assertEquals( 0,
dt.getValueList( c2,
sce ).length );
r = dt.getValueList( asf,
sce );
assertEquals( 2,
r.length );
assertEquals( "bob",
r[0] );
assertEquals( "michael",
r[1] );
r = dt.getValueList( ins,
sce );
assertEquals( 2,
r.length );
assertEquals( "1",
r[0] );
assertEquals( "2",
r[1] );
r = dt.getValueList( ins_,
sce );
assertEquals( 3,
r.length );
assertEquals( "one",
r[0] );
assertEquals( "two",
r[1] );
assertEquals( "three",
r[2] );
assertEquals( 0,
dt.getValueList( asf_,
sce ).length );
r = dt.getValueList( asf__,
sce );
assertEquals( 3,
r.length );
assertEquals( "one",
r[0] );
assertEquals( "two",
r[1] );
assertEquals( "three",
r[2] );
AttributeCol at = new AttributeCol();
at.setAttribute( "no-loop" );
dt.getAttributeCols().add( at );
r = dt.getValueList( at,
sce );
assertEquals( 2,
r.length );
assertEquals( "true",
r[0] );
assertEquals( "false",
r[1] );
at.setAttribute( "enabled" );
assertEquals( 2,
dt.getValueList( at,
sce ).length );
at.setAttribute( "salience" );
assertEquals( 0,
dt.getValueList( at,
sce ).length );
}