}
@SuppressWarnings("serial")
@Test
public void testNoConstraints() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
// add cols for LHS
RowNumberCol52 rnc = new RowNumberCol52();
DescriptionCol52 dc = new DescriptionCol52();
MetadataCol52 mdc = new MetadataCol52();
mdc.setMetadata( "cheese" );
AttributeCol52 ac = new AttributeCol52();
ac.setAttribute( "salience" );
ActionSetFieldCol52 asfc = new ActionSetFieldCol52();
asfc.setBoundName( "d1" );
asfc.setFactField( "age" );
ActionInsertFactCol52 aifc = new ActionInsertFactCol52();
aifc.setBoundName( "d2" );
aifc.setFactType( "Driver" );
aifc.setFactField( "age" );
ConditionCol52 c1 = new ConditionCol52();
Pattern52 p1 = new Pattern52();
p1.setBoundName( "c1" );
p1.setFactType( "Driver" );
c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
p1.getChildColumns().add( c1 );
dt.getConditions().add( p1 );
ConditionCol52 c2 = new ConditionCol52();
Pattern52 p2 = new Pattern52();
p2.setBoundName( "c2" );
p2.setFactType( "Driver" );
c2.setFactField( "age" );
c2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
p2.getChildColumns().add( c2 );
dt.getConditions().add( p2 );
ConditionCol52 c3 = new ConditionCol52();
Pattern52 p3 = new Pattern52();
p3.setBoundName( "c3" );
p3.setFactType( "Driver" );
c3.setOperator( "==" );
c3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
p3.getChildColumns().add( c3 );
dt.getConditions().add( p3 );
ConditionCol52 c4 = new ConditionCol52();
Pattern52 p4 = new Pattern52();
p4.setBoundName( "c4" );
p4.setFactType( "Driver" );
c4.setFactField( "age" );
c4.setOperator( "==" );
c4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
p4.getChildColumns().add( c4 );
dt.getConditions().add( p4 );
ConditionCol52 c5 = new ConditionCol52();
Pattern52 p5 = new Pattern52();
p5.setBoundName( "c5" );
p5.setFactType( "Driver" );
c5.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
p5.getChildColumns().add( c5 );
dt.getConditions().add( p5 );
ConditionCol52 c6 = new ConditionCol52();
Pattern52 p6 = new Pattern52();
p6.setBoundName( "c6" );
p6.setFactType( "Driver" );
c6.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
p6.getChildColumns().add( c6 );
dt.getConditions().add( p6 );
SuggestionCompletionEngine sce = new SuggestionCompletionEngine();
sce.setFieldsForTypes( new HashMap<String, ModelField[]>() {
{
put( "Driver",
new ModelField[]{
new ModelField( "age",
Integer.class.getName(),
FIELD_CLASS_TYPE.REGULAR_CLASS,
SuggestionCompletionEngine.TYPE_NUMERIC ),
new ModelField( "name",
String.class.getName(),
FIELD_CLASS_TYPE.REGULAR_CLASS,
SuggestionCompletionEngine.TYPE_STRING )
} );
}
} );
assertTrue( dt.isConstraintValid( rnc,
sce ) );
assertTrue( dt.isConstraintValid( dc,
sce ) );
assertTrue( dt.isConstraintValid( mdc,
sce ) );
assertTrue( dt.isConstraintValid( ac,
sce ) );
assertTrue( dt.isConstraintValid( asfc,
sce ) );
assertTrue( dt.isConstraintValid( aifc,
sce ) );
assertFalse( dt.isConstraintValid( c1,
sce ) );
assertFalse( dt.isConstraintValid( c2,
sce ) );
assertFalse( dt.isConstraintValid( c3,
sce ) );
assertTrue( dt.isConstraintValid( c4,
sce ) );
assertTrue( dt.isConstraintValid( c5,
sce ) );
assertTrue( dt.isConstraintValid( c6,
sce ) );
}