1
2
3
4
5
6
7
8
9 package net.kwfgrid.gwes;
10
11 import junit.framework.Assert;
12 import junit.framework.Test;
13 import junit.framework.TestSuite;
14 import net.kwfgrid.gwes.exception.*;
15 import net.kwfgrid.gworkflowdl.structure.WorkflowFormatException;
16 import org.apache.log4j.Logger;
17 import org.jaxen.JaxenException;
18 import org.jdom.Element;
19 import org.jdom.JDOMException;
20
21 import java.io.IOException;
22 import java.util.List;
23
24
25
26
27
28
29
30
31
32
33 public final class GWES_DecisionTest extends LocalGWESAbstractTestCase {
34
35
36
37
38 static Logger logger = Logger.getLogger(GWES_DecisionTest.class);
39
40
41
42
43
44
45 public GWES_DecisionTest(String testName) throws LoggingException {
46 super(testName);
47 }
48
49
50
51
52 public static Test suite() {
53 return new TestSuite(GWES_DecisionTest.class);
54 }
55
56 public void testUnresolvedDecisions() throws DatabaseException, JaxenException, IOException, JDOMException, StateTransitionException, WorkflowFormatException, WorkflowSecurityException, InterruptedException, NoSuchWorkflowException, LoggingException, GWESException {
57 String gworkflowdl = testGWES("examples/controlflow/gworkflowdl_decision.xml", WorkflowStatus.STATUS_SUSPENDED);
58 String sequence = extractOccurrenceSequence(gworkflowdl);
59 Assert.assertEquals("Occurrence sequence", "",sequence);
60 List elements = xpath("/gwdl:workflow/gwdl:transition/gwdl:property[@name='decision.1150795880']", gworkflowdl);
61 Assert.assertEquals(2, elements.size());
62
63 for (int i = 0; i < elements.size(); i++) {
64 Element element = (Element) elements.get(i);
65 Assert.assertEquals("TAKE_CONFLICT", element.getText());
66 }
67 }
68
69 public void testDecisionSolvedByPriority() throws DatabaseException, JaxenException, IOException, JDOMException, StateTransitionException, WorkflowFormatException, WorkflowSecurityException, InterruptedException, NoSuchWorkflowException, LoggingException, GWESException {
70 String gworkflowdl = testGWES("examples/controlflow/gworkflowdl_decision_with_priority.xml", WorkflowStatus.STATUS_COMPLETED);
71
72 String sequence = extractOccurrenceSequence(gworkflowdl);
73 Assert.assertEquals("Occurrence sequence", "t2 tend",sequence);
74 List elements = xpath("/gwdl:workflow/gwdl:transition/gwdl:property[@name='decision.1150795880']", gworkflowdl);
75 Assert.assertEquals(0, elements.size());
76 }
77
78
79 }