Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Informer-interaction : replace update with modify, fix tests

  • Loading branch information...
commit 8245e486fc2b6f08ef1a0e61c5315039b7d1c486 1 parent fa00d73
Davide Sottara sotty authored
4 ...ls-informer/drools-informer-interaction/src/main/resources/org/drools/informer/interaction/humanTask.drl
@@ -491,10 +491,10 @@ then
491 491 holder.setTaskId( $tid );
492 492 holder.setOwner( $t.getOwner() );
493 493 System.out.println( "Create interactive task transition Quest' >>>>>>>>>>>" + holder + " for " + $t + " with owner " + $t.getOwner() );
  494 + insert( holder );
494 495 modify ( $t ) {
495   - setControlQuestId( holder.getQuestionnaireId() );
  496 + setControlQuestId( holder.getQuestionnaireId() );
496 497 }
497   - insert( holder );
498 498 end
499 499
500 500 rule "Clear Tx Qs"
19 ...-informer/drools-informer-interaction/src/main/resources/org/drools/informer/interaction/interaction.drl
@@ -210,12 +210,13 @@ when
210 210 not TaskStateTransition( $tid ; )
211 211 then
212 212 retract( $alert );
213   - $receivers.remove( 0 );
214   - $channels.remove( 0 );
215   - $timeouts.remove( 0 );
216   - $bodies.remove( 0 );
217 213 System.out.println( " Interaction is NOW " + $inter );
218   - update( $inter );
  214 + modify( $inter ) {
  215 + getReceivers().remove( 0 ),
  216 + getChannels().remove( 0 ),
  217 + getTimeouts().remove( 0 ),
  218 + getBodyTemplateIds().remove( 0 );
  219 + }
219 220 insert( new TaskStateTransition( $tid, TaskTransitions.DELEGATE, (String) $receivers.get( 0 ), new Date() ) );
220 221 insert( new TaskStateTransition( $tid, TaskTransitions.START, (String) $receivers.get( 0 ), new Date() ) );
221 222 end
@@ -233,10 +234,12 @@ when
233 234 then
234 235 System.out.println( $dest + " did not answer " + $alert );
235 236 retract( $alert );
236   - $receivers.remove( 0 );
237   - $channels.remove( 0 );
238 237 System.out.println( " Interaction is FAILED " + $inter );
239   - update( $inter );
  238 +
  239 + modify( $inter ) {
  240 + getReceivers().remove( 0 ),
  241 + getChannels().remove( 0 );
  242 + }
240 243 insert( new TaskStateTransition( $tid, TaskTransitions.ERROR, null, new Date() ) );
241 244 end
242 245
10 drools-informer/drools-informer-interaction/src/main/resources/org/drools/informer/interaction/quests.drl
@@ -85,8 +85,9 @@ when
85 85 $task : HumanTask( taskId == $qid, state != TaskStates.IN_PROGRESS )
86 86 then
87 87 System.out.println( "DISABLING A QUEST FOR A NOT STARTED TASK " + $qid );
88   - $quest.setSurveyLocked( true );
89   - update( $quest );
  88 + modify ( $quest ) {
  89 + setSurveyLocked( true );
  90 + }
90 91 end
91 92
92 93 rule "Enable Quest when HumanTask in Progress"
@@ -96,8 +97,9 @@ when
96 97 $task : HumanTask( taskId == $qid, state == TaskStates.IN_PROGRESS )
97 98 then
98 99 System.out.println( "ENABLING A QUEST FOR A STARTED TASK " + $qid );
99   - $quest.setSurveyLocked( false );
100   - update( $quest );
  100 + modify ( $quest ) {
  101 + setSurveyLocked( false );
  102 + }
101 103 end
102 104
103 105
6 drools-informer/drools-informer-interaction/src/test/java/TaskInteractionTest.java
@@ -21,8 +21,6 @@
21 21 import org.drools.conf.AssertBehaviorOption;
22 22 import org.drools.conf.EventProcessingOption;
23 23 import org.drools.definition.type.FactType;
24   -import org.drools.event.rule.DebugAgendaEventListener;
25   -import org.drools.event.rule.DebugWorkingMemoryEventListener;
26 24 import org.drools.informer.Answer;
27 25 import org.drools.informer.MultipleChoiceQuestion;
28 26 import org.drools.io.impl.ClassPathResource;
@@ -171,7 +169,7 @@ public void run() {
171 169
172 170
173 171 try {
174   - Thread.sleep( 2000 );
  172 + Thread.sleep( 3000 );
175 173 } catch (InterruptedException e) {
176 174 fail();
177 175 }
@@ -337,7 +335,7 @@ public void run() {
337 335 System.err.println( kSession.getGlobal( "list" ) );
338 336 System.err.println( kSession.getGlobal( "taskLog" ) );
339 337
340   - assertEquals(Arrays.asList("actor1", "main1", "actor2", "alien2", "actor3"), kSession.getGlobal("list"));
  338 + assertTrue( ((List)kSession.getGlobal("list")).containsAll( Arrays.asList("actor1", "main1", "actor2", "alien2", "actor3") ) );
341 339 assertEquals( 14, ((List) kSession.getGlobal( "taskLog" )).size() );
342 340
343 341 kSession.dispose();

0 comments on commit 8245e48

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