1 package org.jbpm.bpel.service.def; 2 3 import org.jbpm.bpel.db.AbstractDbTestCase; 4 import org.jbpm.bpel.def.Activity; 5 import org.jbpm.bpel.def.BpelDefinition; 6 import org.jbpm.bpel.def.Empty; 7 import org.jbpm.bpel.def.Pick; 8 9 public class CorrelationDbTest extends AbstractDbTestCase { 10 11 BpelDefinition processDefinition; 12 Correlation correlation; 13 14 public void setUp() { 15 super.setUp(); 16 processDefinition = new BpelDefinition(); 17 Pick pick = new Pick("parent"); 18 Receiver receiver = new Receiver(pick); 19 20 Correlations correlations = new Correlations(); 21 correlation = new Correlation(); 22 CorrelationSetDefinition set = new CorrelationSetDefinition(); 23 set.setName("cs"); 24 processDefinition.getScope().addCorrelationSet(set); 25 correlation.setSet(set); 26 correlations.addCorrelation(correlation); 27 receiver.setCorrelations(correlations); 28 29 Activity activity = new Empty("child"); 30 pick.addNode(activity); 31 pick.setOnMessage(activity, receiver); 32 processDefinition.addNode(pick); 33 } 34 35 public void testInitiateYes() { 36 correlation.setInitiate(Correlation.Initiate.YES); 37 38 processDefinition = saveAndReload(processDefinition); 39 correlation = getCorrelation(); 40 41 assertEquals( Correlation.Initiate.YES, correlation.getInitiate() ); 42 } 43 44 public void testInitiateNo() { 45 correlation.setInitiate(Correlation.Initiate.NO); 46 47 processDefinition = saveAndReload(processDefinition); 48 correlation = getCorrelation(); 49 50 assertEquals( Correlation.Initiate.NO, correlation.getInitiate() ); 51 } 52 53 public void testInitiateRendezvous() { 54 correlation.setInitiate(Correlation.Initiate.RENDEZVOUS); 55 56 processDefinition = saveAndReload(processDefinition); 57 correlation = getCorrelation(); 58 59 assertEquals( Correlation.Initiate.RENDEZVOUS, correlation.getInitiate() ); 60 } 61 62 public void testSet() { 63 processDefinition = saveAndReload(processDefinition); 64 assertEquals("cs", getCorrelation().getSet().getName()); 65 } 66 67 private Correlation getCorrelation() { 68 Pick pick = ((Pick) processDefinition.getNode("parent")); 69 Receiver receptor = (Receiver) pick.getOnMessages().get(0); 70 return (Correlation) receptor.getCorrelations().getCorrelations().values().iterator().next(); 71 } 72 } 73 | Popular Tags |