0001: /*--
0002:
0003: Copyright (C) 2002-2005 Adrian Price.
0004: All rights reserved.
0005:
0006: Redistribution and use in source and binary forms, with or without
0007: modification, are permitted provided that the following conditions
0008: are met:
0009:
0010: 1. Redistributions of source code must retain the above copyright
0011: notice, this list of conditions, and the following disclaimer.
0012:
0013: 2. Redistributions in binary form must reproduce the above copyright
0014: notice, this list of conditions, and the disclaimer that follows
0015: these conditions in the documentation and/or other materials
0016: provided with the distribution.
0017:
0018: 3. The names "OBE" and "Open Business Engine" must not be used to
0019: endorse or promote products derived from this software without prior
0020: written permission. For written permission, please contact
0021: adrianprice@sourceforge.net.
0022:
0023: 4. Products derived from this software may not be called "OBE" or
0024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
0025: appear in their name, without prior written permission from
0026: Adrian Price (adrianprice@users.sourceforge.net).
0027:
0028: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0029: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0030: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0031: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
0032: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0033: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0034: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0035: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
0036: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
0037: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0038: POSSIBILITY OF SUCH DAMAGE.
0039:
0040: For more information on OBE, please see
0041: <http://obe.sourceforge.net/>.
0042:
0043: */
0044:
0045: package org.obe.test;
0046:
0047: import junit.framework.Test;
0048: import org.apache.commons.logging.Log;
0049: import org.apache.commons.logging.LogFactory;
0050: import org.obe.client.api.model.ActivityInstanceAttributes;
0051: import org.obe.client.api.model.ProcessInstanceAttributes;
0052: import org.obe.client.api.model.WorkItemAttributes;
0053: import org.obe.client.api.repository.RepositoryException;
0054: import org.obe.spi.model.*;
0055: import org.obe.xpdl.model.activity.Activity;
0056: import org.obe.xpdl.model.data.DataTypes;
0057: import org.obe.xpdl.model.data.Type;
0058: import org.obe.xpdl.model.pkg.XPDLPackage;
0059: import org.obe.xpdl.model.workflow.WorkflowProcess;
0060: import org.obe.xpdl.parser.XPDLParser;
0061: import org.obe.xpdl.parser.XPDLParserException;
0062: import org.obe.xpdl.parser.dom4j.Dom4JXPDLParser;
0063: import org.wfmc.wapi.WMActivityInstanceState;
0064: import org.wfmc.wapi.WMFilter;
0065: import org.wfmc.wapi.WMProcessInstanceState;
0066: import org.wfmc.wapi.WMWorkItemState;
0067:
0068: import java.beans.PropertyDescriptor;
0069: import java.io.IOException;
0070: import java.io.InputStream;
0071: import java.util.Collection;
0072: import java.util.Date;
0073: import java.util.Locale;
0074: import java.util.Properties;
0075:
0076: /**
0077: * Tests the instance repository.
0078: *
0079: * @author Adrian Price
0080: */
0081: public class InstanceRepositoryTest extends AbstractRepositoryTest {
0082: private static final Log _logger = LogFactory
0083: .getLog(InstanceRepositoryTest.class);
0084: private static final int[] PROC_INST_ATTR_TYPES = getAttributeTypes(ProcessInstanceAttributes.SYSTEM_PROPERTIES);
0085: private static final int[] ACT_INST_ATTR_TYPES = getAttributeTypes(ActivityInstance.propertyDescriptors);
0086: private static final int[] WORK_ITEM_ATTR_TYPES = getAttributeTypes(WorkItem.propertyDescriptors);
0087:
0088: protected static final String[] TESTS = { "testInitialize",
0089: "testCreateProcessInstance",
0090: "testCreateProcessInstanceAttribute",
0091: "testFindProcessInstance", "testFindProcessInstances",
0092: "testFindProcessInstanceAttribute",
0093: "testFindProcessInstanceAttributes",
0094: "testCreateActivityInstance",
0095: "testCreateActivityInstanceAttribute",
0096: "testFindActivityInstance", "testFindActivityInstances",
0097: "testFindActivityInstanceAttribute",
0098: "testFindActivityInstanceAttributes", "testCreateWorkItem",
0099: "testCreateWorkItemAttribute", "testFindWorkItem",
0100: "testFindWorkItems", "testFindWorkItemAttribute",
0101: "testFindWorkItemAttributes", "testDeleteProcessInstance",
0102: "testPurge", "testUninitialize" };
0103: private static final double DOUBLE_TOLERANCE = 1.0E-5;
0104: private static final int WAITING_TIME_MILLIS = 60000;
0105: private static final int DURATION_MILLIS = 43200000;
0106: private static final int LIMIT_MILLIS = 86400000;
0107: private static final int ARBITRARY_INT_1 = 666;
0108: private static final int ARBITRARY_INT_2 = 665;
0109: // We'll test persistent date accuracy to a tolerance of one second.
0110: private static final Date CREATED_DATE = ignoreMillis(new Date());
0111: private static final Date STARTED_DATE = new Date(CREATED_DATE
0112: .getTime()
0113: + WAITING_TIME_MILLIS);
0114: private static final Date TARGET_DATE = new Date(STARTED_DATE
0115: .getTime()
0116: + DURATION_MILLIS);
0117: private static final Date DUE_DATE = new Date(STARTED_DATE
0118: .getTime()
0119: + LIMIT_MILLIS);
0120: private static final String[] PARTICIPANTS = { "Tom", "Dick",
0121: "Harry" };
0122: private static final String[] PACKAGE_ID = new String[2];
0123: private static final String[] PROC_DEF_ID = new String[3];
0124: private static final String[] ACT_DEF_ID = new String[2];
0125: private static final String[] PROC_INST_DEF_ID = new String[5];
0126: private static final String[] PROC_INST_NAME = { "ProcInst1",
0127: "ProcInst2", "ProcInst3", "ProcInst4", "ProcInst5" };
0128: private static final int[] PROC_INST_STATE = {
0129: WMProcessInstanceState.OPEN_RUNNING_INT,
0130: WMProcessInstanceState.OPEN_NOTRUNNING_NOTSTARTED_INT,
0131: WMProcessInstanceState.OPEN_RUNNING_INT,
0132: WMProcessInstanceState.OPEN_RUNNING_INT,
0133: WMProcessInstanceState.OPEN_RUNNING_INT };
0134: private static final int[] PROC_INST_PRIORITY = { 0, 1, 0, 2, 0 };
0135: private static final Date[] PROC_INST_STARTED = { STARTED_DATE,
0136: null, STARTED_DATE, STARTED_DATE, STARTED_DATE };
0137: private static final ProcessInstance[] PROC_INST = new ProcessInstance[5];
0138: private static final String[] PROC_INST_ID = new String[5];
0139: private static final String[] EMPTY_ATTR_NAMES = {};
0140: private static final int[] EMPTY_ATTR_TYPES = {};
0141: private static final String[] ATTR_INST_NAME = { "BoolAttr",
0142: "DateAttr", "FloatAttr", "IntAttr", "StringAttr", "ObjAttr" };
0143: private static final int[] ATTR_INST_TYPE = { Type.BOOLEAN_TYPE,
0144: Type.DATETIME_TYPE, Type.FLOAT_TYPE, Type.INTEGER_TYPE,
0145: Type.STRING_TYPE, Type.EXTERNAL_REFERENCE_TYPE };
0146: private static final Object[] ATTR_INST_VALUE = { Boolean.TRUE,
0147: STARTED_DATE, new Double(Math.PI),
0148: new Integer(ARBITRARY_INT_1), "AttributeInstance1 Value",
0149: Locale.getDefault() };
0150: private static final AttributeInstance[] ATTR_INST = new AttributeInstance[ATTR_INST_NAME.length];
0151: // These filters are such that each will yield true when applied against the
0152: // attributes and values defined above.
0153: private static WMFilter[] QB_ATTR_FILTER = {
0154: new WMFilter(ATTR_INST_NAME[0], WMFilter.NE, Boolean.FALSE),
0155: new WMFilter(ATTR_INST_NAME[1], WMFilter.LT, DUE_DATE),
0156: new WMFilter(ATTR_INST_NAME[2], WMFilter.GT, new Double(
0157: Math.E)),
0158: new WMFilter(ATTR_INST_NAME[3], WMFilter.GE, new Integer(
0159: ARBITRARY_INT_2)),
0160: new WMFilter(ATTR_INST_NAME[4], WMFilter.EQ,
0161: (String) ATTR_INST_VALUE[4]) };
0162: private static String[] QB_ATTR_FILTER_NAME = {
0163: "Boolean attribute filtered", "Date attribute filtered",
0164: "Float attribute filtered", "Integer attribute filtered",
0165: "String attribute filtered" };
0166: private static Object[][] ATTR_FILTER_TESTS = {
0167: { "Unfiltered", null, ATTR_INST_NAME, ATTR_INST_TYPE,
0168: ATTR_INST_VALUE },
0169: {
0170: "Simple filtered",
0171: new WMFilter("type", WMFilter.EQ, String
0172: .valueOf(ATTR_INST_TYPE[4])),
0173: new String[] { ATTR_INST_NAME[4] },
0174: new int[] { ATTR_INST_TYPE[4] },
0175: new Object[] { ATTR_INST_VALUE[4] } },
0176: {
0177: "SQL-AND filtered",
0178: new WMFilter("type = " + ATTR_INST_TYPE[4]
0179: + " AND name = '" + ATTR_INST_NAME[4]
0180: + '\''),
0181: new String[] { ATTR_INST_NAME[4] },
0182: new int[] { ATTR_INST_TYPE[4] },
0183: new Object[] { ATTR_INST_VALUE[4] } },
0184: {
0185: "SQL-LIKE filtered",
0186: new WMFilter("name LIKE '%tAttr'"),
0187: new String[] { ATTR_INST_NAME[2], ATTR_INST_NAME[3] },
0188: new int[] { ATTR_INST_TYPE[2], ATTR_INST_TYPE[3] },
0189: new Object[] { ATTR_INST_VALUE[2],
0190: ATTR_INST_VALUE[3] } },
0191: {
0192: "SQL-NOT-LIKE filtered",
0193: new WMFilter("name NOT LIKE '%tAttr'"),
0194: new String[] { ATTR_INST_NAME[0],
0195: ATTR_INST_NAME[1], ATTR_INST_NAME[4],
0196: ATTR_INST_NAME[5] },
0197: new int[] { ATTR_INST_TYPE[0], ATTR_INST_TYPE[1],
0198: ATTR_INST_TYPE[4], ATTR_INST_TYPE[5] },
0199: new Object[] { ATTR_INST_VALUE[0],
0200: ATTR_INST_VALUE[1], ATTR_INST_VALUE[4],
0201: ATTR_INST_VALUE[5] } },
0202: {
0203: "SQL-OR filtered",
0204: new WMFilter("type = " + ATTR_INST_TYPE[3]
0205: + " OR type = " + ATTR_INST_TYPE[4]),
0206: new String[] { ATTR_INST_NAME[3], ATTR_INST_NAME[4] },
0207: new int[] { ATTR_INST_TYPE[3], ATTR_INST_TYPE[4] },
0208: new Object[] { ATTR_INST_VALUE[3],
0209: ATTR_INST_VALUE[4] } },
0210: {
0211: "SQL-IN filtered",
0212: new WMFilter("type IN (" + ATTR_INST_TYPE[3] + ", "
0213: + ATTR_INST_TYPE[4] + ')'),
0214: new String[] { ATTR_INST_NAME[3], ATTR_INST_NAME[4] },
0215: new int[] { ATTR_INST_TYPE[3], ATTR_INST_TYPE[4] },
0216: new Object[] { ATTR_INST_VALUE[3],
0217: ATTR_INST_VALUE[4] } },
0218: {
0219: "SQL-NOT-IN filtered",
0220: new WMFilter("type NOT IN (" + ATTR_INST_TYPE[3]
0221: + ", " + ATTR_INST_TYPE[4] + ')'),
0222: new String[] { ATTR_INST_NAME[0],
0223: ATTR_INST_NAME[1], ATTR_INST_NAME[2],
0224: ATTR_INST_NAME[5] },
0225: new int[] { ATTR_INST_TYPE[0], ATTR_INST_TYPE[1],
0226: ATTR_INST_TYPE[2], ATTR_INST_TYPE[5] },
0227: new Object[] { ATTR_INST_VALUE[0],
0228: ATTR_INST_VALUE[1], ATTR_INST_VALUE[2],
0229: ATTR_INST_VALUE[5] } },
0230: {
0231: "SQL-BETWEEN filtered",
0232: new WMFilter("type BETWEEN " + Type.STRING_TYPE
0233: + " AND " + Type.INTEGER_TYPE),
0234: new String[] { ATTR_INST_NAME[2],
0235: ATTR_INST_NAME[3], ATTR_INST_NAME[4] },
0236: new int[] { ATTR_INST_TYPE[2], ATTR_INST_TYPE[3],
0237: ATTR_INST_TYPE[4] },
0238: new Object[] { ATTR_INST_VALUE[2],
0239: ATTR_INST_VALUE[3], ATTR_INST_VALUE[4] } },
0240: {
0241: "SQL-NOT-BETWEEN filtered",
0242: new WMFilter("type NOT BETWEEN " + Type.STRING_TYPE
0243: + " AND " + Type.INTEGER_TYPE),
0244: new String[] { ATTR_INST_NAME[0],
0245: ATTR_INST_NAME[1], ATTR_INST_NAME[5] },
0246: new int[] { ATTR_INST_TYPE[0], ATTR_INST_TYPE[1],
0247: ATTR_INST_TYPE[5] },
0248: new Object[] { ATTR_INST_VALUE[0],
0249: ATTR_INST_VALUE[1], ATTR_INST_VALUE[5] } }, };
0250: private static final String[] ACT_NAME = new String[4];
0251: private static final JoinInstance[] ACT_INST_JOIN = {
0252: new AndJoinInstance(new String[] { "1", "2", "3" }),
0253: new OrJoinInstance(new String[] { "4", "5", "6" }), null,
0254: null };
0255: private static final int[] ACT_INST_STATE = {
0256: WMActivityInstanceState.OPEN_RUNNING_INT,
0257: WMActivityInstanceState.OPEN_NOTRUNNING_INT,
0258: WMActivityInstanceState.OPEN_RUNNING_INT,
0259: WMActivityInstanceState.OPEN_RUNNING_INT };
0260: private static final Date[] ACT_INST_STARTED = { STARTED_DATE,
0261: null, STARTED_DATE, STARTED_DATE };
0262: private static final Date[] ACT_INST_DUE = { DUE_DATE, null,
0263: DUE_DATE, null };
0264: private static final Date[] ACT_INST_TARGET = { TARGET_DATE, null,
0265: TARGET_DATE, null };
0266: private static final int[] ACT_INST_PRIORITY = { 1, 2, 1, 1 };
0267: private static final ActivityInstance[] ACT_INST = new ActivityInstance[4];
0268: private static final String[] ACT_INST_ID = new String[4];
0269: private static final WorkItem[] WORKITEM = new WorkItem[4];
0270: private static final String[] WORKITEM_ID = new String[4];
0271: private static final String[] WORKITEM_PARTICIPANT = { "Tom",
0272: "Dick", "Harry", "Adrian" };
0273: private static final int[] WORKITEM_STATE = {
0274: WMActivityInstanceState.OPEN_RUNNING_INT,
0275: WMActivityInstanceState.OPEN_NOTRUNNING_INT,
0276: WMActivityInstanceState.OPEN_RUNNING_INT,
0277: WMActivityInstanceState.OPEN_RUNNING_INT };
0278: private static final int[] WORKITEM_TOOL_INDEX = { -1, 0, 1, 2 };
0279: private static final Date[] WORKITEM_STARTED = { STARTED_DATE,
0280: null, STARTED_DATE, STARTED_DATE };
0281: private static final Date[] WORKITEM_DUE = { DUE_DATE, null,
0282: DUE_DATE, null };
0283: private static final Date[] WORKITEM_TARGET = { TARGET_DATE, null,
0284: TARGET_DATE, null };
0285:
0286: public static Test suite() {
0287: return cactusSuite(InstanceRepositoryTest.class, TESTS);
0288: }
0289:
0290: private static int[] getAttributeTypes(
0291: PropertyDescriptor[] propDescs) {
0292: int[] attrTypes = new int[propDescs.length];
0293: for (int i = 0; i < propDescs.length; i++) {
0294: attrTypes[i] = DataTypes.typeForClass(propDescs[i]
0295: .getPropertyType());
0296: }
0297: return attrTypes;
0298: }
0299:
0300: public InstanceRepositoryTest(String name) {
0301: super (name, null);
0302: }
0303:
0304: protected InstanceRepositoryTest(String name, Properties svcMgrProps) {
0305: super (name, svcMgrProps);
0306: }
0307:
0308: protected Log getLogger() {
0309: return _logger;
0310: }
0311:
0312: // The sole purpose of this 'test' is to initialize the repositories for
0313: // the ensuing tests.
0314: public void testInitialize() throws IOException,
0315: RepositoryException {
0316: initializeRepositories();
0317: }
0318:
0319: public void testCreateProcessInstance() throws RepositoryException {
0320: for (int i = 0; i < PROC_INST.length; i++) {
0321: PROC_INST[i] = _instanceRepository.createProcessInstance(
0322: PROC_INST_DEF_ID[i], null, PROC_INST_NAME[i],
0323: PROC_INST_PRIORITY[i], PROC_INST_STATE[i],
0324: CREATED_DATE, PROC_INST_STARTED[i], PARTICIPANTS);
0325: PROC_INST_ID[i] = PROC_INST[i].getProcessInstanceId();
0326: }
0327:
0328: getLogger().info("testCreateProcessInstance passed");
0329: }
0330:
0331: public void testCreateProcessInstanceAttribute()
0332: throws RepositoryException {
0333:
0334: for (int i = 0; i < ATTR_INST_NAME.length; i++) {
0335: ATTR_INST[i] = _instanceRepository
0336: .createProcessInstanceAttribute(PROC_INST_ID[0],
0337: ATTR_INST_NAME[i], ATTR_INST_TYPE[i],
0338: ATTR_INST_VALUE[i]);
0339: }
0340:
0341: getLogger().info("testCreateProcessInstanceAttribute passed");
0342: }
0343:
0344: public void testFindProcessInstance() throws RepositoryException {
0345: for (int i = 0; i < PROC_INST.length; i++) {
0346: ProcessInstance procInst = _instanceRepository
0347: .findProcessInstance(PROC_INST_ID[i]);
0348: assertEquals("Wrong instance ID;", PROC_INST_ID[i],
0349: procInst.getProcessInstanceId());
0350: assertEquals("Wrong definition ID;", PROC_INST_DEF_ID[i],
0351: procInst.getProcessDefinitionId());
0352: assertEquals("Wrong name;", PROC_INST_NAME[i], procInst
0353: .getName());
0354: assertEquals("Wrong priority;", PROC_INST_PRIORITY[i],
0355: procInst.getPriority());
0356: assertEquals("Wrong state;", PROC_INST_STATE[i], procInst
0357: .getState());
0358: assertEquals("Wrong created date;", CREATED_DATE, procInst
0359: .getCreatedDate());
0360: assertEquals("Wrong started date;", PROC_INST_STARTED[i],
0361: procInst.getStartedDate());
0362: assertNull("Wrong completed date;", procInst
0363: .getCompletedDate());
0364: assertNotNull("Wrong number of participants;", procInst
0365: .getParticipants());
0366: assertEquals("Wrong number of participants;",
0367: PARTICIPANTS.length,
0368: procInst.getParticipants().length);
0369: }
0370:
0371: getLogger().info("testFindProcessInstance passed");
0372: }
0373:
0374: public void testFindProcessInstances() throws RepositoryException {
0375: WMFilter simpleFilter = new WMFilter(
0376: ProcessInstanceAttributes.STATE, WMFilter.EQ,
0377: String.valueOf(WMProcessInstanceState.OPEN_RUNNING_INT));
0378: WMFilter sqlFilter = new WMFilter(
0379: ProcessInstanceAttributes.STATE + " = "
0380: + WMProcessInstanceState.OPEN_RUNNING_INT
0381: + " AND priority = 0");
0382:
0383: ProcessInstance[] instances;
0384:
0385: instances = _instanceRepository.findProcessInstances(null,
0386: null, true);
0387: checkCount("All", 5, instances);
0388:
0389: instances = _instanceRepository.findProcessInstances(
0390: PROC_DEF_ID[0], null, true);
0391: checkCount("Unfiltered", 4, instances);
0392:
0393: instances = _instanceRepository.findProcessInstances(
0394: PROC_DEF_ID[0], simpleFilter, true);
0395: checkCount("Simple filtered", 3, instances);
0396:
0397: for (int i = 0; i < QB_ATTR_FILTER.length; i++) {
0398: instances = _instanceRepository.findProcessInstances(
0399: PROC_DEF_ID[0], QB_ATTR_FILTER[i], true);
0400: checkCount(QB_ATTR_FILTER_NAME[i], 1, instances);
0401: }
0402:
0403: instances = _instanceRepository.findProcessInstances(
0404: PROC_DEF_ID[0], sqlFilter, true);
0405: checkCount("SQL filtered", 2, instances);
0406:
0407: instances = _instanceRepository.findProcessInstances(null,
0408: null, false);
0409: checkIds("All", PROC_INST_ID, getProcessInstanceIds(instances));
0410:
0411: instances = _instanceRepository.findProcessInstances(
0412: PROC_DEF_ID[0], null, false);
0413: String[] expected = { PROC_INST_ID[0], PROC_INST_ID[1],
0414: PROC_INST_ID[2], PROC_INST_ID[3] };
0415: checkIds("Unfiltered", expected,
0416: getProcessInstanceIds(instances));
0417:
0418: instances = _instanceRepository.findProcessInstances(
0419: PROC_DEF_ID[0], simpleFilter, false);
0420: expected = new String[] { PROC_INST_ID[0], PROC_INST_ID[2],
0421: PROC_INST_ID[3] };
0422: checkIds("Simple filtered", expected,
0423: getProcessInstanceIds(instances));
0424:
0425: expected = new String[] { PROC_INST_ID[0] };
0426: for (int i = 0; i < QB_ATTR_FILTER.length; i++) {
0427: instances = _instanceRepository.findProcessInstances(
0428: PROC_DEF_ID[0], QB_ATTR_FILTER[i], false);
0429: checkIds(QB_ATTR_FILTER_NAME[i], expected,
0430: getProcessInstanceIds(instances));
0431: }
0432:
0433: instances = _instanceRepository.findProcessInstances(
0434: PROC_DEF_ID[0], sqlFilter, false);
0435: expected = new String[] { PROC_INST_ID[0], PROC_INST_ID[2] };
0436: checkIds("SQL filtered", expected,
0437: getProcessInstanceIds(instances));
0438:
0439: getLogger().info("testFindProcessInstances passed");
0440: }
0441:
0442: public void testFindProcessInstanceAttribute()
0443: throws RepositoryException {
0444: for (int i = 0; i < ATTR_INST.length; i++) {
0445: AttributeInstance attrInst = _instanceRepository
0446: .findProcessInstanceAttribute(PROC_INST_ID[0],
0447: ATTR_INST_NAME[i]);
0448: checkAttributeInstance("Singleton", PROC_INST_ID[0],
0449: PROC_INST_ID[0], ATTR_INST_NAME[i],
0450: ATTR_INST_TYPE[i], ATTR_INST_VALUE[i], attrInst);
0451: }
0452:
0453: getLogger().info("testFindProcessInstanceAttribute passed");
0454: }
0455:
0456: public void testFindProcessInstanceAttributes()
0457: throws RepositoryException {
0458:
0459: AttributeInstance[] attributes;
0460: for (int i = 0; i < ATTR_FILTER_TESTS.length; i++) {
0461: String hint = (String) ATTR_FILTER_TESTS[i][0] + " [i=" + i
0462: + ']';
0463: WMFilter filter = (WMFilter) ATTR_FILTER_TESTS[i][1];
0464: String[] names = (String[]) ATTR_FILTER_TESTS[i][2];
0465: int[] types = (int[]) ATTR_FILTER_TESTS[i][3];
0466: Object[] values = (Object[]) ATTR_FILTER_TESTS[i][4];
0467: attributes = _instanceRepository
0468: .findProcessInstanceAttributes(null,
0469: PROC_INST_ID[0], filter, null, true);
0470: int expectedCount = names.length;
0471: if (filter == null)
0472: expectedCount += ProcessInstanceAttributes.SYSTEM_ATTRIBUTES.length;
0473: checkCount(hint, expectedCount, attributes);
0474: attributes = _instanceRepository
0475: .findProcessInstanceAttributes(null,
0476: PROC_INST_ID[0], filter, null, false);
0477: checkAttributeInstances(
0478: hint,
0479: PROC_INST_ID[0],
0480: PROC_INST_ID[0],
0481: filter == null ? ProcessInstanceAttributes.SYSTEM_ATTRIBUTES
0482: : EMPTY_ATTR_NAMES,
0483: filter == null ? PROC_INST_ATTR_TYPES
0484: : EMPTY_ATTR_TYPES, names, types, values,
0485: attributes);
0486: }
0487:
0488: // Check the process instance's attribute collection.
0489: Collection c = PROC_INST[0].getAttributeInstances().values();
0490: checkAttributeInstances("Collection", PROC_INST_ID[0],
0491: PROC_INST_ID[0],
0492: ProcessInstanceAttributes.SYSTEM_ATTRIBUTES,
0493: PROC_INST_ATTR_TYPES, ATTR_INST_NAME, ATTR_INST_TYPE,
0494: ATTR_INST_VALUE, c);
0495:
0496: getLogger().info("testFindProcessInstanceAttributes passed");
0497: }
0498:
0499: public void testCreateActivityInstance() throws RepositoryException {
0500: for (int i = 0; i < ACT_INST.length; i++) {
0501: ACT_INST[i] = _instanceRepository.createActivityInstance(
0502: PROC_DEF_ID[0], PROC_INST_ID[0], ACT_DEF_ID[0],
0503: ACT_NAME[0], ACT_INST_JOIN[i], null, null,
0504: ACT_INST_PRIORITY[i], ACT_INST_STATE[i],
0505: PARTICIPANTS);
0506: ACT_INST[i].setStartedDate(ACT_INST_STARTED[i]);
0507: ACT_INST[i].setDueDate(ACT_INST_DUE[i]);
0508: ACT_INST[i].setTargetDate(ACT_INST_TARGET[i]);
0509: ACT_INST_ID[i] = ACT_INST[i].getActivityInstanceId();
0510: }
0511:
0512: getLogger().info("testCreateActivityInstance passed");
0513: }
0514:
0515: public void testCreateActivityInstanceAttribute()
0516: throws RepositoryException {
0517:
0518: for (int i = 0; i < ATTR_INST.length; i++) {
0519: ATTR_INST[i] = _instanceRepository
0520: .createActivityInstanceAttribute(PROC_INST_ID[0],
0521: ACT_INST_ID[0], ATTR_INST_NAME[i],
0522: ATTR_INST_TYPE[i], ATTR_INST_VALUE[i]);
0523: }
0524:
0525: getLogger().info("testCreateActivityInstanceAttribute passed");
0526: }
0527:
0528: public void testFindActivityInstance() throws RepositoryException {
0529: for (int i = 0; i < ACT_INST.length; i++) {
0530: ActivityInstance inst = _instanceRepository
0531: .findActivityInstance(ACT_INST_ID[i]);
0532: assertEquals("Wrong process definition ID;",
0533: PROC_DEF_ID[0], inst.getProcessDefinitionId());
0534: assertEquals("Wrong process instance ID;", PROC_INST_ID[0],
0535: inst.getProcessInstanceId());
0536: assertEquals("Wrong activity definition ID;",
0537: ACT_DEF_ID[0], inst.getActivityDefinitionId());
0538: assertEquals("Wrong activity instance ID;", ACT_INST_ID[i],
0539: inst.getActivityInstanceId());
0540: assertEquals("Wrong completed date;", null, inst
0541: .getCompletedDate());
0542: assertEquals("Wrong due date;", ACT_INST_DUE[i], inst
0543: .getDueDate());
0544: assertEquals("Wrong target date;", ACT_INST_TARGET[i], inst
0545: .getTargetDate());
0546: assertEquals("Wrong join;", ACT_INST_JOIN[i], inst
0547: .getJoin());
0548: assertEquals("Wrong name;", ACT_NAME[0], inst.getName());
0549: assertNotNull("Wrong number of participants;", inst
0550: .getParticipants());
0551: assertEquals("Wrong number of participants;",
0552: PARTICIPANTS.length, inst.getParticipants().length);
0553: assertEquals("Wrong priority;", ACT_INST_PRIORITY[i], inst
0554: .getPriority());
0555: assertEquals("Wrong started date;", ACT_INST_STARTED[i],
0556: inst.getStartedDate());
0557: assertEquals("Wrong state;", ACT_INST_STATE[i], inst
0558: .getState());
0559: assertEquals("Wrong process instance;", PROC_INST_ID[0],
0560: inst.getProcessInstance().getProcessInstanceId());
0561: }
0562:
0563: getLogger().info("testFindActivityInstance passed");
0564: }
0565:
0566: public void testFindActivityInstances() throws RepositoryException {
0567: WMFilter simpleFilter = new WMFilter(
0568: ActivityInstanceAttributes.STATE,
0569: WMFilter.EQ,
0570: String
0571: .valueOf(WMActivityInstanceState.OPEN_RUNNING_INT));
0572: WMFilter sqlFilter = new WMFilter(
0573: ActivityInstanceAttributes.STATE + " = "
0574: + WMActivityInstanceState.OPEN_NOTRUNNING_INT
0575: + " AND priority = 2");
0576:
0577: ActivityInstance[] activities;
0578:
0579: activities = _instanceRepository.findActivityInstances(
0580: PROC_DEF_ID[0], null, null, true);
0581: checkCount("Unfiltered", 4, activities);
0582:
0583: activities = _instanceRepository.findActivityInstances(
0584: PROC_DEF_ID[0], null, simpleFilter, true);
0585: checkCount("Simple filtered", 3, activities);
0586:
0587: for (int i = 0; i < QB_ATTR_FILTER.length; i++) {
0588: activities = _instanceRepository.findActivityInstances(
0589: PROC_DEF_ID[0], null, QB_ATTR_FILTER[i], true);
0590: checkCount(QB_ATTR_FILTER_NAME[i], 1, activities);
0591: }
0592:
0593: activities = _instanceRepository.findActivityInstances(
0594: PROC_DEF_ID[0], null, sqlFilter, true);
0595: checkCount("SQL filtered", 1, activities);
0596:
0597: activities = _instanceRepository.findActivityInstances(
0598: PROC_DEF_ID[0], null, null, false);
0599: checkIds("Unfiltered", ACT_INST_ID,
0600: getActivityInstanceIds(activities));
0601:
0602: activities = _instanceRepository.findActivityInstances(
0603: PROC_DEF_ID[0], null, simpleFilter, false);
0604: String[] expected = { ACT_INST_ID[0], ACT_INST_ID[2],
0605: ACT_INST_ID[3] };
0606: checkIds("Simple filtered", expected,
0607: getActivityInstanceIds(activities));
0608:
0609: expected = new String[] { ACT_INST_ID[0] };
0610: for (int i = 0; i < QB_ATTR_FILTER.length; i++) {
0611: activities = _instanceRepository.findActivityInstances(
0612: PROC_DEF_ID[0], null, QB_ATTR_FILTER[i], false);
0613: checkIds(QB_ATTR_FILTER_NAME[i], expected,
0614: getActivityInstanceIds(activities));
0615: }
0616:
0617: activities = _instanceRepository.findActivityInstances(
0618: PROC_DEF_ID[0], null, sqlFilter, false);
0619: expected = new String[] { ACT_INST_ID[1] };
0620: checkIds("SQL filtered", expected,
0621: getActivityInstanceIds(activities));
0622:
0623: getLogger().info("testFindActivityInstances passed");
0624: }
0625:
0626: public void testFindActivityInstanceAttribute()
0627: throws RepositoryException {
0628:
0629: for (int i = 0; i < ATTR_INST.length; i++) {
0630: AttributeInstance attrInst = _instanceRepository
0631: .findActivityInstanceAttribute(PROC_INST_ID[0],
0632: ACT_INST_ID[0], ATTR_INST_NAME[i]);
0633: checkAttributeInstance("Singleton", PROC_INST_ID[0],
0634: ACT_INST_ID[0], ATTR_INST_NAME[i],
0635: ATTR_INST_TYPE[i], ATTR_INST_VALUE[i], attrInst);
0636: }
0637: getLogger().info("testFindActivityInstanceAttribute passed");
0638: }
0639:
0640: public void testFindActivityInstanceAttributes()
0641: throws RepositoryException {
0642:
0643: AttributeInstance[] attributes;
0644: for (int i = 0; i < ATTR_FILTER_TESTS.length; i++) {
0645: String hint = (String) ATTR_FILTER_TESTS[i][0] + " [i=" + i
0646: + ']';
0647: WMFilter filter = (WMFilter) ATTR_FILTER_TESTS[i][1];
0648: String[] names = (String[]) ATTR_FILTER_TESTS[i][2];
0649: int[] types = (int[]) ATTR_FILTER_TESTS[i][3];
0650: Object[] values = (Object[]) ATTR_FILTER_TESTS[i][4];
0651: attributes = _instanceRepository
0652: .findActivityInstanceAttributes(null, null, null,
0653: ACT_INST_ID[0], filter, null, true);
0654: int expectedCount = names.length;
0655: if (filter == null)
0656: expectedCount += ActivityInstance.attributes.length;
0657: checkCount(hint, expectedCount, attributes);
0658: attributes = _instanceRepository
0659: .findActivityInstanceAttributes(null, null, null,
0660: ACT_INST_ID[0], filter, null, false);
0661: checkAttributeInstances(hint, PROC_INST_ID[0],
0662: ACT_INST_ID[0],
0663: filter == null ? ActivityInstance.attributes
0664: : EMPTY_ATTR_NAMES,
0665: filter == null ? ACT_INST_ATTR_TYPES
0666: : EMPTY_ATTR_TYPES, names, types, values,
0667: attributes);
0668: }
0669:
0670: // Check the activity instance's attribute collection.
0671: Collection c = ACT_INST[0].getAttributeInstances().values();
0672: checkAttributeInstances("Collection", PROC_INST_ID[0],
0673: ACT_INST_ID[0], ActivityInstance.attributes,
0674: ACT_INST_ATTR_TYPES, ATTR_INST_NAME, ATTR_INST_TYPE,
0675: ATTR_INST_VALUE, c);
0676:
0677: getLogger().info("testFindActivityInstanceAttributes passed");
0678: }
0679:
0680: public void testCreateWorkItem() throws RepositoryException {
0681: for (int i = 0; i < WORKITEM.length; i++) {
0682: WORKITEM[i] = _instanceRepository.createWorkItem(
0683: PROC_DEF_ID[0], PROC_INST_ID[0], ACT_INST_ID[0],
0684: WORKITEM_TOOL_INDEX[i], WORKITEM_STATE[i],
0685: WORKITEM_PARTICIPANT[i], WORKITEM_PARTICIPANT[i]);
0686: WORKITEM[i].setStartedDate(WORKITEM_STARTED[i]);
0687: WORKITEM[i].setDueDate(WORKITEM_DUE[i]);
0688: WORKITEM[i].setTargetDate(WORKITEM_TARGET[i]);
0689: WORKITEM_ID[i] = WORKITEM[i].getWorkItemId();
0690: }
0691:
0692: getLogger().info("testCreateWorkItem passed");
0693: }
0694:
0695: public void testCreateWorkItemAttribute()
0696: throws RepositoryException {
0697: for (int i = 0; i < ATTR_INST.length; i++) {
0698: ATTR_INST[i] = _instanceRepository.createWorkItemAttribute(
0699: PROC_INST_ID[0], WORKITEM_ID[0], ATTR_INST_NAME[i],
0700: ATTR_INST_TYPE[i], ATTR_INST_VALUE[i]);
0701: }
0702:
0703: getLogger().info("testCreateWorkItemAttribute passed");
0704: }
0705:
0706: public void testFindWorkItem() throws RepositoryException {
0707: for (int i = 0; i < WORKITEM.length; i++) {
0708: WorkItem workItem = _instanceRepository.findWorkItem(
0709: PROC_INST_ID[0], WORKITEM_ID[i]);
0710: assertEquals("Wrong work item ID;", WORKITEM_ID[i],
0711: workItem.getWorkItemId());
0712: assertEquals("Wrong activity instance ID;", ACT_INST_ID[0],
0713: workItem.getActivityInstanceId());
0714: assertNull("Wrong completed date;", workItem
0715: .getCompletedDate());
0716: assertEquals("Wrong due date;", WORKITEM_DUE[i], workItem
0717: .getDueDate());
0718: assertEquals("Wrong target date;", WORKITEM_TARGET[i],
0719: workItem.getTargetDate());
0720: assertEquals("Wrong name;", ACT_NAME[0], workItem.getName());
0721: assertEquals("Wrong participant;", WORKITEM_PARTICIPANT[i],
0722: workItem.getParticipant());
0723: assertEquals("Wrong priority;", ACT_INST_PRIORITY[0],
0724: workItem.getPriority());
0725: assertEquals("Wrong process definition ID;",
0726: PROC_DEF_ID[0], workItem.getProcessDefinitionId());
0727: assertEquals("Wrong process instance ID;", PROC_INST_ID[0],
0728: workItem.getProcessInstanceId());
0729: assertEquals("Wrong started date;", WORKITEM_STARTED[i],
0730: workItem.getStartedDate());
0731: assertEquals("Wrong state;", WORKITEM_STATE[i], workItem
0732: .getState());
0733: assertEquals("Wrong tool index;", WORKITEM_TOOL_INDEX[i],
0734: workItem.getToolIndex());
0735: assertEquals("Wrong activity instance;", ACT_INST_ID[0],
0736: workItem.getActivityInstance()
0737: .getActivityInstanceId());
0738: }
0739:
0740: getLogger().info("testFindWorkItem passed");
0741: }
0742:
0743: public void testFindWorkItems() throws RepositoryException {
0744: WMFilter simpleFilter = new WMFilter(WorkItemAttributes.STATE,
0745: WMFilter.EQ, String
0746: .valueOf(WMWorkItemState.OPEN_RUNNING_INT));
0747: WMFilter sqlFilter = new WMFilter(WorkItemAttributes.STATE
0748: + " = " + WMActivityInstanceState.OPEN_NOTRUNNING_INT
0749: + " AND priority = 1");
0750:
0751: WorkItem[] workitems;
0752:
0753: workitems = _instanceRepository.findWorkItems(null, true);
0754: checkCount("Unfiltered", 4, workitems);
0755:
0756: workitems = _instanceRepository.findWorkItems(simpleFilter,
0757: true);
0758: checkCount("Simple filtered", 3, workitems);
0759:
0760: for (int i = 0; i < QB_ATTR_FILTER.length; i++) {
0761: workitems = _instanceRepository.findWorkItems(
0762: QB_ATTR_FILTER[i], true);
0763: checkCount(QB_ATTR_FILTER_NAME[i], 1, workitems);
0764: }
0765:
0766: workitems = _instanceRepository.findWorkItems(sqlFilter, true);
0767: checkCount("SQL filtered", 1, workitems);
0768:
0769: workitems = _instanceRepository.findWorkItems(null, false);
0770: checkIds("Unfiltered", WORKITEM_ID, getWorkItemIds(workitems));
0771:
0772: workitems = _instanceRepository.findWorkItems(simpleFilter,
0773: false);
0774: String[] expected = { WORKITEM_ID[0], WORKITEM_ID[2],
0775: WORKITEM_ID[3] };
0776: checkIds("Simple filtered", expected, getWorkItemIds(workitems));
0777:
0778: expected = new String[] { WORKITEM_ID[0] };
0779: for (int i = 0; i < QB_ATTR_FILTER.length; i++) {
0780: workitems = _instanceRepository.findWorkItems(
0781: QB_ATTR_FILTER[i], false);
0782: checkIds(QB_ATTR_FILTER_NAME[i], expected,
0783: getWorkItemIds(workitems));
0784: }
0785:
0786: workitems = _instanceRepository.findWorkItems(sqlFilter, false);
0787: expected = new String[] { WORKITEM_ID[1] };
0788: checkIds("SQL filtered", expected, getWorkItemIds(workitems));
0789:
0790: getLogger().info("testFindWorkItems passed");
0791: }
0792:
0793: public void testFindWorkItemAttribute() throws RepositoryException {
0794: for (int i = 0; i < ATTR_INST.length; i++) {
0795: AttributeInstance attrInst = _instanceRepository
0796: .findWorkItemAttribute(PROC_INST_ID[0],
0797: WORKITEM_ID[0], ATTR_INST_NAME[i]);
0798: checkAttributeInstance("Singleton", PROC_INST_ID[0],
0799: WORKITEM_ID[0], ATTR_INST_NAME[i],
0800: ATTR_INST_TYPE[i], ATTR_INST_VALUE[i], attrInst);
0801: }
0802:
0803: getLogger().info("testFindWorkItemAttribute passed");
0804: }
0805:
0806: public void testFindWorkItemAttributes() throws RepositoryException {
0807: AttributeInstance[] attributes;
0808: for (int i = 0; i < ATTR_FILTER_TESTS.length; i++) {
0809: String hint = (String) ATTR_FILTER_TESTS[i][0] + " [i=" + i
0810: + ']';
0811: WMFilter filter = (WMFilter) ATTR_FILTER_TESTS[i][1];
0812: String[] names = (String[]) ATTR_FILTER_TESTS[i][2];
0813: int[] types = (int[]) ATTR_FILTER_TESTS[i][3];
0814: Object[] values = (Object[]) ATTR_FILTER_TESTS[i][4];
0815: attributes = _instanceRepository.findWorkItemAttributes(
0816: null, WORKITEM_ID[0], filter, true);
0817: int expectedCount = names.length;
0818: if (filter == null)
0819: expectedCount += WorkItem.attributes.length;
0820: checkCount(hint, expectedCount, attributes);
0821: attributes = _instanceRepository.findWorkItemAttributes(
0822: null, WORKITEM_ID[0], filter, false);
0823: checkAttributeInstances(hint, PROC_INST_ID[0],
0824: WORKITEM_ID[0],
0825: filter == null ? WorkItem.attributes
0826: : EMPTY_ATTR_NAMES,
0827: filter == null ? WORK_ITEM_ATTR_TYPES
0828: : EMPTY_ATTR_TYPES, names, types, values,
0829: attributes);
0830: }
0831:
0832: // Check the process instance's attribute collection.
0833: Collection c = WORKITEM[0].getAttributeInstances().values();
0834: checkAttributeInstances("Collection", PROC_INST_ID[0],
0835: WORKITEM_ID[0], WorkItem.attributes,
0836: WORK_ITEM_ATTR_TYPES, ATTR_INST_NAME, ATTR_INST_TYPE,
0837: ATTR_INST_VALUE, c);
0838:
0839: getLogger().info("testFindWorkItemAttributes passed");
0840: }
0841:
0842: public void testDeleteProcessInstance() throws RepositoryException {
0843: _instanceRepository.deleteProcessInstance(PROC_INST_ID[0]);
0844: _instanceRepository.deleteProcessInstance(PROC_INST_ID[1]);
0845: _instanceRepository.deleteProcessInstance(PROC_INST_ID[2]);
0846: _instanceRepository.deleteProcessInstance(PROC_INST_ID[3]);
0847: _instanceRepository.deleteProcessInstance(PROC_INST_ID[4]);
0848: ProcessInstance[] instances = _instanceRepository
0849: .findProcessInstances(PROC_DEF_ID[0], null, true);
0850: assertEquals("Failed to delete instances;", 0, instances.length);
0851: instances = _instanceRepository.findProcessInstances(
0852: PROC_DEF_ID[1], null, true);
0853: assertEquals("Failed to delete instances;", 0, instances.length);
0854:
0855: getLogger().info("testDeleteProcessInstance passed");
0856: }
0857:
0858: public void testPurge() throws RepositoryException {
0859: _instanceRepository.purge();
0860: _processRepository.purge();
0861:
0862: getLogger().info("testPurge passed");
0863: }
0864:
0865: public void testUninitialize() throws IOException,
0866: RepositoryException {
0867: uninitializeRepositories();
0868: }
0869:
0870: protected void initializeRepositories() throws IOException,
0871: RepositoryException {
0872:
0873: try {
0874: super .initializeRepositories();
0875:
0876: // Read the XPDL file.
0877: XPDLParser parser = new Dom4JXPDLParser();
0878: InputStream in = getClass().getResourceAsStream(
0879: "/org/obe/test/WMClientTest1.xpdl");
0880: if (in == null)
0881: fail("Failed to load resource /org/obe/test/WMClientTest1.xpdl");
0882: XPDLPackage pkg = parser.parse(in);
0883: in.close();
0884: PACKAGE_ID[0] = pkg.getId();
0885: WorkflowProcess[] processes = pkg.getWorkflowProcess();
0886: assertEquals("Package contains wrong number of workflows;",
0887: 2, processes.length);
0888: PROC_DEF_ID[0] = processes[0].getId();
0889: PROC_DEF_ID[1] = processes[1].getId();
0890: WorkflowProcess process = processes[0];
0891: Activity[] activities = process.getActivity();
0892: Activity activity = activities[0];
0893: ACT_DEF_ID[0] = activity.getId();
0894: ACT_NAME[0] = activity.getName();
0895: activity = activities[1];
0896: ACT_DEF_ID[1] = activity.getId();
0897: ACT_NAME[1] = activity.getName();
0898:
0899: // Persist the package in the process repository.
0900: _processRepository.createPackage(pkg);
0901:
0902: // Set up test data.
0903: PROC_INST_DEF_ID[0] = PROC_DEF_ID[0];
0904: PROC_INST_DEF_ID[1] = PROC_DEF_ID[0];
0905: PROC_INST_DEF_ID[2] = PROC_DEF_ID[0];
0906: PROC_INST_DEF_ID[3] = PROC_DEF_ID[0];
0907: PROC_INST_DEF_ID[4] = PROC_DEF_ID[1];
0908:
0909: getLogger().info("Repositories initialized");
0910: } catch (XPDLParserException e) {
0911: throw new RepositoryException(e);
0912: }
0913: }
0914:
0915: private void checkAttributeInstance(String hint, String procInstId,
0916: String ownerId, String attrName, int attrType,
0917: Object attrValue, AttributeInstance attrInst) {
0918:
0919: assertEquals(hint + " process instance ID is wrong;",
0920: procInstId, attrInst.getOwner().getProcessInstanceId());
0921: assertEquals(hint + " owner ID is wrong;", ownerId, attrInst
0922: .getOwner().getEntityId());
0923: assertEquals(hint + " name is wrong;", attrName, attrInst
0924: .getName());
0925: assertEquals(hint + " type is wrong;", attrType, attrInst
0926: .getType());
0927: if (attrValue instanceof Double) {
0928: double actual = ((Double) attrInst.getValue())
0929: .doubleValue();
0930: assertEquals(hint + " value is wrong;",
0931: ((Double) attrValue).doubleValue(), actual,
0932: DOUBLE_TOLERANCE);
0933: } else {
0934: assertEquals(hint + " value is wrong;", attrValue, attrInst
0935: .getValue());
0936: }
0937: }
0938:
0939: private void checkAttributeInstances(String hint,
0940: String procInstId, String ownerId, String[] sysAttrNames,
0941: int[] sysAttrTypes, String[] names, int[] types,
0942: Object[] values, Collection attributes) {
0943:
0944: AttributeInstance[] attrs = (AttributeInstance[]) attributes
0945: .toArray(new AttributeInstance[attributes.size()]);
0946: checkAttributeInstances(hint, procInstId, ownerId,
0947: sysAttrNames, sysAttrTypes, names, types, values, attrs);
0948: }
0949:
0950: private void checkAttributeInstances(String hint,
0951: String procInstId, String ownerId, String[] sysAttrNames,
0952: int[] sysAttrTypes, String[] names, int[] types,
0953: Object[] values, AttributeInstance[] attributes) {
0954:
0955: if (sysAttrNames != null) {
0956: String[] tmpNames = new String[names.length
0957: + sysAttrNames.length];
0958: int[] tmpTypes = new int[types.length + sysAttrTypes.length];
0959: System.arraycopy(names, 0, tmpNames, 0, names.length);
0960: System.arraycopy(types, 0, tmpTypes, 0, types.length);
0961: System.arraycopy(sysAttrNames, 0, tmpNames, names.length,
0962: sysAttrNames.length);
0963: System.arraycopy(sysAttrTypes, 0, tmpTypes, names.length,
0964: sysAttrTypes.length);
0965: names = tmpNames;
0966: types = tmpTypes;
0967: }
0968: assertEquals(hint + " count is wrong;", names.length,
0969: attributes.length);
0970: next: for (int i = 0; i < names.length; i++) {
0971: for (int j = 0; j < attributes.length; j++) {
0972: AttributeInstance attr = attributes[j];
0973: if (attr.getName().equals(names[i])) {
0974: checkAttributeInstance(hint, procInstId, ownerId,
0975: names[i], types[i], values[i], attr);
0976: break next;
0977: }
0978: }
0979: fail(hint + " query failed to find attribute: " + names[i]);
0980: }
0981: }
0982:
0983: private String[] getProcessInstanceIds(ProcessInstance[] instances) {
0984: String[] instanceIds = new String[instances.length];
0985: for (int i = 0; i < instances.length; i++)
0986: instanceIds[i] = instances[i].getProcessInstanceId();
0987: return instanceIds;
0988: }
0989:
0990: private String[] getActivityInstanceIds(
0991: ActivityInstance[] activities) {
0992: String[] instanceIds = new String[activities.length];
0993: for (int i = 0; i < activities.length; i++)
0994: instanceIds[i] = activities[i].getActivityInstanceId();
0995: return instanceIds;
0996: }
0997:
0998: private String[] getWorkItemIds(WorkItem[] workitems) {
0999: String[] instanceIds = new String[workitems.length];
1000: for (int i = 0; i < workitems.length; i++)
1001: instanceIds[i] = workitems[i].getWorkItemId();
1002: return instanceIds;
1003: }
1004: }
|