01: /*
02: * Bossa Workflow System
03: *
04: * $Id: HistoryTest.java,v 1.6 2004/03/12 19:44:38 gdvieira Exp $
05: *
06: * Copyright (C) 2003,2004 OpenBR Sistemas S/C Ltda.
07: *
08: * This file is part of Bossa.
09: *
10: * Bossa is free software; you can redistribute it and/or modify it
11: * under the terms of version 2 of the GNU General Public License as
12: * published by the Free Software Foundation.
13: *
14: * This program is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * General Public License for more details.
18: *
19: * You should have received a copy of the GNU General Public
20: * License along with this program; if not, write to the
21: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22: * Boston, MA 02111-1307, USA.
23: */
24:
25: package com.bigbross.bossa.history;
26:
27: import java.util.List;
28:
29: import junit.framework.TestCase;
30:
31: import com.bigbross.bossa.Bossa;
32: import com.bigbross.bossa.BossaException;
33: import com.bigbross.bossa.BossaFactory;
34: import com.bigbross.bossa.BossaTestUtil;
35: import com.bigbross.bossa.resource.Resource;
36: import com.bigbross.bossa.wfnet.WorkItem;
37: import com.bigbross.bossa.work.WorkManager;
38:
39: public class HistoryTest extends TestCase {
40:
41: private Resource frank, sally;
42: private WorkManager workManager;
43: private Historian historian;
44:
45: public HistoryTest(String name) {
46: super (name);
47: }
48:
49: protected void setUp() {
50: }
51:
52: public void testHistory() throws BossaException {
53: Bossa bossa = BossaTestUtil.createCompleteTestBossa();
54: frank = bossa.getResourceManager().getResource("frank");
55: sally = bossa.getResourceManager().getResource("sally");
56: workManager = bossa.getWorkManager();
57: historian = bossa.getHistorian();
58:
59: WorkItem wi = (WorkItem) workManager.getWorkItems(frank, true)
60: .get(0);
61: wi.open(frank).close();
62: wi = (WorkItem) workManager.getWorkItems(sally).get(0);
63: wi.open(sally).close();
64: wi = (WorkItem) workManager.getWorkItems(frank).get(0);
65: wi.open(frank).close();
66:
67: List events = historian.getHistory();
68: assertEquals(29, events.size());
69: }
70:
71: public void testNoHistory() throws BossaException {
72: BossaFactory factory = new BossaFactory();
73: factory.setTransientBossa(true);
74: factory.setActiveHistorian(false);
75: Bossa bossa = factory.createBossa();
76: BossaTestUtil.setupTestBossa(bossa);
77: frank = bossa.getResourceManager().getResource("frank");
78: workManager = bossa.getWorkManager();
79: historian = bossa.getHistorian();
80:
81: WorkItem wi = (WorkItem) workManager.getWorkItems(frank, true)
82: .get(0);
83: wi.open(frank).close();
84:
85: List events = historian.getHistory();
86: assertEquals(0, events.size());
87: }
88: }
|