001: /*
002: * Bossa Workflow System
003: *
004: * $Id: WFNetCoverage.java,v 1.2 2004/03/18 21:08:03 gdvieira Exp $
005: *
006: * Copyright (C) 2004 OpenBR Sistemas S/C Ltda.
007: *
008: * This file is part of Bossa.
009: *
010: * Bossa is free software; you can redistribute it and/or modify it
011: * under the terms of version 2 of the GNU General Public License as
012: * published by the Free Software Foundation.
013: *
014: * This program is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * General Public License for more details.
018: *
019: * You should have received a copy of the GNU General Public
020: * License along with this program; if not, write to the
021: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
022: * Boston, MA 02111-1307, USA.
023: */
024:
025: package com.bigbross.bossa.wfnet;
026:
027: import java.util.Map;
028:
029: import junit.framework.TestCase;
030:
031: public class WFNetCoverage extends TestCase {
032:
033: public void check(CaseType caseType) {
034:
035: assertEquals("wfnet-coverage", caseType.getId());
036:
037: assertEquals(6, caseType.getPlaces().size());
038: Place p1 = caseType.getPlace("place1");
039: assertNotNull(p1);
040: assertEquals(1, p1.getInitialMarking());
041: Place p21 = caseType.getPlace("place2.1");
042: assertNotNull(p1);
043: assertEquals(0, p21.getInitialMarking());
044: Place p22 = caseType.getPlace("place2.2");
045: assertNotNull(p1);
046: assertEquals(0, p22.getInitialMarking());
047: Place p3 = caseType.getPlace("place3");
048: assertNotNull(p1);
049: assertEquals(0, p3.getInitialMarking());
050: Place p4 = caseType.getPlace("place4");
051: assertNotNull(p1);
052: assertEquals(0, p4.getInitialMarking());
053: Place p5 = caseType.getPlace("place5");
054: assertNotNull(p5);
055: assertEquals(0, p5.getInitialMarking());
056:
057: assertEquals(5, caseType.getTransitions().size());
058: Transition t1 = caseType.getTransition("workitem1");
059: assertNotNull(t1);
060: assertEquals("starters", t1.getResource().toString());
061: assertEquals(-1, t1.getTimeout());
062: Transition t21 = caseType.getTransition("workitem2.1");
063: assertNotNull(t21);
064: assertNull(t21.getResource());
065: assertEquals(0, t21.getTimeout());
066: Transition t22 = caseType.getTransition("workitem2.2");
067: assertNotNull(t22);
068: assertEquals("workers", t22.getResource().toString());
069: assertEquals(-1, t22.getTimeout());
070: Transition t3 = caseType.getTransition("workitem3");
071: assertNotNull(t3);
072: assertEquals("workers-$workitem2.2", t3.getResource()
073: .toString());
074: assertEquals(-1, t3.getTimeout());
075: Transition t4 = caseType.getTransition("workitem4");
076: assertNotNull(t4);
077: assertEquals("workers", t4.getResource().toString());
078: assertEquals(-1, t4.getTimeout());
079:
080: assertEquals(1, t1.getInputEdges().size());
081: assertEquals("-1", t1.getInputEdges().get(0).toString());
082: assertEquals(2, t1.getOutputEdges().size());
083: assertEquals("1", t1.getOutputEdges().get(0).toString());
084: assertEquals("1", t1.getOutputEdges().get(1).toString());
085: assertEquals(1, t21.getInputEdges().size());
086: assertEquals("-1", t21.getInputEdges().get(0).toString());
087: assertEquals(1, t21.getOutputEdges().size());
088: assertEquals("1", t21.getOutputEdges().get(0).toString());
089: assertEquals(1, t22.getInputEdges().size());
090: assertEquals("-1", t22.getInputEdges().get(0).toString());
091: assertEquals(1, t22.getOutputEdges().size());
092: assertEquals("1", t22.getOutputEdges().get(0).toString());
093: assertEquals(1, t3.getInputEdges().size());
094: assertEquals("-2", t3.getInputEdges().get(0).toString());
095: assertEquals(2, t3.getOutputEdges().size());
096: assertEquals("1", t3.getOutputEdges().get(0).toString());
097: assertEquals("optional", t3.getOutputEdges().get(1).toString());
098: assertEquals(1, t4.getInputEdges().size());
099: assertEquals("-1", t4.getInputEdges().get(0).toString());
100: assertEquals(1, t4.getOutputEdges().size());
101: assertEquals("1", t4.getOutputEdges().get(0).toString());
102:
103: Map attributes = caseType.getCase(0).getAttributes();
104: assertEquals(2, attributes.size());
105: assertEquals(new Integer(0), attributes.get("optional"));
106: assertEquals("yes", attributes.get("testStr"));
107: }
108: }
|