diff options
author | Bob Brodt | 2017-02-21 18:44:36 +0000 |
---|---|---|
committer | Bob Brodt | 2017-02-21 18:44:36 +0000 |
commit | a069490f577c4d5a88726b8fba99a8492ef40053 (patch) | |
tree | df9edfa9733f3fb89209212cb1248a98db991dea | |
parent | 7096dd1f321793f55cbb0e15ed4d5a71d0ad5b44 (diff) | |
download | org.eclipse.bpmn2-modeler-a069490f577c4d5a88726b8fba99a8492ef40053.tar.gz org.eclipse.bpmn2-modeler-a069490f577c4d5a88726b8fba99a8492ef40053.tar.xz org.eclipse.bpmn2-modeler-a069490f577c4d5a88726b8fba99a8492ef40053.zip |
Working towards implementing dynamically loadable custom WID editor
The Work Items in the Service Tasks palette should be ordered
https://issues.jboss.org/browse/JBPM-5636
Introduce unit tests for BPMN2 Modeler
workhttps://bugs.eclipse.org/bugs/show_bug.cgi?id=512240
34 files changed, 784 insertions, 104 deletions
diff --git a/parent/pom.xml b/parent/pom.xml index 98345160..02bb5211 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -32,6 +32,7 @@ <tycho-version>0.21.0</tycho-version> <tycho-extras-version>${tycho-version}</tycho-extras-version> <BUILD_ALIAS>Final</BUILD_ALIAS> + <eclipse.orbit.url>http://download.eclipse.org/tools/orbit/downloads/drops/repository</eclipse.orbit.url> </properties> <profiles> @@ -131,7 +132,20 @@ <eclipse-site>http://download.eclipse.org/releases/neon</eclipse-site> <platform-version>[4.6,5.0)</platform-version> <platform-version-name>neon</platform-version-name> + <eclipse.orbit.url>http://download.eclipse.org/tools/orbit/downloads/drops/R20160520211859/repository</eclipse.orbit.url> </properties> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <useUIThread>false</useUIThread> + </configuration> + </plugin> + </plugins> + </build> </profile> <profile> <id>platform-oxygen</id> @@ -145,7 +159,20 @@ <eclipse-site>http://download.eclipse.org/releases/oxygen</eclipse-site> <platform-version>[4.7,5.0)</platform-version> <platform-version-name>oxygen</platform-version-name> + <eclipse.orbit.url>http://download.eclipse.org/tools/orbit/S-builds/S20170120205402/repository</eclipse.orbit.url> </properties> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <useUIThread>false</useUIThread> + </configuration> + </plugin> + </plugins> + </build> </profile> <profile> <id>sign</id> @@ -200,6 +227,15 @@ <repositories> <repository> + <snapshots> + <enabled>false</enabled> + </snapshots> + <id>central</id> + <name>Central Repository</name> + <url>https://repo.maven.apache.org/maven2</url> + </repository> + + <repository> <id>eclipse-platform</id> <layout>p2</layout> <url>${eclipse-site}</url> @@ -279,7 +315,7 @@ </repository> <repository> <id>eclipse-orbit</id> - <url>http://download.eclipse.org/tools/orbit/downloads/drops/repository</url> + <url>${eclipse.orbit.url}</url> <layout>p2</layout> <snapshots> <enabled>true</enabled> diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java index 5ca7a493..9db4d72a 100644 --- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java +++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java @@ -824,7 +824,12 @@ public class Bpmn2Preferences implements IResourceChangeListener, IPropertyChang public ModelEnablementDescriptor createToolProfile(TargetRuntime rt, String id, String profileName, String description) { ModelEnablementDescriptor med = null; boolean createNew = false; - if (id!=null && !id.isEmpty() && profileName!=null && !profileName.isEmpty()) { + if (profileName==null || profileName.isEmpty()) { + profileName = "default"; + if (description==null || description.isEmpty()) + description = "Default Profile"; + } + if (id!=null && !id.isEmpty()) { try { Preferences prefs = null; String path = getToolProfilePath(rt); diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Messages.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Messages.java index bdcc1141..26f91a94 100644 --- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Messages.java +++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/Messages.java @@ -16,6 +16,9 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.bpmn2.modeler.core.runtime.messages"; //$NON-NLS-1$ public static String TargetRuntime_Config_Error; public static String TargetRuntimeConfigurationException_Config_Error; + public static String TargetRuntime_Duplicate_Custom_Task_Title; + public static String TargetRuntime_Duplicate_Custom_Task_ID_Message; + public static String TargetRuntime_Duplicate_Custom_Task_Name_Message; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java index 18a476be..0f46bb10 100644 --- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java +++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java @@ -21,6 +21,7 @@ import java.util.Comparator; import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import java.util.TreeSet; import org.eclipse.bpmn2.Bpmn2Package; import org.eclipse.bpmn2.modeler.core.IBpmn2RuntimeExtension; @@ -48,6 +49,9 @@ import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.graphiti.platform.IDiagramBehavior; import org.eclipse.graphiti.platform.IDiagramContainer; import org.eclipse.graphiti.ui.editor.DiagramEditor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; @@ -60,6 +64,50 @@ public class TargetRuntime extends BaseRuntimeExtensionDescriptor implements IRu public static final String EXTENSION_NAME = "runtime"; //$NON-NLS-1$ + @SuppressWarnings("serial") + public class CustomTaskSet extends TreeSet<CustomTaskDescriptor> { + public CustomTaskSet() { + super(new Comparator<CustomTaskDescriptor>() { + @Override + public int compare(CustomTaskDescriptor t1, CustomTaskDescriptor t2) { + return t1.getId().compareTo(t2.getId()); + } + }); + } + + @Override + public boolean add(CustomTaskDescriptor customTaskDescriptor) { + if (this.contains(customTaskDescriptor)) { + // a custom task with this same ID already exists + MessageDialog.openError(Display.getDefault().getActiveShell(), + Messages.TargetRuntime_Duplicate_Custom_Task_Title, + NLS.bind( + Messages.TargetRuntime_Duplicate_Custom_Task_ID_Message, + customTaskDescriptor.getId() + ) + ); + return false; + } + for (CustomTaskDescriptor ctd : this) { + if (ctd.getName().equals(customTaskDescriptor.getName())) { + // a custom task with a different ID, but the same name already exists + MessageDialog.openWarning(Display.getDefault().getActiveShell(), + Messages.TargetRuntime_Duplicate_Custom_Task_Title, + NLS.bind( + Messages.TargetRuntime_Duplicate_Custom_Task_Name_Message, + new Object[] { + customTaskDescriptor.getId(), + ctd.getId(), + ctd.getName() + } + ) + ); + } + } + return super.add(customTaskDescriptor); + } + } + // extension point ID for Target Runtimes public static final String RUNTIME_EXTENSION_ID = "org.eclipse.bpmn2.modeler.runtime"; //$NON-NLS-1$ public static final String DEFAULT_RUNTIME_ID = "org.eclipse.bpmn2.modeler.runtime.none"; //$NON-NLS-1$ @@ -79,7 +127,7 @@ public class TargetRuntime extends BaseRuntimeExtensionDescriptor implements IRu // the lists of Extension Descriptors defined in the extension plugin's plugin.xml protected List<ModelDescriptor> modelDescriptors; protected List<PropertyTabDescriptor> propertyTabDescriptors; - protected List<CustomTaskDescriptor> customTaskDescriptors; + protected CustomTaskSet customTaskDescriptors; protected List<ModelExtensionDescriptor> modelExtensionDescriptors; protected List<ModelEnablementDescriptor> modelEnablementDescriptors; // protected ModelEnablementDescriptor defaultModelEnablementDescriptors; @@ -935,10 +983,10 @@ public class TargetRuntime extends BaseRuntimeExtensionDescriptor implements IRu /* * List Accessors for all Runtime Extension Descriptors */ - public List<CustomTaskDescriptor> getCustomTaskDescriptors() + public CustomTaskSet getCustomTaskDescriptors() { if (customTaskDescriptors==null) { - customTaskDescriptors = new ArrayList<CustomTaskDescriptor>(); + customTaskDescriptors = new CustomTaskSet(); } return customTaskDescriptors; } diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/messages.properties b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/messages.properties index 6bb0b80f..565cb753 100644 --- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/messages.properties +++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/messages.properties @@ -9,4 +9,10 @@ # Red Hat, Inc. - initial API and implementation #------------------------------------------------------------------------------- TargetRuntime_Config_Error=Error in Configuration File -TargetRuntimeConfigurationException_Config_Error=Configuration Error for Target Runtime +TargetRuntimeConfigurationException_Config_Error=Configuration Error for Target Runtime +TargetRuntime_Duplicate_Custom_Task_Title=Duplicate Custom Task +TargetRuntime_Duplicate_Custom_Task_ID_Message=The Custom Task with ID \"{0}\" is already defined +TargetRuntime_Duplicate_Custom_Task_Name_Message=The Custom Task with ID \"{0}\"\n\ + has the same name as \"{1}\".\n\ + It may not be possible to distinguish between the two items\n\ + named \"{2}\" in the Tool Palette! diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/validation/SyntaxCheckerUtils.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/validation/SyntaxCheckerUtils.java index aa5fd2ce..b9a670a0 100644 --- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/validation/SyntaxCheckerUtils.java +++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/validation/SyntaxCheckerUtils.java @@ -10,8 +10,14 @@ *******************************************************************************/ package org.eclipse.bpmn2.modeler.core.validation; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.CharacterCodingException; +import java.nio.charset.Charset; + public class SyntaxCheckerUtils { private static char invalidChar; + private final static Charset charsetUTF8 = Charset.forName("UTF-8"); public static char getInvalidChar() { return invalidChar; @@ -111,6 +117,27 @@ public class SyntaxCheckerUtils { if (name==null || name.isEmpty()) return false; + try { + System.out.println("isJavaIdentifier checking for UTF8 string"); + CharBuffer charbuf = charsetUTF8.newDecoder().decode(ByteBuffer.wrap(name.getBytes())); + char c = charbuf.charAt(0); + int nameLength = charbuf.length(); + + if (Character.isJavaIdentifierStart(c)) { + // Check the rest of the characters + for (int i = 1; i < nameLength; i++) { + c = charbuf.charAt(i); + if (!Character.isJavaIdentifierPart(c)) { + invalidChar = c; + return false; + } + } + + // All characters have been checked + return true; + } + } catch (CharacterCodingException e) { + } int nameLength = name.length(); // Check first character diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/META-INF/MANIFEST.MF b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/META-INF/MANIFEST.MF index 8117bce0..ab49aaaf 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/META-INF/MANIFEST.MF @@ -37,6 +37,12 @@ Export-Package: org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5, org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.property, org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.property.adapters, org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.util, + org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.customeditor, + org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core, + org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl, + org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype, + org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl, + org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type, org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid Import-Package: org.eclipse.bpmn2.modeler.help, org.eclipse.bpmn2.modeler.ui, diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/build.properties b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/build.properties index 97dcdf1a..f291b185 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/build.properties +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/build.properties @@ -16,4 +16,11 @@ bin.includes = META-INF/,\ model/,\ icons/,\ about.html,\ - plugin.properties + plugin.properties,\ + bin/ +src.includes = bin/,\ + src/,\ + META-INF/,\ + about.html,\ + model/,\ + icons/ diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java index 6a1fd6d2..9c061852 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/JBPM5RuntimeExtension.java @@ -150,14 +150,14 @@ public class JBPM5RuntimeExtension implements IBpmn2RuntimeExtension { loader.load(project); if (loader.getClasspathWIDs().size() > 0) { - workItemDefinitions.addAll(loader.getClasspathWIDs().values()); + workItemDefinitions.addAll(loader.getClasspathWIDs()); for (Entry<String, ImageDescriptor> e : loader.getClasspathIcons().entrySet()) { CustomTaskImageProvider.registerImage(e.getKey(), e.getValue()); } } if (loader.getProjectWIDs().size() > 0) { - workItemDefinitions.addAll(loader.getProjectWIDs().values()); + workItemDefinitions.addAll(loader.getProjectWIDs()); for (Entry<String, ImageDescriptor> e : loader.getProjectIcons().entrySet()) { CustomTaskImageProvider.registerImage(e.getKey(), e.getValue()); } @@ -377,7 +377,7 @@ public class JBPM5RuntimeExtension implements IBpmn2RuntimeExtension { private Property createIOSpecificationSection ( CustomTaskDescriptor ct, WorkItemDefinition wid ) { Property ioSpecification = new Property (null,"ioSpecification", null); //$NON-NLS-1$ - for (Entry<String, String> entry : wid.getParameters().entrySet()) { + for (Entry<String, Object> entry : wid.getParameters().entrySet()) { Property dataInputs = new Property(ioSpecification,"dataInputs", null); //$NON-NLS-1$ Property dataInputsName = new Property(dataInputs,"name", null); //$NON-NLS-1$ dataInputsName.getValues().add(entry.getKey()); @@ -394,7 +394,7 @@ public class JBPM5RuntimeExtension implements IBpmn2RuntimeExtension { // dataOutputs.getValues().add(dataOutputsName); // ioSpecification.getValues().add(dataOutputs); // } else { - for (Entry<String, String> entry : wid.getResults().entrySet()) { + for (Entry<String, Object> entry : wid.getResults().entrySet()) { Property dataOutputs = new Property(ioSpecification,"dataOutputs", null); //$NON-NLS-1$ Property dataOutputsName = new Property(dataOutputs,"name", null); //$NON-NLS-1$ dataOutputsName.getValues().add(entry.getKey()); diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/DataTypeRegistry.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/DataTypeRegistry.java index f4dda85d..80468476 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/DataTypeRegistry.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/DataTypeRegistry.java @@ -20,6 +20,8 @@ import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatyp import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.EnumDataType; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.FloatDataType; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.IntegerDataType; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.ListDataType; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.ObjectDataType; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.StringDataType; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.UndefinedDataType; import org.eclipse.core.runtime.Assert; @@ -40,6 +42,8 @@ public class DataTypeRegistry { instance.put("BooleanDataType", new NewInstanceDataTypeFactory(BooleanDataType.class)); //$NON-NLS-1$ instance.put("EnumDataType", new NewInstanceDataTypeFactory(EnumDataType.class)); //$NON-NLS-1$ instance.put("FloatDataType", new NewInstanceDataTypeFactory(FloatDataType.class)); //$NON-NLS-1$ + instance.put("ListDataType", new NewInstanceDataTypeFactory(ListDataType.class)); //$NON-NLS-1$ + instance.put("ObjectDataType", new NewInstanceDataTypeFactory(ObjectDataType.class)); //$NON-NLS-1$ instance.put("IntegerDataType", new NewInstanceDataTypeFactory(IntegerDataType.class)); //$NON-NLS-1$ instance.put("StringDataType", new NewInstanceDataTypeFactory(StringDataType.class)); //$NON-NLS-1$ instance.put("UndefinedDataType", new NewInstanceDataTypeFactory(UndefinedDataType.class)); //$NON-NLS-1$ diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/impl/type/ListDataType.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/impl/type/ListDataType.java new file mode 100644 index 00000000..a10b07bb --- /dev/null +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/impl/type/ListDataType.java @@ -0,0 +1,75 @@ +/* + * Copyright 2005 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.List; + +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.TypeObject; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataType; + +/** + * Representation of a list datatype. + * All elements in the list must have the same datatype. + */ +public class ListDataType extends ObjectDataType implements TypeObject { + + private static final long serialVersionUID = 510l; + + private DataType dataType; + + public ListDataType() { + setClassName("java.util.List"); + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + dataType = (DataType)in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(dataType); + } + + public ListDataType(DataType dataType) { + setType(dataType); + } + + public void setType(final DataType dataType) { + this.dataType = dataType; + } + + public DataType getType() { + return this.dataType; + } + + public boolean verifyDataType(final Object value) { + if (value == null) { + return true; + } + if (value instanceof List) { + for (Object o: (List<?>) value) { + if (dataType != null && !dataType.verifyDataType(o)) { + return false; + } + } + return true; + } + return false; + } +} diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/impl/type/ObjectDataType.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/impl/type/ObjectDataType.java new file mode 100644 index 00000000..1e1f6037 --- /dev/null +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/drools/process/core/datatype/impl/type/ObjectDataType.java @@ -0,0 +1,111 @@ +/* + * Copyright 2005 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataType; + +//import com.thoughtworks.xstream.XStream; + +/** + * Representation of an object datatype. + */ +public class ObjectDataType implements DataType { + + private static final long serialVersionUID = 510l; + + private String className; + + private ClassLoader classLoader; + + public ObjectDataType() { + } + + public ObjectDataType(String className) { + setClassName(className); + } + + public ObjectDataType(String className, ClassLoader classLoader) { + setClassName(className); + setClassLoader(classLoader); + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public void setClassLoader(ClassLoader classLoader) { + this.classLoader = classLoader; + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + className = (String) in.readObject(); + } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(className); + } + + public boolean verifyDataType(final Object value) { + if (value == null) { + return true; + } + try { + Class<?> clazz = Class.forName(className, true, value.getClass().getClassLoader()); + if (clazz.isInstance(value)) { + return true; + } + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException( + "Could not find data type " + className); + } + return false; + } + + public Object readValue(String value) { +// XStream xstream = new XStream(); +// if (classLoader != null) { +// xstream.setClassLoader(classLoader); +// } +// return xstream.fromXML(value); + return null; + } + + public String writeValue(Object value) { +// XStream xstream = new XStream(); +// if (classLoader != null) { +// xstream.setClassLoader(classLoader); +// } +// return xstream.toXML(value); + return ""; + } + + public String getStringType() { + return className == null ? "java.lang.Object" : className; + } +} diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/features/JbpmCustomTaskFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/features/JbpmCustomTaskFeatureContainer.java index d96db9a7..a7b94bf1 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/features/JbpmCustomTaskFeatureContainer.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/features/JbpmCustomTaskFeatureContainer.java @@ -12,9 +12,12 @@ ******************************************************************************/ package org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.features; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import org.eclipse.bpmn2.Activity; import org.eclipse.bpmn2.BaseElement; import org.eclipse.bpmn2.DataInput; import org.eclipse.bpmn2.DataInputAssociation; @@ -42,10 +45,11 @@ import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.JBPM5RuntimeExtension; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.customeditor.SampleCustomEditor; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.ParameterDefinition; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.Work; -import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.WorkDefinition; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.WorkEditor; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataType; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataTypeFactory; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataTypeRegistry; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.impl.type.StringDataType; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl.ParameterDefinitionImpl; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl.WorkDefinitionImpl; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl.WorkImpl; @@ -141,7 +145,7 @@ public class JbpmCustomTaskFeatureContainer extends CustomShapeFeatureContainer WorkItemDefinition wid = rx.getWorkItemDefinition(id); if (ioSpecification!=null && wid!=null) { for (DataInput input : ioSpecification.getDataInputs()) { - for (Entry<String, String> entry : wid.getParameters().entrySet()) { + for (Entry<String, Object> entry : wid.getParameters().entrySet()) { if (input.getName().equals(entry.getKey())) { if (entry.getValue()!=null) input.setItemSubjectRef(JbpmModelUtil.getDataType(context.getTargetContainer(), entry.getValue())); @@ -150,7 +154,7 @@ public class JbpmCustomTaskFeatureContainer extends CustomShapeFeatureContainer } } for (DataOutput output : ioSpecification.getDataOutputs()) { - for (Entry<String, String> entry : wid.getResults().entrySet()) { + for (Entry<String, Object> entry : wid.getResults().entrySet()) { if (output.getName().equals(entry.getKey())) { if (entry.getValue()!=null) output.setItemSubjectRef(JbpmModelUtil.getDataType(context.getTargetContainer(), entry.getValue())); @@ -227,6 +231,7 @@ public class JbpmCustomTaskFeatureContainer extends CustomShapeFeatureContainer TargetRuntime rt = TargetRuntime.getRuntime(baseElement); JBPM5RuntimeExtension rte = (JBPM5RuntimeExtension)rt.getRuntimeExtension(); WorkItemDefinition wid = ((JBPM5RuntimeExtension)rte).getWorkItemDefinition(customTaskId); + WorkEditor editor = null; if (wid!=null) { String customEditor = wid.getEclipseCustomEditor(); if (customEditor!=null && !customEditor.isEmpty()) { @@ -236,13 +241,46 @@ public class JbpmCustomTaskFeatureContainer extends CustomShapeFeatureContainer IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(uri.segment(1)); JavaProjectClassLoader cl = new JavaProjectClassLoader(project); if (cl!=null) { - return new SampleCustomEditor(Display.getDefault().getActiveShell()); + editor = new SampleCustomEditor(Display.getDefault().getActiveShell()); + Work work = new WorkImpl(); + // set actual parameter values from Task object here... + work.setName(((Activity)baseElement).getName()); + Map<String, Object> parameters = new HashMap<String, Object>(); + parameters.putAll(wid.getParameters()); + work.setParameters(parameters); + editor.setWork(work); + + WorkDefinitionImpl workDefinition = new WorkDefinitionImpl(); + for (Entry<String, Object> entry : wid.getParameters().entrySet()) { + ParameterDefinitionImpl pd = new ParameterDefinitionImpl(); + pd.setName(entry.getKey()); + DataType type; + if (entry.getValue() instanceof DataType) + type = (DataType) entry.getValue(); + else + type = new StringDataType(); + pd.setType(type); + workDefinition.addParameter(pd); + work.addParameterDefinition(pd); + } + for (Entry<String, Object> entry : wid.getResults().entrySet()) { + ParameterDefinitionImpl pd = new ParameterDefinitionImpl(); + pd.setName(entry.getKey()); + DataType type; + if (entry.getValue() instanceof DataType) + type = (DataType) entry.getValue(); + else + type = new StringDataType(); + pd.setType(type); + workDefinition.addResult(pd); + } + editor.setWorkDefinition(workDefinition); } } catch (Exception ignore) { } } } - return null; + return editor; } public class ConfigureWorkItemFeature implements ICustomFeature { @@ -340,9 +378,16 @@ public class JbpmCustomTaskFeatureContainer extends CustomShapeFeatureContainer WorkDefinitionImpl wd = new WorkDefinitionImpl(); for (String name : workItemDefinition.getParameters().keySet()) { - String type = workItemDefinition.getParameters().get(name); - DataTypeFactory factory = DataTypeRegistry.getFactory(type); - wd.addParameter( new ParameterDefinitionImpl(name,factory.createDataType()) ); + Object type = workItemDefinition.getParameters().get(name); + DataTypeFactory factory = null; + if (type instanceof DataType) { + factory = DataTypeRegistry.getFactory(((DataType)type).getStringType()); + } + else if (type instanceof String) { + factory = DataTypeRegistry.getFactory((String)type); + } + if (factory!=null) + wd.addParameter( new ParameterDefinitionImpl(name,factory.createDataType()) ); } WorkImpl w = new WorkImpl(); diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/property/JbpmTaskDetailComposite.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/property/JbpmTaskDetailComposite.java index 8e1ae7e1..f01ff23a 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/property/JbpmTaskDetailComposite.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/property/JbpmTaskDetailComposite.java @@ -15,6 +15,7 @@ package org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.property; import java.util.ArrayList; import java.util.List; +import java.util.Map.Entry; import org.eclipse.bpmn2.DataAssociation; import org.eclipse.bpmn2.DataInput; @@ -53,6 +54,15 @@ import org.eclipse.bpmn2.modeler.core.runtime.ModelExtensionDescriptor; import org.eclipse.bpmn2.modeler.core.runtime.ModelExtensionDescriptor.Property; import org.eclipse.bpmn2.modeler.core.runtime.TargetRuntime; import org.eclipse.bpmn2.modeler.core.utils.ModelUtil; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.Work; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.WorkDefinition; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.WorkDefinitionExtension; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.ParameterDefinition; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.WorkEditor; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl.WorkImpl; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl.WorkDefinitionImpl; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl.WorkDefinitionExtensionImpl; +import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.impl.ParameterDefinitionImpl; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.features.JbpmCustomTaskFeatureContainer; import org.eclipse.bpmn2.modeler.ui.property.tasks.IoParameterMappingColumn; import org.eclipse.emf.common.util.EList; @@ -161,14 +171,25 @@ public class JbpmTaskDetailComposite extends JbpmActivityDetailComposite { // Does the WID for this Task define a Work Item Editor dialog? // If so, do not display the WID parameters in this Property tab. - if (JbpmCustomTaskFeatureContainer.getWorkItemEditor(task)!=null) { + final WorkEditor workEditor = JbpmCustomTaskFeatureContainer.getWorkItemEditor(task); + if (workEditor!=null) { // TODO: // 1. create a New Work Item Editor wizard that copies the required // java interfaces and a sample implementation into the user's // java project. // 2. hook the ButtonObjectEditor into an action that pops up // the Work Item Editor. - ButtonObjectEditor button = new ButtonObjectEditor(this, task, null); + ButtonObjectEditor button = new ButtonObjectEditor(this, task, null) { + @Override + protected void buttonClicked() { + if (workEditor.show()) { + Work work = workEditor.getWork(); + for (Entry<String, Object> entry : work.getParameters().entrySet()) { + System.out.println(entry.getKey()+"="+entry.getValue()); + } + } + } + }; button.createControl(this.getAttributesParent(), "Edit Work Item Parameters"); return; } diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDLoader.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDLoader.java index 852ed761..6a51a14d 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDLoader.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDLoader.java @@ -5,8 +5,10 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -38,9 +40,9 @@ public class WIDLoader { private static final String WID_FOLDER = "/src/main/resources/META-INF"; private static final String ICONS_FOLDER = "/src/main/resources/icons"; - private HashMap<String, WorkItemDefinition> projectWIDs = new HashMap<String, WorkItemDefinition>(); + private List<WorkItemDefinition> projectWIDs = new ArrayList<WorkItemDefinition>(); private HashMap<String, ImageDescriptor> projectIcons = new HashMap<String, ImageDescriptor>(); - private HashMap<String, WorkItemDefinition> classpathWIDs = new HashMap<String, WorkItemDefinition>(); + private List<WorkItemDefinition> classpathWIDs = new ArrayList<WorkItemDefinition>(); private HashMap<String, ImageDescriptor> classpathIcons = new HashMap<String, ImageDescriptor>(); private class WIDVisitor implements IResourceVisitor { @@ -101,11 +103,11 @@ public class WIDLoader { project.accept(visitor, IResource.DEPTH_INFINITE, false); } - public HashMap<String, WorkItemDefinition> getProjectWIDs() { + public List<WorkItemDefinition> getProjectWIDs() { return projectWIDs; } - public HashMap<String, WorkItemDefinition> getClasspathWIDs() { + public List<WorkItemDefinition> getClasspathWIDs() { return classpathWIDs; } @@ -120,15 +122,15 @@ public class WIDLoader { private void getProjectFileWIDs(IFile file) throws CoreException, IOException, WIDException { InputStream is = file.getContents(); String content = inputStreamToString(is,null); - HashMap<String, WorkItemDefinition> widMap = WIDParser.parse(content); - for (WorkItemDefinition wid : widMap.values()) { + List<WorkItemDefinition> widMap = WIDParser.parse(content); + for (WorkItemDefinition wid : widMap) { String icon = wid.getIcon(); if (icon!=null && !icon.isEmpty()) { getProjectFileIcon(file, icon); ((WorkItemDefinitionImpl)wid).setDefinitionFile(file.getFullPath().toFile()); } } - projectWIDs.putAll(widMap); + projectWIDs.addAll(widMap); } private void getProjectFileIcon(IFile file, String icon) throws CoreException, IOException { @@ -171,13 +173,13 @@ public class WIDLoader { is = jar.getInputStream(entry); if (is!=null) { String content = inputStreamToString(is,null); - HashMap<String, WorkItemDefinition> widMap = WIDParser.parse(content); - for (WorkItemDefinition wid : widMap.values()) { + List<WorkItemDefinition> widMap = WIDParser.parse(content); + for (WorkItemDefinition wid : widMap) { String icon = wid.getIcon(); getJarFileIcon(jar, icon); ((WorkItemDefinitionImpl)wid).setDefinitionFile(jarFile.getAbsoluteFile()); } - classpathWIDs.putAll(widMap); + classpathWIDs.addAll(widMap); is.close(); } } diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDParser.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDParser.java index 8f599fd1..c2f48ff2 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDParser.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WIDParser.java @@ -12,10 +12,9 @@ ******************************************************************************/ package org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid; -import java.util.HashMap; -import java.util.LinkedHashMap; +import java.util.ArrayList; +import java.util.List; -import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataType; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataTypeFactory; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.drools.process.core.datatype.DataTypeRegistry; @@ -38,10 +37,9 @@ public class WIDParser { * work item task names. * @throws WIDException */ - public static HashMap<String, WorkItemDefinition> parse(String content) throws WIDException { + public static List<WorkItemDefinition> parse(String content) throws WIDException { - HashMap<String, WorkItemDefinition> widMap = - new LinkedHashMap<String, WorkItemDefinition>(); + List<WorkItemDefinition> widMap = new ArrayList<WorkItemDefinition>(); if (content == null) { WIDException widException = @@ -84,7 +82,7 @@ public class WIDParser { openBrackets--; if (openBrackets == 1) { if (currentWid != null && currentWid.getName() != null) { - widMap.put(currentWid.getName(), currentWid); + widMap.add(currentWid); } currentWid = new WorkItemDefinitionImpl(); } @@ -98,34 +96,34 @@ public class WIDParser { valueIndex = 2; name = name + ':' + nameValue[1].replace('"', ' ').trim(); } - String value = nameValue[valueIndex].replace('"', ' ').replace(',', ' '). + String stringValue = nameValue[valueIndex].replace('"', ' ').replace(',', ' '). replace('[',' ').trim(); - if (openBrackets == 2 && value.trim().length() > 0) { + if (openBrackets == 2 && stringValue.trim().length() > 0) { if (name.equalsIgnoreCase("name")) { //$NON-NLS-1$ - currentWid.setName(value); + currentWid.setName(stringValue); } else if (name.equalsIgnoreCase("displayName")) { //$NON-NLS-1$ - currentWid.setDispalyName(value); + currentWid.setDispalyName(stringValue); } else if (name.equalsIgnoreCase("description")) { //$NON-NLS-1$ - currentWid.setDescription(value); + currentWid.setDescription(stringValue); } else if (name.equalsIgnoreCase("category")) { //$NON-NLS-1$ - currentWid.setCategory(value); + currentWid.setCategory(stringValue); } else if (name.equalsIgnoreCase("icon")) { //$NON-NLS-1$ - currentWid.setIcon(value); + currentWid.setIcon(stringValue); } else if (name.equalsIgnoreCase("customEditor")) { //$NON-NLS-1$ - currentWid.setCustomEditor(value); + currentWid.setCustomEditor(stringValue); } else if (name.equalsIgnoreCase("eclipse:customEditor")) { //$NON-NLS-1$ - currentWid.setEclipseCustomEditor(value); + currentWid.setEclipseCustomEditor(stringValue); } - } else if (openBrackets == 3 && value.trim().length() > 0) { - if (value.startsWith("new") && value.indexOf("(")>0) { //$NON-NLS-1$ //$NON-NLS-2$ - int index = value.indexOf("("); //$NON-NLS-1$ - value = value.substring(3,index).trim(); + } else if (openBrackets == 3 && stringValue.trim().length() > 0) { + Object value = stringValue; + if (stringValue.startsWith("new") && stringValue.indexOf("(")>0) { //$NON-NLS-1$ //$NON-NLS-2$ + int index = stringValue.indexOf("("); //$NON-NLS-1$ + stringValue = stringValue.substring(3,index).trim(); // look up the DataType in the registry and replace the DataType // name with its Java type equivalent name - DataTypeFactory dtf = DataTypeRegistry.getFactory(value); + DataTypeFactory dtf = DataTypeRegistry.getFactory(stringValue); if (dtf!=null) { - DataType dt = dtf.createDataType(); - value = dt.getStringType(); + value = dtf.createDataType(); } } if (current == Section.PARAMETERS) diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinition.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinition.java index 37deee97..fd56bb14 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinition.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinition.java @@ -34,8 +34,8 @@ public interface WorkItemDefinition { public void setCategory ( String category ); public String getIcon(); public void setIcon ( String iconPath ); - public LinkedHashMap<String, String> getParameters(); - public LinkedHashMap<String, String> getResults(); + public LinkedHashMap<String, Object> getParameters(); + public LinkedHashMap<String, Object> getResults(); public File getDefinitionFile(); } diff --git a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinitionImpl.java b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinitionImpl.java index e1141934..00af3dcf 100644 --- a/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinitionImpl.java +++ b/plugins/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/wid/WorkItemDefinitionImpl.java @@ -41,8 +41,8 @@ public class WorkItemDefinitionImpl implements WorkItemDefinition { private String widIcon; private String widCustomEditor; private String widEclipseCustomEditor; - private LinkedHashMap<String, String> widParameters; - private LinkedHashMap<String, String> widResults; + private LinkedHashMap<String, Object> widParameters; + private LinkedHashMap<String, Object> widResults; private File file; @Override @@ -71,9 +71,9 @@ public class WorkItemDefinitionImpl implements WorkItemDefinition { } @Override - public LinkedHashMap<String, String> getParameters() { + public LinkedHashMap<String, Object> getParameters() { if (this.widParameters == null) - this.widParameters = new LinkedHashMap<String, String>(); + this.widParameters = new LinkedHashMap<String, Object>(); return this.widParameters; } @@ -132,9 +132,9 @@ public class WorkItemDefinitionImpl implements WorkItemDefinition { } @Override - public LinkedHashMap<String, String> getResults() { + public LinkedHashMap<String, Object> getResults() { if (this.widResults == null) - this.widResults = new LinkedHashMap<String, String>(); + this.widResults = new LinkedHashMap<String, Object>(); return this.widResults; } @@ -13,5 +13,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs <module>plugins</module> <module>features</module> <module>examples</module> + <module>tests</module> </modules> </project>
\ No newline at end of file diff --git a/tests/.project b/tests/.project new file mode 100644 index 00000000..76d5a448 --- /dev/null +++ b/tests/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.bpmn2.modeler.tests.parent</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + </natures> +</projectDescription> diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/.classpath b/tests/org.eclipse.bpmn2.modeler.core.tests/.classpath new file mode 100644 index 00000000..97067505 --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src/"/> + <classpathentry kind="src" path="resources/"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/.project b/tests/org.eclipse.bpmn2.modeler.core.tests/.project new file mode 100644 index 00000000..aff11428 --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.bpmn2.modeler.core.tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.bpmn2.modeler.core.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000..3aaf1506 --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.bpmn2.modeler.core.tests;singleton:=true +Bundle-Version: 1.4.0.qualifier +Require-Bundle: org.eclipse.bpmn2.edit, + org.eclipse.bpmn2.editor, + org.eclipse.bpmn2.modeler.core, + org.eclipse.emf.edit.ui, + org.eclipse.emf.ecore, + org.eclipse.emf.transaction, + org.eclipse.emf.validation.ocl, + org.junit, + org.mockito;bundle-version="1.9.5", + org.hamcrest;bundle-version="1.1.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/build.properties b/tests/org.eclipse.bpmn2.modeler.core.tests/build.properties new file mode 100644 index 00000000..cad2cc51 --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/build.properties @@ -0,0 +1,6 @@ + +source.. = src/,\ + resources/ +output.. = target/classes +bin.includes = META-INF/,\ + . diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/plugin.properties b/tests/org.eclipse.bpmn2.modeler.core.tests/plugin.properties new file mode 100644 index 00000000..ca9bf67e --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/plugin.properties @@ -0,0 +1,16 @@ +# <copyright> +############################################################################### +# Copyright (c) 2011, 2012, 2013, 2014 Red Hat, Inc. +# All rights reserved. +# This program is made available under the terms of the +# Eclipse Public License v1.0 which accompanies this distribution, +# and is available at http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +############################################################################### +# </copyright> +# +# $Id$ +pluginName = BPMN2 Modeler Core +providerName = Eclipse.org diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/pom.xml b/tests/org.eclipse.bpmn2.modeler.core.tests/pom.xml new file mode 100644 index 00000000..3e9e6c73 --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/pom.xml @@ -0,0 +1,13 @@ +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.bpmn2.modeler.tests</groupId> + <artifactId>tests-parent</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <artifactId>org.eclipse.bpmn2.modeler.core.tests</artifactId> + <name>BPMN2 Modeler Tests: Core Tests</name> + <packaging>eclipse-test-plugin</packaging> +</project> + diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/src/org/eclipse/bpmn2/modeler/core/validation/tests/SyntaxCheckerUtilsTest.java b/tests/org.eclipse.bpmn2.modeler.core.tests/src/org/eclipse/bpmn2/modeler/core/validation/tests/SyntaxCheckerUtilsTest.java new file mode 100644 index 00000000..b5ddcbba --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/src/org/eclipse/bpmn2/modeler/core/validation/tests/SyntaxCheckerUtilsTest.java @@ -0,0 +1,34 @@ +package org.eclipse.bpmn2.modeler.core.validation.tests; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.eclipse.bpmn2.modeler.core.validation.SyntaxCheckerUtils; +import org.junit.Test; + +public class SyntaxCheckerUtilsTest { + + @Test + public void testIsJavaIdentifier() throws Exception { + assertTrue( SyntaxCheckerUtils.isJavaIdentifier("_ab") ); + assertTrue( SyntaxCheckerUtils.isJavaIdentifier("a1b") ); + assertTrue( SyntaxCheckerUtils.isJavaIdentifier("_ab") ); + } + + @Test + public void testIsJavaIdentifierUTF8() throws Exception { + assertTrue( SyntaxCheckerUtils.isJavaIdentifier("形声") ); + } + + @Test + public void testIsJavaIdentifierNegative() throws Exception { + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("_a b") ); + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("1ab") ); + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("!ab") ); + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("*") ); + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("+") ); + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("-") ); + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("a+") ); + assertFalse( SyntaxCheckerUtils.isJavaIdentifier("a#") ); + } +} diff --git a/tests/org.eclipse.bpmn2.modeler.core.tests/src/org/eclipse/bpmn2/modeler/core/validation/validators/tests/GatewayValidatorTest.java b/tests/org.eclipse.bpmn2.modeler.core.tests/src/org/eclipse/bpmn2/modeler/core/validation/validators/tests/GatewayValidatorTest.java new file mode 100644 index 00000000..70744017 --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.core.tests/src/org/eclipse/bpmn2/modeler/core/validation/validators/tests/GatewayValidatorTest.java @@ -0,0 +1,91 @@ +package org.eclipse.bpmn2.modeler.core.validation.validators.tests; + +import org.eclipse.bpmn2.Bpmn2Package; +import org.eclipse.bpmn2.Gateway; +import org.eclipse.bpmn2.GatewayDirection; +import org.eclipse.bpmn2.SequenceFlow; +import org.eclipse.bpmn2.modeler.core.validation.validators.GatewayValidator; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.validation.IValidationContext; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.verify; + +import java.util.ArrayList; +import java.util.List; + +@RunWith(MockitoJUnitRunner.class) +public class GatewayValidatorTest { + + @Mock + Gateway gateway; + + @Mock + IValidationContext ctx; + + @Mock + SequenceFlow flowOne; + + @Mock + SequenceFlow flowTwo; + + @Mock + SequenceFlow flowThree; + + @Mock + EClass eClass; + + @Mock + EStructuralFeature eFeature; + + List<SequenceFlow> zeroFlows; + + List<SequenceFlow> oneFlow; + + List<SequenceFlow> twoFlows; + + GatewayValidator validator; + + @Before + public void setUp() { + validator = new GatewayValidator(ctx) { + @Override + protected void addStatus(EObject object, String featureName, int severity, String messagePattern, Object... messageArguments) { + // do nothing for test purposes + } + }; + + zeroFlows = new ArrayList<SequenceFlow>(); + + oneFlow = new ArrayList<SequenceFlow>(); + oneFlow.add(flowOne); + + twoFlows = new ArrayList<SequenceFlow>(); + twoFlows.add(flowTwo); + twoFlows.add(flowThree); + + when(eClass.getEStructuralFeature(anyString())).thenReturn(eFeature); + when(gateway.eClass()).thenReturn(eClass); + + } + + @Test + public void testConvergingGatewayWrongSequenceCounts() throws Exception { + when(gateway.getGatewayDirection()).thenReturn(GatewayDirection.CONVERGING); + when(gateway.getIncoming()).thenReturn(zeroFlows); + when(gateway.getOutgoing()).thenReturn(twoFlows); + + validator.validate(gateway); + + verify(ctx, times(2)).addResult(Bpmn2Package.eINSTANCE.getGateway_GatewayDirection()); + } +} diff --git a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.classpath b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.classpath index ad32c83a..bd5d6f6e 100644 --- a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.classpath +++ b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.classpath @@ -1,7 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> + <classpathentry excluding="**" kind="src" path="widfiles"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="output" path="target/classes"/> </classpath> diff --git a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.project b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.project index 71047083..b1b7bae3 100644 --- a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.project +++ b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/.project @@ -11,18 +11,13 @@ </arguments> </buildCommand> <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> + <name>org.eclipse.m2e.core.maven2Builder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> - <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.m2e.core.maven2Nature</nature> </natures> </projectDescription> diff --git a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/META-INF/MANIFEST.MF index 795ed324..fce0ec42 100644 --- a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.4.0.qualifier Bundle-Vendor: %providerName -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.junit, org.eclipse.bpmn2.modeler.runtime.jboss.jbpm, org.eclipse.core.runtime, diff --git a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/pom.xml b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/pom.xml new file mode 100644 index 00000000..3cb9f3a0 --- /dev/null +++ b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/pom.xml @@ -0,0 +1,15 @@ +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.bpmn2.modeler.tests</groupId> + <artifactId>tests-parent</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <artifactId>org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests</artifactId> + <name>BPMN2 Modeler Tests: Runtime JBPM5 Tests</name> + <packaging>eclipse-test-plugin</packaging> +</project> + diff --git a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/tests/TestWIDHandler.java b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/tests/TestWIDHandler.java index 9b85bc38..e0097b18 100644 --- a/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/tests/TestWIDHandler.java +++ b/tests/org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests/src/org/eclipse/bpmn2/modeler/runtime/jboss/jbpm5/tests/TestWIDHandler.java @@ -16,21 +16,22 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; +import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; +import java.util.List; import java.util.Scanner; -import junit.framework.Assert; - import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid.WIDException; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid.WIDParser; import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.wid.WorkItemDefinition; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.junit.Assert; import org.junit.Test; import org.osgi.framework.Bundle; + /** * Basic tests for the WIDHandler * @author bfitzpat @@ -38,26 +39,22 @@ import org.osgi.framework.Bundle; */ public class TestWIDHandler { - private String getFile( String filepath ) { + private String getWidFile( String filepath ) { + Bundle bundle = Activator.getDefault().getBundle(); + IPath path = new Path("widfiles/"+filepath); + URL setupUrl = FileLocator.find(bundle, path, Collections.EMPTY_MAP); + File setupFile = null; try { - if (filepath == null) { - Bundle bundle = Activator.getDefault().getBundle(); - IPath path = new Path("widfiles/logemail.wid"); - URL setupUrl = FileLocator.find(bundle, path, Collections.EMPTY_MAP); - File setupFile = new File(FileLocator.toFileURL(setupUrl).toURI()); - filepath = setupFile.getAbsolutePath(); - } else { - Bundle bundle = Activator.getDefault().getBundle(); - IPath path = new Path(filepath); - URL setupUrl = FileLocator.find(bundle, path, Collections.EMPTY_MAP); - File setupFile = new File(FileLocator.toFileURL(setupUrl).toURI()); - filepath = setupFile.getAbsolutePath(); - } - } catch (URISyntaxException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + setupFile = new File(FileLocator.toFileURL(setupUrl).toURI()); + } catch (URISyntaxException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); } + filepath = setupFile.getAbsolutePath(); + StringBuilder text = new StringBuilder(); String NL = System.getProperty("line.separator"); Scanner scanner = null; @@ -79,15 +76,15 @@ public class TestWIDHandler { @Test public void testBasic() { System.out.println("testBasic: logemail.wid"); - String content = getFile(null); - HashMap<String, WorkItemDefinition> widMap = new HashMap<String, WorkItemDefinition>(); + String content = getWidFile("logemail.wid"); + List<WorkItemDefinition> widMap = new ArrayList<WorkItemDefinition>(); try { widMap = WIDParser.parse(content); } catch (WIDException e) { Assert.fail("Failed with exception " + e.getMessage()); } Assert.assertTrue(!widMap.isEmpty()); - java.util.Iterator<WorkItemDefinition> widIterator = widMap.values().iterator(); + java.util.Iterator<WorkItemDefinition> widIterator = widMap.iterator(); while(widIterator.hasNext()) System.out.println(widIterator.next().toString()); } @@ -95,15 +92,15 @@ public class TestWIDHandler { @Test public void testComplex() { System.out.println("testComplex: widfiles/Email.wid"); - String content = getFile("widfiles/Email.wid"); - HashMap<String, WorkItemDefinition> widMap = new HashMap<String, WorkItemDefinition>(); + String content = getWidFile("Email.wid"); + List<WorkItemDefinition> widMap = new ArrayList<WorkItemDefinition>(); try { widMap = WIDParser.parse(content); } catch (WIDException e) { Assert.fail("Failed with exception " + e.getMessage()); } Assert.assertTrue(!widMap.isEmpty()); - java.util.Iterator<WorkItemDefinition> widIterator = widMap.values().iterator(); + java.util.Iterator<WorkItemDefinition> widIterator = widMap.iterator(); while(widIterator.hasNext()) { WorkItemDefinition wid = widIterator.next(); Assert.assertTrue(wid.getEclipseCustomEditor() != null && @@ -115,15 +112,15 @@ public class TestWIDHandler { @Test public void testResults() { System.out.println("testResults: widfiles/java.wid"); - String content = getFile("widfiles/java.wid"); - HashMap<String, WorkItemDefinition> widMap = new HashMap<String, WorkItemDefinition>(); + String content = getWidFile("java.wid"); + List<WorkItemDefinition> widMap = new ArrayList<WorkItemDefinition>(); try { widMap = WIDParser.parse(content); } catch (WIDException e) { Assert.fail("Failed with exception " + e.getMessage()); } Assert.assertTrue(!widMap.isEmpty()); - java.util.Iterator<WorkItemDefinition> widIterator = widMap.values().iterator(); + java.util.Iterator<WorkItemDefinition> widIterator = widMap.iterator(); while(widIterator.hasNext()) { WorkItemDefinition wid = widIterator.next(); Assert.assertTrue(!wid.getResults().isEmpty()); @@ -134,7 +131,7 @@ public class TestWIDHandler { @Test public void testFail() { System.out.println("testFail: no wid"); - HashMap<String, WorkItemDefinition> widMap = new HashMap<String, WorkItemDefinition>(); + List<WorkItemDefinition> widMap = new ArrayList<WorkItemDefinition>(); try { widMap = WIDParser.parse(null); } catch (WIDException e) { diff --git a/tests/pom.xml b/tests/pom.xml new file mode 100644 index 00000000..88433a4c --- /dev/null +++ b/tests/pom.xml @@ -0,0 +1,28 @@ +<project +xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.bpmn2.modeler</groupId> + <artifactId>org.eclipse.bpmn2.modeler.parent</artifactId> + <version>1.4.0-SNAPSHOT</version> + <relativePath>../parent/pom.xml</relativePath> + </parent> + + <groupId>org.eclipse.bpmn2.modeler.tests</groupId> + <artifactId>tests-parent</artifactId> + <name>BPMN2 Modeler: Tests Parent</name> + <packaging>pom</packaging> + + <dependencies> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.9.5</version> + </dependency> + </dependencies> + + <modules> + <module>org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.tests</module> + <module>org.eclipse.bpmn2.modeler.core.tests</module> + </modules> +</project> |