@Test
//Test that WorkItem Parameters can be used to set fields on new Fact
public void testRHSActionWorkItemInsertFacts() {
RuleModel m = new RuleModel();
m.name = "WorkItem";
ActionExecuteWorkItem awi = new ActionExecuteWorkItem();
PortableWorkDefinition pwd = new PortableWorkDefinition();
pwd.setName( "WorkItem" );
awi.setWorkDefinition( pwd );
PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
p1.setName( "BooleanResult" );
pwd.addResult( p1 );
PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
p2.setName( "FloatResult" );
pwd.addResult( p2 );
PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
p3.setName( "IntegerResult" );
pwd.addResult( p3 );
PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
p4.setName( "StringResult" );
pwd.addResult( p4 );
m.addRhsItem( awi );
ActionInsertFact aif = new ActionInsertFact();
aif.setBoundName( "$r" );
aif.setFactType( "Results" );
ActionWorkItemFieldValue fv1 = new ActionWorkItemFieldValue( "ResultsBooleanResult",
DataType.TYPE_BOOLEAN,
"WorkItem",
"BooleanResult",
Boolean.class.getName() );
aif.addFieldValue( fv1 );
ActionWorkItemFieldValue fv2 = new ActionWorkItemFieldValue( "ResultsFloatResult",
DataType.TYPE_NUMERIC_FLOAT,
"WorkItem",
"FloatResult",
Float.class.getName() );
aif.addFieldValue( fv2 );
ActionWorkItemFieldValue fv3 = new ActionWorkItemFieldValue( "ResultsIntegerResult",
DataType.TYPE_NUMERIC_INTEGER,
"WorkItem",
"IntegerResult",
Integer.class.getName() );
aif.addFieldValue( fv3 );
ActionWorkItemFieldValue fv4 = new ActionWorkItemFieldValue( "ResultsStringResult",
DataType.TYPE_STRING,
"WorkItem",
"StringResult",
String.class.getName() );
aif.addFieldValue( fv4 );
m.addRhsItem( aif );
String result = BRDRLPersistence.getInstance().marshal( m );
assertTrue( result.indexOf( "org.kie.internal.process.instance.WorkItemManager wim = (org.kie.internal.process.instance.WorkItemManager) drools.getWorkingMemory().getWorkItemManager();" ) != -1 );
assertTrue( result.indexOf( "org.kie.internal.process.instance.impl.WorkItemImpl wiWorkItem = new org.kie.internal.process.instance.impl.WorkItemImpl();" ) != -1 );