[jboss-user] [jBPM Users] - Re: Signaling executions for processes that containt tasks d

LMarinkov do-not-reply at jboss.com
Fri Sep 11 11:58:19 EDT 2009


/*
  |  * JBoss, Home of Professional Open Source
  |  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  |  * by the @authors tag. See the copyright.txt in the distribution for a
  |  * full listing of individual contributors.
  |  *
  |  * This is free software; you can redistribute it and/or modify it
  |  * under the terms of the GNU Lesser General Public License as
  |  * published by the Free Software Foundation; either version 2.1 of
  |  * the License, or (at your option) any later version.
  |  *
  |  * This software is distributed in the hope that it will be useful,
  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  |  * Lesser General Public License for more details.
  |  *
  |  * You should have received a copy of the GNU Lesser General Public
  |  * License along with this software; if not, write to the Free
  |  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  |  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  |  */
  | package org.jbpm.test.history;
  | 
  | import java.util.Map;
  | 
  | import org.jbpm.api.Execution;
  | import org.jbpm.test.JbpmTestCase;
  | 
  | 
  | /**
  |  * @author Tom Baeyens
  |  */
  | public class AvgDurationTest extends JbpmTestCase {
  | 
  |   public void testAvgDuration() throws Exception {
  |     deployJpdlXmlString(
  |       "<process name='Insurance claim' key='ICL'>" +
  |       "  <start>" +
  |       "    <transition to='one' />" +
  |       "  </start>" +
  |       "  <task name='one'>" +
  |       "    <transition to='two' />" +
  |       "  </task>" +
  |       "  <task name='two'>" +
  |       "    <transition to='three' />" +
  |       "  </task>" +
  |       "  <task name='three'>" +
  |       "    <transition to='end' />" +
  |       "  </task>" +
  |       "  <end name='end' />" +
  |       "</process>"
  |     );
  | 
  |     executeProcess();
  |     executeProcess();
  |     executeProcess();
  | 
  |     Map<String, Long> avgDurations = historyService.avgDurationPerActivity("ICL-1");
  | 
  | 
  |     Long avgDurationOne = avgDurations.get("one");
  |     assertNotNull(avgDurationOne);
  |     assertTrue("expected avg duration bigger then 40, but was"+avgDurationOne, avgDurationOne>40);
  |     Long avgDurationTwo = avgDurations.get("two");
  |     assertNotNull(avgDurationTwo);
  |     assertTrue("expected avg duration bigger then 10, but was"+avgDurationTwo, avgDurationTwo>10);
  |     Long avgDurationThree = avgDurations.get("three");
  |     assertNotNull(avgDurationThree);
  |     assertTrue("expected avg duration bigger then 0, but was"+avgDurationThree, avgDurationThree>=0);
  | 
  |     assertEquals(3, avgDurations.size());
  |   }
  | 
  |   protected void executeProcess() throws InterruptedException {
  |     Execution execution = executionService.startProcessInstanceByKey("ICL");
  |     Thread.sleep(50);
  |     executionService.signalExecutionById(execution.getId());
  |     Thread.sleep(20);
  |     executionService.signalExecutionById(execution.getId());
  |     executionService.signalExecutionById(execution.getId());
  |   }
  | 
  | }

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4254816#4254816

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4254816



More information about the jboss-user mailing list