diff options
Diffstat (limited to 'extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests')
11 files changed, 553 insertions, 0 deletions
diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.classpath b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.classpath @@ -0,0 +1,7 @@ +<?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="output" path="bin"/> +</classpath> diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.project b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.project new file mode 100644 index 00000000000..1f1902b7f08 --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.papyrus.bpmn.test</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> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.settings/org.eclipse.jdt.core.prefs b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/META-INF/MANIFEST.MF b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..6a9494cdd76 --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Bundle-ActivationPolicy: lazy +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test +Bundle-SymbolicName: org.eclipse.papyrus.bpmn.test +Bundle-Version: 0.8.0.qualifier +Bundle-Vendor: CEA +Fragment-Host: org.eclipse.papyrus.bpmn;bundle-version="0.8.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.junit;bundle-version="[4.11.0,5.0.0)" diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/build.properties b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/pom.xml b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/pom.xml new file mode 100644 index 00000000000..fcb270fb917 --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/pom.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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> + <artifactId>org.eclipse.papyrus.bpmn</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <relativePath>../org.eclipse.papyrus.bpmn</relativePath> + <version>0.8.0-SNAPSHOT</version> + </parent> + <artifactId>org.eclipse.papyrus.bpmn.tests</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <packaging>eclipse-test-plugin</packaging> +</project>
\ No newline at end of file diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/BPMNProcessCustomTest.java b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/BPMNProcessCustomTest.java new file mode 100644 index 00000000000..4febba8f39e --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/BPMNProcessCustomTest.java @@ -0,0 +1,100 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + *****************************************************************************/ +package org.eclipse.papyrus.bpmn.test; + + +import static org.junit.Assert.assertEquals; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProcess; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProfilePackage; +import org.eclipse.papyrus.bpmn.BPMNProfile.FlowElement; +import org.eclipse.papyrus.bpmn.BPMNProfile.Task; +import org.eclipse.papyrus.bpmn.BPMNProfile.impl.BPMNProcessCustom; +import org.eclipse.papyrus.bpmn.util.BPMNResource; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.OpaqueAction; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.util.UMLUtil; +import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class BPMNProcessCustomTest { + + private BPMNProcess bpmnProcess; + private Task task; + + @Before + public void setUp(){ + Model model = BPMNResource.createBPMNModel(); + + Activity activity = UMLFactory.eINSTANCE.createActivity(); + model.getPackagedElements().add(activity); + StereotypeApplicationHelper.getInstance(null).applyStereotype(activity, BPMNProfilePackage.eINSTANCE.getBPMNProcess()); + + OpaqueAction action = UMLFactory.eINSTANCE.createOpaqueAction(); + activity.getOwnedNodes().add(action); + task = (Task) StereotypeApplicationHelper.getInstance(null).applyStereotype(action, BPMNProfilePackage.eINSTANCE.getTask()); + + bpmnProcess = UMLUtil.getStereotypeApplication(activity, BPMNProcess.class); + } + + /* + * test that custom code is present in generated code + */ + @Test + public void getFlowElementsGeneratedTest(){ + try{ + bpmnProcess.getFlowElements(); + } + catch(UnsupportedOperationException e){ + Assert.fail("missing custom code !"); + } + } + + /* + * test custom code + */ + @Test + public void getFlowElementsCustomTest(){ + EList<FlowElement> flowElements = BPMNProcessCustom.getFlowElements(bpmnProcess); + Assert.assertNotNull(flowElements); + assertEquals(task, flowElements.get(0)); + } + + /* + * test full path + */ + @Test + public void getFlowElementsTest(){ + EList<FlowElement> flowElements = bpmnProcess.getFlowElements(); + Assert.assertNotNull(flowElements); + assertEquals(task, flowElements.get(0)); + } + + @Test + public void basicGetSupportsGeneratedTest(){ + try{ + bpmnProcess.getSupports(); + } + catch(UnsupportedOperationException e){ + Assert.fail("missing custom code !"); + } + } + + @Test + public void basicGetSupportsTest(){ + assertEquals(bpmnProcess, bpmnProcess.getSupports()); + } +} diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/BoundaryEventCustomTest.java b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/BoundaryEventCustomTest.java new file mode 100644 index 00000000000..08d9e7d9259 --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/BoundaryEventCustomTest.java @@ -0,0 +1,82 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + *****************************************************************************/ +package org.eclipse.papyrus.bpmn.test; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNActivity; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProcess; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProfilePackage; +import org.eclipse.papyrus.bpmn.BPMNProfile.BoundaryEvent; +import org.eclipse.papyrus.bpmn.BPMNProfile.Task; +import org.eclipse.papyrus.bpmn.BPMNProfile.impl.BoundaryEventCustom; +import org.eclipse.papyrus.bpmn.util.BPMNResource; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.ChangeEvent; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.OpaqueAction; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.util.UMLUtil; +import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class BoundaryEventCustomTest { + + private OpaqueAction action; + private BoundaryEvent boundaryEvent; + + @Before + public void setUp(){ + Model model = BPMNResource.createBPMNModel(); + + Activity activity = UMLFactory.eINSTANCE.createActivity(); + model.getPackagedElements().add(activity); + StereotypeApplicationHelper.getInstance(null).applyStereotype(activity, BPMNProfilePackage.eINSTANCE.getBPMNProcess()); + BPMNProcess bpmnProcess = UMLUtil.getStereotypeApplication(activity, BPMNProcess.class); + + action = UMLFactory.eINSTANCE.createOpaqueAction(); + activity.getOwnedNodes().add(action); + Task task = (Task) StereotypeApplicationHelper.getInstance(null).applyStereotype(action, BPMNProfilePackage.eINSTANCE.getTask()); + + ChangeEvent changeEvent = UMLFactory.eINSTANCE.createChangeEvent(); + model.getPackagedElements().add(changeEvent); + boundaryEvent = (BoundaryEvent) StereotypeApplicationHelper.getInstance(null).applyStereotype(changeEvent, BPMNProfilePackage.eINSTANCE.getBoundaryEvent()); + task.getBoundaryEventRefs().add(boundaryEvent); + boundaryEvent.setBase_ActivityNode(task.getBase_ActivityNode()); + } + + @Test + public void basicGetAttachedToRefGeneratedTest() { + try{ + boundaryEvent.getAttachedToRef(); + } + catch(UnsupportedOperationException e){ + Assert.fail("missing custom code !"); + } + } + + @Test + public void basicGetAttachedToRefCustomTest() { + BPMNActivity bmpnActivity = BoundaryEventCustom.basicGetAttachedToRef(boundaryEvent); + Assert.assertNotNull(bmpnActivity); + assertEquals(bmpnActivity, UMLUtil.getStereotypeApplication(action, BPMNActivity.class)); + } + + + @Test + public void basicGetAttachedToRefTest() { + BPMNActivity bmpnActivity = boundaryEvent.getAttachedToRef(); + Assert.assertNotNull(bmpnActivity); + assertEquals(bmpnActivity, UMLUtil.getStereotypeApplication(action, BPMNActivity.class)); + } +} diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/CallActivityCustomTest.java b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/CallActivityCustomTest.java new file mode 100644 index 00000000000..23d2c7b3e07 --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/CallActivityCustomTest.java @@ -0,0 +1,98 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + *****************************************************************************/ +package org.eclipse.papyrus.bpmn.test; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProcess; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProfilePackage; +import org.eclipse.papyrus.bpmn.BPMNProfile.CallActivity; +import org.eclipse.papyrus.bpmn.BPMNProfile.CallableElement; +import org.eclipse.papyrus.bpmn.BPMNProfile.Task; +import org.eclipse.papyrus.bpmn.BPMNProfile.impl.CallActivityCustom; +import org.eclipse.papyrus.bpmn.util.BPMNResource; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.Behavior; +import org.eclipse.uml2.uml.CallBehaviorAction; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.OpaqueAction; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.util.UMLUtil; +import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Created by GD249233 on 01/02/2017. + */ +public class CallActivityCustomTest { + + private BPMNProcess bpmnProcess; + private BPMNProcess bpmnSubProcess; + private Task task; + private CallActivity callActivity; + private Activity activity2; + + @Before + public void setUp(){ + Model model = BPMNResource.createBPMNModel(); + + Activity activity = UMLFactory.eINSTANCE.createActivity(); + model.getPackagedElements().add(activity); + StereotypeApplicationHelper.getInstance(null).applyStereotype(activity, BPMNProfilePackage.eINSTANCE.getBPMNProcess()); + + OpaqueAction action = UMLFactory.eINSTANCE.createOpaqueAction(); + activity.getOwnedNodes().add(action); + task = (Task) StereotypeApplicationHelper.getInstance(null).applyStereotype(action, BPMNProfilePackage.eINSTANCE.getTask()); + + bpmnProcess = UMLUtil.getStereotypeApplication(activity, BPMNProcess.class); + + CallBehaviorAction callBehaviorAction = UMLFactory.eINSTANCE.createCallBehaviorAction(); + activity.getOwnedNodes().add(callBehaviorAction); + callActivity = (CallActivity) StereotypeApplicationHelper.getInstance(null).applyStereotype(callBehaviorAction, BPMNProfilePackage.eINSTANCE.getCallActivity()); + + activity2 = UMLFactory.eINSTANCE.createActivity(); + model.getPackagedElements().add(activity2); + bpmnSubProcess = (BPMNProcess) StereotypeApplicationHelper.getInstance(null).applyStereotype(activity2, BPMNProfilePackage.eINSTANCE.getBPMNProcess()); + + callBehaviorAction.setBehavior((Behavior)activity2); + } + + /* + * test that custom code is present in generated code + */ + @Test + public void basicGetCalledElementRefGeneratedTest(){ + try{ + callActivity.getCalledElementRef(); + } + catch(UnsupportedOperationException e){ + Assert.fail("missing custom code !"); + } + } + + @Test + public void basicGetCalledElementRefCustomTest(){ + CallableElement e = CallActivityCustom.basicGetCalledElementRef(callActivity); + Assert.assertNotNull(e); + assertEquals(e, bpmnSubProcess); + } + + @Test + public void basicGetCalledElementRefTest(){ + CallableElement e = callActivity.getCalledElementRef(); + Assert.assertNotNull(e); + assertEquals(e, bpmnSubProcess); + } + + +} diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/FlowElementCustomTest.java b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/FlowElementCustomTest.java new file mode 100644 index 00000000000..fb3c3010dfb --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/FlowElementCustomTest.java @@ -0,0 +1,83 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + *****************************************************************************/ +package org.eclipse.papyrus.bpmn.test; + +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProcess; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProfilePackage; +import org.eclipse.papyrus.bpmn.BPMNProfile.BoundaryEvent; +import org.eclipse.papyrus.bpmn.BPMNProfile.FlowElement; +import org.eclipse.papyrus.bpmn.BPMNProfile.FlowElementsContainer; +import org.eclipse.papyrus.bpmn.BPMNProfile.Task; +import org.eclipse.papyrus.bpmn.BPMNProfile.impl.FlowElementCustom; +import org.eclipse.papyrus.bpmn.util.BPMNResource; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.ChangeEvent; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.OpaqueAction; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.util.UMLUtil; +import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class FlowElementCustomTest { + + OpaqueAction action; + BPMNProcess bpmnProcess; + BoundaryEvent boundaryEvent; + Task task; + + @Before + public void setUp(){ + Model model = BPMNResource.createBPMNModel(); + + Activity activity = UMLFactory.eINSTANCE.createActivity(); + model.getPackagedElements().add(activity); + StereotypeApplicationHelper.getInstance(null).applyStereotype(activity, BPMNProfilePackage.eINSTANCE.getBPMNProcess()); + bpmnProcess = UMLUtil.getStereotypeApplication(activity, BPMNProcess.class); + + action = UMLFactory.eINSTANCE.createOpaqueAction(); + activity.getOwnedNodes().add(action); + task = (Task) StereotypeApplicationHelper.getInstance(null).applyStereotype(action, BPMNProfilePackage.eINSTANCE.getTask()); + + ChangeEvent changeEvent = UMLFactory.eINSTANCE.createChangeEvent(); + model.getPackagedElements().add(changeEvent); + boundaryEvent = (BoundaryEvent) StereotypeApplicationHelper.getInstance(null).applyStereotype(changeEvent, BPMNProfilePackage.eINSTANCE.getBoundaryEvent()); + task.getBoundaryEventRefs().add(boundaryEvent); + boundaryEvent.setBase_ActivityNode(task.getBase_ActivityNode()); + } + + @Test + public void basicGetContainerGeneratedTest(){ + try{ + FlowElement fe = UMLUtil.getStereotypeApplication(task.getBase_Element(), FlowElement.class); + fe.getContainer(); + } + catch(UnsupportedOperationException e){ + Assert.fail("missing custom code !"); + } + } + + @Test + public void basicGetContainerCustomTest(){ + Assert.assertEquals(bpmnProcess, FlowElementCustom.basicGetContainer(UMLUtil.getStereotypeApplication(task.getBase_Element(), FlowElement.class))); + Assert.assertEquals(bpmnProcess, FlowElementCustom.basicGetContainer(UMLUtil.getStereotypeApplication(boundaryEvent.getBase_Element(), FlowElement.class))); + } + + @Test + public void basicGetContainerTest(){ + FlowElement fe1 = UMLUtil.getStereotypeApplication(task.getBase_Element(), FlowElement.class); + Assert.assertEquals(bpmnProcess, fe1.getContainer()); + FlowElement fe2 = UMLUtil.getStereotypeApplication(boundaryEvent.getBase_Element(), FlowElement.class); + Assert.assertEquals(bpmnProcess, fe2.getContainer()); + } +} diff --git a/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/StandardLoopCharacteristicsCustomTest.java b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/StandardLoopCharacteristicsCustomTest.java new file mode 100644 index 00000000000..c3b7a796b3d --- /dev/null +++ b/extraplugins/bpmn/org.eclipse.papyrus.bpmn.tests/src/org/eclipse/papyrus/bpmn/test/StandardLoopCharacteristicsCustomTest.java @@ -0,0 +1,119 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are 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: + * CEA - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.bpmn.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNExpression; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProcess; +import org.eclipse.papyrus.bpmn.BPMNProfile.BPMNProfilePackage; +import org.eclipse.papyrus.bpmn.BPMNProfile.StandardLoopCharacteristics; +import org.eclipse.papyrus.bpmn.BPMNProfile.Task; +import org.eclipse.papyrus.bpmn.BPMNProfile.impl.StandardLoopCharacteristicsCustom; +import org.eclipse.papyrus.bpmn.util.BPMNResource; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.LoopNode; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.OpaqueAction; +import org.eclipse.uml2.uml.OutputPin; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.ValueSpecificationAction; +import org.eclipse.uml2.uml.util.UMLUtil; +import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Created by GD249233 on 25/01/2017. + */ +public class StandardLoopCharacteristicsCustomTest { + + private BPMNProcess bpmnProcess; + private Task task; + private StandardLoopCharacteristics loop; + private BPMNExpression bex; + + @Before + public void setUp(){ + Model model = BPMNResource.createBPMNModel(); + + Activity activity = UMLFactory.eINSTANCE.createActivity(); + model.getPackagedElements().add(activity); + StereotypeApplicationHelper.getInstance(null).applyStereotype(activity, BPMNProfilePackage.eINSTANCE.getBPMNProcess()); + bpmnProcess = UMLUtil.getStereotypeApplication(activity, BPMNProcess.class); + + LoopNode loopNode = UMLFactory.eINSTANCE.createLoopNode(); + activity.getOwnedNodes().add(loopNode); + StereotypeApplicationHelper.getInstance(null).applyStereotype(loopNode, BPMNProfilePackage.eINSTANCE.getStandardLoopCharacteristics()); + loop = UMLUtil.getStereotypeApplication(loopNode, StandardLoopCharacteristics.class); + + OpaqueAction action = UMLFactory.eINSTANCE.createOpaqueAction(); + loopNode.getNodes().add(action); + task = (Task) StereotypeApplicationHelper.getInstance(null).applyStereotype(action, BPMNProfilePackage.eINSTANCE.getTask()); + + loopNode.setIsTestedFirst(true); + + ValueSpecificationAction valueSpecificationAction = UMLFactory.eINSTANCE.createValueSpecificationAction(); + loopNode.getNodes().add(valueSpecificationAction); + loopNode.getTests().add(valueSpecificationAction); + bex = (BPMNExpression) StereotypeApplicationHelper.getInstance(null).applyStereotype(valueSpecificationAction, BPMNProfilePackage.eINSTANCE.getBPMNExpression()); + + OutputPin outputPin = UMLFactory.eINSTANCE.createOutputPin(); + + valueSpecificationAction.setResult(outputPin); + } + + @Test + public void isTestBeforeGeneratedTest() { + try{ + loop.isTestBefore(); + } + catch(UnsupportedOperationException e){ + Assert.fail("missing custom code !"); + } + } + + @Test + public void isTestBeforeCustomTest() { + assertTrue(StandardLoopCharacteristicsCustom.isTestBefore(loop)); + } + + @Test + public void isTestBeforeTest() { + assertTrue(loop.isTestBefore()); + + } + + @Test + public void basicGetLoopConditionGeneratedTest() { + try{ + loop.getLoopCondition(); + } + catch(UnsupportedOperationException e){ + Assert.fail("missing custom code !"); + } + } + + @Test + public void basicGetLoopConditionCustomTest() { + assertEquals(bex, StandardLoopCharacteristicsCustom.basicGetLoopCondition(loop)); + } + + @Test + public void basicGetLoopConditionTest() { + assertEquals(bex, loop.getLoopCondition()); + } + +} |