Skip to content
Browse files

Informer-interaction : replace update with modify, fix tests

  • Loading branch information...
1 parent fa00d73 commit 8245e486fc2b6f08ef1a0e61c5315039b7d1c486 @sotty sotty committed Aug 8, 2012
View
4 ...ols-informer-interaction/src/main/resources/org/drools/informer/interaction/humanTask.drl
@@ -491,10 +491,10 @@ then
holder.setTaskId( $tid );
holder.setOwner( $t.getOwner() );
System.out.println( "Create interactive task transition Quest' >>>>>>>>>>>" + holder + " for " + $t + " with owner " + $t.getOwner() );
+ insert( holder );
modify ( $t ) {
- setControlQuestId( holder.getQuestionnaireId() );
+ setControlQuestId( holder.getQuestionnaireId() );
}
- insert( holder );
end
rule "Clear Tx Qs"
View
19 ...s-informer-interaction/src/main/resources/org/drools/informer/interaction/interaction.drl
@@ -210,12 +210,13 @@ when
not TaskStateTransition( $tid ; )
then
retract( $alert );
- $receivers.remove( 0 );
- $channels.remove( 0 );
- $timeouts.remove( 0 );
- $bodies.remove( 0 );
System.out.println( " Interaction is NOW " + $inter );
- update( $inter );
+ modify( $inter ) {
+ getReceivers().remove( 0 ),
+ getChannels().remove( 0 ),
+ getTimeouts().remove( 0 ),
+ getBodyTemplateIds().remove( 0 );
+ }
insert( new TaskStateTransition( $tid, TaskTransitions.DELEGATE, (String) $receivers.get( 0 ), new Date() ) );
insert( new TaskStateTransition( $tid, TaskTransitions.START, (String) $receivers.get( 0 ), new Date() ) );
end
@@ -233,10 +234,12 @@ when
then
System.out.println( $dest + " did not answer " + $alert );
retract( $alert );
- $receivers.remove( 0 );
- $channels.remove( 0 );
System.out.println( " Interaction is FAILED " + $inter );
- update( $inter );
+
+ modify( $inter ) {
+ getReceivers().remove( 0 ),
+ getChannels().remove( 0 );
+ }
insert( new TaskStateTransition( $tid, TaskTransitions.ERROR, null, new Date() ) );
end
View
10 ...drools-informer-interaction/src/main/resources/org/drools/informer/interaction/quests.drl
@@ -85,8 +85,9 @@ when
$task : HumanTask( taskId == $qid, state != TaskStates.IN_PROGRESS )
then
System.out.println( "DISABLING A QUEST FOR A NOT STARTED TASK " + $qid );
- $quest.setSurveyLocked( true );
- update( $quest );
+ modify ( $quest ) {
+ setSurveyLocked( true );
+ }
end
rule "Enable Quest when HumanTask in Progress"
@@ -96,8 +97,9 @@ when
$task : HumanTask( taskId == $qid, state == TaskStates.IN_PROGRESS )
then
System.out.println( "ENABLING A QUEST FOR A STARTED TASK " + $qid );
- $quest.setSurveyLocked( false );
- update( $quest );
+ modify ( $quest ) {
+ setSurveyLocked( false );
+ }
end
View
6 drools-informer/drools-informer-interaction/src/test/java/TaskInteractionTest.java
@@ -21,8 +21,6 @@
import org.drools.conf.AssertBehaviorOption;
import org.drools.conf.EventProcessingOption;
import org.drools.definition.type.FactType;
-import org.drools.event.rule.DebugAgendaEventListener;
-import org.drools.event.rule.DebugWorkingMemoryEventListener;
import org.drools.informer.Answer;
import org.drools.informer.MultipleChoiceQuestion;
import org.drools.io.impl.ClassPathResource;
@@ -171,7 +169,7 @@ public void run() {
try {
- Thread.sleep( 2000 );
+ Thread.sleep( 3000 );
} catch (InterruptedException e) {
fail();
}
@@ -337,7 +335,7 @@ public void run() {
System.err.println( kSession.getGlobal( "list" ) );
System.err.println( kSession.getGlobal( "taskLog" ) );
- assertEquals(Arrays.asList("actor1", "main1", "actor2", "alien2", "actor3"), kSession.getGlobal("list"));
+ assertTrue( ((List)kSession.getGlobal("list")).containsAll( Arrays.asList("actor1", "main1", "actor2", "alien2", "actor3") ) );
assertEquals( 14, ((List) kSession.getGlobal( "taskLog" )).size() );
kSession.dispose();

0 comments on commit 8245e48

Please sign in to comment.
Something went wrong with that request. Please try again.