} catch( InterruptedException e ) {
fail( e.getMessage() );
}
List tasks = taskService.getTasksForUser( new UserID( 1 ), Task.TASK_INCOMPLETE );
Task task = (Task)tasks.get( 0 );
ResponseHandler handler = taskService.getResponseHandlerForTask( task.getTaskID(), null );
assertNotNull( handler );
HttpServletRequestImpl request = new HttpServletRequestImpl();
HttpServletResponseImpl response = new HttpServletResponseImpl();
// Supply the parameters
request.addParameter( "numdays", "40" );
request.addParameter( "reason", "Expedition to Mount Everest" );
ResponseHandlerResponse rhr = ((HTTPResponseHandler)handler).processAction( request, response );
assertNotNull( rhr );
assertTrue( rhr.isAbleToContinue() );
// The task has been submitted so let's transition to the next node
EngineMessage engineMessage = new EngineMessageImpl();
engineMessage.setMessageType( EngineMessage.TYPE_MOVE_TOKEN );
engineMessage.setCurrentTokenID( rhr.getTokenID() );
engineMessage.addAppData( rhr.getActivityDataName(), rhr.getActivityData() );
queueService.enqueue( engineMessage );
taskService.setTaskStatus( task.getTaskID(), Task.TASK_COMPLETE );
try {
Thread.sleep(1000);
}
catch( InterruptedException e) {
fail( e.getMessage() );
}
// Instance variables should now reflect the new assigned values
tasks = taskService.getTasksForUser( new UserID( 1 ), Task.TASK_INCOMPLETE );
task = (Task)tasks.get( 0 );
Token token = tokenService.getTokenByID( task.getSourceTokenID() );
Instance instance = instanceService.getInstanceByID( token.getInstanceID() );
assertEquals( "40", instance.getInstanceVariables().get( "numdays" ) );
}