├── coverage-0.9.jar
├── org.eclipse.uml2.common_1.7.0.v20120913-1441.jar
├── org.eclipse.uml2.types_1.0.0.v20120913-1441.jar
├── src
├── test
│ ├── resources
│ │ └── testData
│ │ │ ├── roc
│ │ │ ├── model
│ │ │ │ ├── rocBasicModel.di
│ │ │ │ └── rocBasicModel.uml
│ │ │ └── Roc.feature
│ │ │ └── VendingMachine
│ │ │ └── model
│ │ │ ├── VendingMachineFSM.di
│ │ │ └── VendingMachineFSM.uml
│ └── java
│ │ └── com
│ │ └── mdsol
│ │ └── skyfire
│ │ └── util
│ │ ├── JavaSupporterTest.java
│ │ └── MappingTest.java
├── integration-test
│ ├── resources
│ │ ├── testData
│ │ │ ├── roc
│ │ │ │ ├── model
│ │ │ │ │ ├── rocBasicModel.di
│ │ │ │ │ └── rocBasicModel.uml
│ │ │ │ ├── RocNodeCoverage.feature
│ │ │ │ ├── RocEdgeCoverage.feature
│ │ │ │ ├── RocEdgePairCoverage.feature
│ │ │ │ └── RocPrimePathCoverage.feature
│ │ │ ├── VendingMachine
│ │ │ │ └── model
│ │ │ │ │ ├── VendingMachineFSM.di
│ │ │ │ │ └── VendingMachineFSM.uml
│ │ │ └── plinth
│ │ │ │ └── model
│ │ │ │ └── plinth_old.uml
│ │ └── log4j2.xml
│ └── java
│ │ └── com
│ │ └── mdsol
│ │ └── skyfire
│ │ ├── StateMachineAccessorIT.java
│ │ ├── CucumberTestGeneratorIT.java
│ │ ├── AbstractTestGeneratorIT.java
│ │ └── AccessingModelsIT.java
└── main
│ ├── java
│ └── com
│ │ └── mdsol
│ │ └── skyfire
│ │ ├── TestCoverageCriteria.java
│ │ ├── IdentifiableElementType.java
│ │ ├── FsmTest.java
│ │ ├── Test.java
│ │ ├── ConstraintMapping.java
│ │ ├── Mapping.java
│ │ ├── util
│ │ └── JavaSupporter.java
│ │ └── ModelAccessor.java
│ └── resources
│ └── log4j2.xml
├── NOTICE
├── jars-installation.sh
├── sonar-project.properties
├── .travis.yml
├── .gitignore
├── README.md
├── mdsol-checkstyle.xml
├── Eclipse Public License - Version 1.0
├── LICENSE
└── pom.xml
/coverage-0.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdsol/skyfire/master/coverage-0.9.jar
--------------------------------------------------------------------------------
/org.eclipse.uml2.common_1.7.0.v20120913-1441.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdsol/skyfire/master/org.eclipse.uml2.common_1.7.0.v20120913-1441.jar
--------------------------------------------------------------------------------
/org.eclipse.uml2.types_1.0.0.v20120913-1441.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdsol/skyfire/master/org.eclipse.uml2.types_1.0.0.v20120913-1441.jar
--------------------------------------------------------------------------------
/src/test/resources/testData/roc/model/rocBasicModel.di:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/roc/model/rocBasicModel.di:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Apache log4j
2 | Copyright [1999-2015] The Apache Software Foundation
3 |
4 | Apache Maven Checkstyle Plugin
5 | Copyright [2006-2015] The Apache Software Foundation
6 |
7 | This product includes software developed at
8 | The Apache Software Foundation (http://www.apache.org/).
--------------------------------------------------------------------------------
/jars-installation.sh:
--------------------------------------------------------------------------------
1 | mvn install:install-file -Dfile=coverage-0.9.jar -DgroupId=edu.gmu.swe \
2 | -DartifactId=coverage -Dversion=0.9 -Dpackaging=jar
3 |
4 | mvn install:install-file -Dfile=org.eclipse.uml2.types_1.0.0.v20120913-1441.jar -DgroupId=org.eclipse.uml2 \
5 | -DartifactId=types -Dversion=1.0.0.v20120913-1441 -Dpackaging=jar
6 |
7 | mvn install:install-file -Dfile=org.eclipse.uml2.common_1.7.0.v20120913-1441.jar -DgroupId=org.eclipse.uml2 \
8 | -DartifactId=common -Dversion=1.7.0.v20120913-1441 -Dpackaging=jar
--------------------------------------------------------------------------------
/sonar-project.properties:
--------------------------------------------------------------------------------
1 | # must be unique in a given SonarQube instance
2 | sonar.projectKey=com.mdsol.skyfire
3 | # this is the name displayed in the SonarQube UI
4 | sonar.projectName=Skyfire
5 | sonar.projectVersion=1.0.0
6 |
7 | # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
8 | # Since SonarQube 4.2, this property is optional if sonar.modules is set.
9 | # If not set, SonarQube starts looking for source code from the directory containing
10 | # the sonar-project.properties file.
11 | sonar.sources=.
12 |
13 | # Encoding of the source code. Default is default system encoding
14 | sonar.sourceEncoding=UTF-8
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | ## install jars locally
4 | install:
5 | - mvn install:install-file -Dfile=coverage-0.9.jar -DgroupId=edu.gmu.swe -DartifactId=coverage -Dversion=0.9 -Dpackaging=jar
6 | - mvn install:install-file -Dfile=org.eclipse.uml2.types_1.0.0.v20120913-1441.jar -DgroupId=org.eclipse.uml2 -DartifactId=types -Dversion=1.0.0.v20120913-1441 -Dpackaging=jar
7 | - mvn install:install-file -Dfile=org.eclipse.uml2.common_1.7.0.v20120913-1441.jar -DgroupId=org.eclipse.uml2 -DartifactId=common -Dversion=1.7.0.v20120913-1441 -Dpackaging=jar
8 |
9 | ## Run integration tests
10 | script: "mvn verify -Dgpg.skip=true"
11 |
12 | notifications:
13 | email:
14 | - nli@mdsol.com
15 | - aescalona@mdsol.com
16 |
17 |
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/TestCoverageCriteria.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 |
7 | package com.mdsol.skyfire;
8 |
9 | /**
10 | * An enumeration class that represents the coverage criteria.
11 | *
12 | * @author Nan Li
13 | * @version 1.0 Feb 25, 2013
14 | * @version 2015.1.0
15 | */
16 | public enum TestCoverageCriteria {
17 | NODECOVERAGE,
18 | EDGECOVERAGE,
19 | EDGEPAIRCOVERAGE,
20 | PRIMEPATHCOVERAGE
21 | }
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
3 | ######################
4 | # OSX
5 | ######################
6 |
7 | .DS_Store
8 | .svn
9 |
10 | # Thumbnails
11 | ._*
12 |
13 | # Files that might appear on external disk
14 | .Spotlight-V100
15 | .Trashes
16 |
17 | ######################
18 | # Eclipse / NetBeans
19 | ######################
20 | /.apt_generated
21 | .settings/
22 | .externalToolBuilders/
23 | build/
24 | bin/
25 | target/
26 | log/
27 | logs/
28 | tmp/
29 |
30 | ############
31 | # SonarQube
32 | ############
33 | .sonar/
34 |
35 | *.launch
36 | *.tmp
37 | *.bak
38 | *.swp
39 | *.nib
40 | *.pydevproject
41 | *.class
42 | *.war
43 | *.ear
44 | *.db
45 | *.buildpath
46 | *.cproject
47 | *.classpath
48 | *.loadpath
49 | *.project
50 | *.metadata
51 |
52 | nb-configuration.xml
53 | **/.checkstyle
54 |
--------------------------------------------------------------------------------
/src/test/resources/testData/VendingMachine/model/VendingMachineFSM.di:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/VendingMachine/model/VendingMachineFSM.di:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/test/java/com/mdsol/skyfire/util/JavaSupporterTest.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire.util;
7 |
8 | import static org.junit.Assert.assertEquals;
9 |
10 | import org.junit.Test;
11 |
12 | public class JavaSupporterTest {
13 |
14 | @Test
15 | public void testRemoveSemiColon() {
16 | String string = "vm.getCredit() == 0;;;;";
17 | assertEquals("vm.getCredit() == 0", JavaSupporter.removeSemiColon(string));
18 | }
19 |
20 | @Test
21 | public void testReturnPakcages() {
22 | assertEquals("edu/gmu/", JavaSupporter.returnPackages("package edu.gmu;"));
23 | }
24 |
25 | @Test
26 | public void testCleanUpPackageName() {
27 | assertEquals("edu.gmu", JavaSupporter.cleanUpPackageName("package edu.gmu;;"));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/IdentifiableElementType.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | /**
9 | * An enumeration that represents the types of identifiable elements in UML models and types used in
10 | * mappings for such as parameters.
11 | *
12 | * @author Nan Li
13 | * @version 1.0 Nov 12, 2012
14 | * @update June 13, 2013
15 | * @version 2015.1.0
16 | */
17 | public enum IdentifiableElementType {
18 | CLASS,
19 | OBJECT,
20 | // state machine
21 | TRANSITION,
22 | STATE,
23 | GUARD,
24 | CONSTRAINT,
25 |
26 | // arguments and variables checking for test oracle
27 | PARAMETER,
28 | FIELD,
29 | PRECONDITION,
30 | POSTCONDITION,
31 | STATEINVARIANT,
32 | TESTORACLE,
33 | TESTORACLE1,
34 | TESTORACLE2,
35 | TESTORACLE3,
36 | TESTORACLE4,
37 | TESTORACLE5;
38 | }
39 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/roc/RocNodeCoverage.feature:
--------------------------------------------------------------------------------
1 | Feature: Roc feature file generated from a state machine diagram
2 |
3 | Scenario: initializeWithInvalidKeys startEmrWithErrorStatus
4 | Given initializeWithInvalidKeys
5 | When startEmrWithErrorStatus
6 | Then invalidKeyErrorOccur
7 |
8 |
9 | Scenario: initializeWithValidKeys startEmr addValidSteps addInvalidSteps checkUntilGettingErrors
10 | Given initializeWithValidKeys
11 | When startEmr
12 | Then emrCreationIsSuccess
13 | When addValidSteps
14 | And addInvalidSteps
15 | And checkUntilGettingErrors
16 | Then invalidStepErrorOccur
17 |
18 |
19 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addInvalidSteps checkUntilGettingErrors
20 | Given initializeWithValidKeys
21 | When startEmr
22 | Then emrCreationIsSuccess
23 | When startUntilRunning
24 | Then emrIsRunning
25 | When runUntilWaiting
26 | Then stepsAreCompleteWaiting
27 | When addInvalidSteps
28 | And checkUntilGettingErrors
29 | Then invalidStepErrorOccur
30 |
31 |
32 | Scenario: initializeWithValidKeys startEmr addValidSteps checkInvalidStepId terminate
33 | Given initializeWithValidKeys
34 | When startEmr
35 | Then emrCreationIsSuccess
36 | When addValidSteps
37 | And checkInvalidStepId
38 | Then invalidStepIdErrorOccur
39 | When terminate
40 | Then terminationIsSuccess
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/test/java/com/mdsol/skyfire/util/MappingTest.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire.util;
7 |
8 | import static org.junit.Assert.assertEquals;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import org.junit.Test;
14 |
15 | import com.mdsol.skyfire.IdentifiableElementType;
16 | import com.mdsol.skyfire.Mapping;
17 |
18 | /**
19 | * A JUnit test case for class {@link Mapping}
20 | *
21 | * @author Nan Li
22 | * @version 1.0 Nov 12, 2012
23 | *
24 | */
25 | public class MappingTest {
26 |
27 | @Test
28 | public void testConstructorAndGettersAndSetters() {
29 | String mappingName = "vMachineInit";
30 | String identifiedElementName = "vm";
31 | IdentifiableElementType type = IdentifiableElementType.CLASS;
32 | String testCode = "vendingMachine vm = new vendingMachine();";
33 | List mappings = new ArrayList<>();
34 | List parameters = new ArrayList<>();
35 |
36 | Mapping mapping = new Mapping(mappingName, type, identifiedElementName, testCode, mappings,
37 | parameters, null, null);
38 |
39 | assertEquals(mapping.getName(), "vMachineInit");
40 | assertEquals(mapping.getIdentifiableElementName(), "vm");
41 | assertEquals(mapping.getType(), IdentifiableElementType.CLASS);
42 | assertEquals(mapping.getTestCode(), "vendingMachine vm = new vendingMachine();");
43 | assertEquals(mapping.getRequiredMappings().size(), 0);
44 | assertEquals(mapping.getParameters().size(), 0);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/FsmTest.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import java.util.List;
9 |
10 | import org.eclipse.uml2.uml.Transition;
11 |
12 | /**
13 | * A class that represents an object of test for state machine diagrams
14 | *
15 | * @author Nan Li
16 | * @version 1.0 Feb 11, 2013
17 | * @version 2015.1.0
18 | */
19 | public class FsmTest extends Test {
20 |
21 | private List path;
22 |
23 | /**
24 | * Default Constructor
25 | */
26 | public FsmTest() {
27 | // do nothing for a quick initialization
28 | super();
29 | }
30 |
31 | /**
32 | *
33 | * @param testName
34 | * the name of the test
35 | * @param testComment
36 | * the comment for the test
37 | * @param path
38 | * the path that includes a list of transitions
39 | */
40 | public FsmTest(final String testName, final String testComment, final List path) {
41 | super(testName, testComment);
42 | this.path = path;
43 | }
44 |
45 | /**
46 | * Gets the abstract test path of the test
47 | *
48 | * @return a list of {@link org.eclipse.uml2.uml.Transition}s
49 | */
50 | public final List getPath() {
51 | return path;
52 | }
53 |
54 | /**
55 | * Sets the abstract test path of the test
56 | *
57 | * @param path
58 | * a list of {@link org.eclipse.uml2.uml.Transition}s
59 | */
60 | public final void setPath(final List path) {
61 | this.path = path;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Model-Based Test Generator
5 | ${servicename}.log
6 | ${servicename}.err
7 | %d{UTF-8} | %-5.5p | %-15.30logger | %C{1}:%M:%L | %m%n
8 | %-5.5p | %-15.30logger | %C{1}:%M:%L | %m%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/integration-test/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Skyfire: Model-Based Test Scenario Generator
5 | ${servicename}.log
6 | ${servicename}.err
7 | %d{UTF-8} | %-5.5p | %-15.30logger | %C{1}:%M:%L | %m%n
8 | %-5.5p | %-15.30logger | %C{1}:%M:%L | %m%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # skyfire
2 |
3 | [](https://travis-ci.org/mdsol/skyfire)
4 |
5 | ## Introduction
6 | Skyfire is a Model-Based Testing (MBT) tool that generates [Cucumber](https://cucumber.io/) test scenarios from a UML behavioral diagram.
7 | Currently, skyfire supports Eclipse Modeling Framework (EMF)-based UML state machine diagrams.
8 | Users can create EMF-based UML diagrams using [Papyrus](https://eclipse.org/papyrus/) or [UMLDesigner](http://www.umldesigner.org/).
9 |
10 | For the motivation, algorithms, and more information, please read the [paper](https://cs.gmu.edu/~nli1/2016-nli-MbtWithCucumber.pdf).
11 |
12 | ## Usage
13 | * Create a Maven-based Java project
14 |
15 | * Include the dependency in the POM file
16 |
17 | ```
18 |
19 | com.mdsol
20 | skyfire
21 | 1.0.1
22 |
23 | ```
24 | * Call the API and specify the path to the UML diagram, a graph coverage criterion, a feature description, and the path to the Cucumber feature file to generate.
25 | Users can select node coverage, edge coverage, edge-pair coverage, or prime path coverage for the graph coverage criterion.
26 | The definitions of these four coverage criteria are included in the paper above.
27 | The feature description, pathToModel, and pathToFeatureFile are in the String format.
28 |
29 | ```
30 | CucumberTestGenerator.generateCucumberScenario (
31 | Paths.get (pathToModel),
32 | TestCoverageCriteria.SOMECOVERAGE,
33 | featureDescription,
34 | Paths.get (pathToFeatureFile));
35 | );
36 | ```
37 | * When a UML diagram uses the same name for different behaviors in multiple composite states, call another API to use qualified names of transitions to distinct transitions that have the same names.
38 | The parameters used are the same as the one above.
39 | ```
40 | CucumberTestGenerator.generateCucumberScenarioWithQualifiedName (
41 | Paths.get (pathToModel),
42 | TestCoverageCriteria.SOMECOVERAGE,
43 | featureDescription,
44 | Paths.get (pathToFeatureFile));
45 | );
46 | ```
47 |
48 | # Development Instructions
49 |
50 | ## Installation
51 | Run jars-installation.sh to install the coverage-0.9 jar, org.eclipse.uml2.common_1.7.0.v20120913-1441.jar, and org.eclipse.uml2.types_1.0.0.v20120913-1441.jar locally because these libraries are not available in any public Maven repository
52 |
53 | ### Compile The Project
54 | ```
55 | mvn clean compile
56 | ```
57 |
58 | ### Check Checkstyle Report
59 | ```
60 | mvn site
61 | ```
62 | ## Run Unit Tests
63 | ```
64 | mvn clean test
65 | ```
66 |
67 | ## Run Integration Tests
68 | ```
69 | mvn clean integration-test
70 | ```
71 |
72 | ## Generate source and JavaDoc Jars
73 | ```
74 | mvn package
75 | ```
76 |
77 | ##Stage for Deployment and Release (project owners only)
78 | ```
79 | mvn clean deploy
80 | ```
81 |
82 | ##Perform a Release Deployment (project owners only)
83 | ```
84 | mvn clean deploy -P release
85 | ```
86 | ## License
87 | Code and documentation copyright 2015-2016 Medidata Solutions, Inc. Code released under the MIT license.
88 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/plinth/model/plinth_old.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/Test.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * A class that represents an object of a test.
12 | *
13 | * @author Nan Li
14 | * @version 1.0 Feb 10, 2013
15 | *
16 | */
17 | public class Test {
18 |
19 | private String testName;
20 | private String testComment;
21 | private List mappings;
22 | private String testCode;
23 |
24 | /**
25 | * Constructs a test with no parameters
26 | */
27 | public Test() {
28 | // do nothing for a quick initialization
29 | }
30 |
31 | /**
32 | * Constructs a Test with the test name, test comment, and abstract test path from a state
33 | * machine diagram
34 | *
35 | * @param testName
36 | * the name of the test
37 | * @param testComment
38 | * the comment for the test
39 | */
40 | public Test(final String testName, final String testComment) {
41 | this.testName = testName;
42 | this.testComment = testComment;
43 | }
44 |
45 | /**
46 | * Gets the concrete test code
47 | *
48 | * @return the concrete test code in a String format
49 | */
50 | public final String getTestCode() {
51 | return testCode;
52 | }
53 |
54 | /**
55 | * Sets the test code
56 | *
57 | * @param testCode
58 | * the test code in a String format
59 | */
60 | public final void setTestCode(final String testCode) {
61 | this.testCode = testCode;
62 | }
63 |
64 | /**
65 | * Gets the comment for the test
66 | *
67 | * @return the test comment in a String format
68 | */
69 | public final String getTestComment() {
70 | return testComment;
71 | }
72 |
73 | /**
74 | * Sets the test comment
75 | *
76 | * @param testComment
77 | * the test comment in a String format
78 | */
79 | public final void setTestComment(final String testComment) {
80 | this.testComment = testComment;
81 | }
82 |
83 | /**
84 | * Gets the test name
85 | *
86 | * @return the test name in a String format
87 | */
88 | public final String getTestName() {
89 | return testName;
90 | }
91 |
92 | /**
93 | * Sets the test name
94 | *
95 | * @param testName
96 | * the test name in a String format
97 | */
98 | public final void setTestName(final String testName) {
99 | this.testName = testName;
100 | }
101 |
102 | /**
103 | * Gets the mappings for the abstract test path
104 | *
105 | * @return a list of {@link edu.gmu.swe.taf.Mapping}s
106 | */
107 | public final List getMappings() {
108 | return mappings;
109 | }
110 |
111 | /**
112 | * Sets the mappings
113 | *
114 | * @param mappings
115 | * a list of {@link edu.gmu.swe.taf.Mapping}s
116 | */
117 | public final void setMappings(final List mappings) {
118 | this.mappings = mappings;
119 | }
120 |
121 | }
122 |
--------------------------------------------------------------------------------
/src/test/resources/testData/roc/Roc.feature:
--------------------------------------------------------------------------------
1 | Feature: Roc feature file generated from a state machine diagram
2 |
3 | Scenario: initializeWithValidKeys startEmr addValidSteps addInvalidSteps checkUntilGettingErrors
4 | Given initializeWithValidKeys
5 | When startEmr
6 | Then emrCreationIsSuccess
7 | When addValidSteps
8 | And addInvalidSteps
9 | And checkUntilGettingErrors
10 | Then invalidStepErrorOccur
11 |
12 |
13 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkStepsUntilComplete addValidSteps checkUntilRunning runUntilWaiting addInvalidSteps checkUntilGettingErrors
14 | Given initializeWithValidKeys
15 | When startEmr
16 | Then emrCreationIsSuccess
17 | When startUntilRunning
18 | Then emrIsRunning
19 | When addValidSteps
20 | And checkStepsUntilComplete
21 | Then stepsAreCompleteWaiting
22 | When addValidSteps
23 | And checkUntilRunning
24 | Then emrIsRunning
25 | When runUntilWaiting
26 | Then stepsAreCompleteWaiting
27 | When addInvalidSteps
28 | And checkUntilGettingErrors
29 | Then invalidStepErrorOccur
30 |
31 |
32 | Scenario: initializeWithValidKeys startEmr startUntilRunning addInvalidSteps checkUntilGettingErrors
33 | Given initializeWithValidKeys
34 | When startEmr
35 | Then emrCreationIsSuccess
36 | When startUntilRunning
37 | Then emrIsRunning
38 | When addInvalidSteps
39 | And checkUntilGettingErrors
40 | Then invalidStepErrorOccur
41 |
42 |
43 | Scenario: initializeWithValidKeys startEmr checkInvalidStepId terminate
44 | Given initializeWithValidKeys
45 | When startEmr
46 | Then emrCreationIsSuccess
47 | When checkInvalidStepId
48 | Then invalidStepIdErrorOccur
49 | When terminate
50 | Then terminationIsSuccess
51 |
52 |
53 | Scenario: initializeWithInvalidKeys startEmrWithErrorStatus
54 | Given initializeWithInvalidKeys
55 | When startEmrWithErrorStatus
56 | Then invalidKeyErrorOccur
57 |
58 |
59 | Scenario: initializeWithValidKeys startEmr addInvalidSteps addValidSteps checkUntilGettingErrors
60 | Given initializeWithValidKeys
61 | When startEmr
62 | Then emrCreationIsSuccess
63 | When addInvalidSteps
64 | And addValidSteps
65 | And checkUntilGettingErrors
66 | Then invalidStepErrorOccur
67 |
68 |
69 | Scenario: initializeWithValidKeys startEmr terminate
70 | Given initializeWithValidKeys
71 | When startEmr
72 | Then emrCreationIsSuccess
73 | When terminate
74 | Then terminationIsSuccess
75 |
76 |
77 | Scenario: initializeWithValidKeys startEmr startUntilRunning terminate
78 | Given initializeWithValidKeys
79 | When startEmr
80 | Then emrCreationIsSuccess
81 | When startUntilRunning
82 | Then emrIsRunning
83 | When terminate
84 | Then terminationIsSuccess
85 |
86 |
87 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting terminate
88 | Given initializeWithValidKeys
89 | When startEmr
90 | Then emrCreationIsSuccess
91 | When startUntilRunning
92 | Then emrIsRunning
93 | When runUntilWaiting
94 | Then stepsAreCompleteWaiting
95 | When terminate
96 | Then terminationIsSuccess
97 |
98 |
99 | Scenario: initializeWithValidKeys startEmr addValidSteps terminate
100 | Given initializeWithValidKeys
101 | When startEmr
102 | Then emrCreationIsSuccess
103 | When addValidSteps
104 | And terminate
105 | Then terminationIsSuccess
106 |
107 |
108 | Scenario: initializeWithValidKeys startEmr startUntilRunning checkInvalidStepId terminate
109 | Given initializeWithValidKeys
110 | When startEmr
111 | Then emrCreationIsSuccess
112 | When startUntilRunning
113 | Then emrIsRunning
114 | When checkInvalidStepId
115 | Then invalidStepIdErrorOccur
116 | When terminate
117 | Then terminationIsSuccess
118 |
119 |
120 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting checkInvalidStepId terminate
121 | Given initializeWithValidKeys
122 | When startEmr
123 | Then emrCreationIsSuccess
124 | When startUntilRunning
125 | Then emrIsRunning
126 | When runUntilWaiting
127 | Then stepsAreCompleteWaiting
128 | When checkInvalidStepId
129 | Then invalidStepIdErrorOccur
130 | When terminate
131 | Then terminationIsSuccess
132 |
133 |
134 | Scenario: initializeWithValidKeys startEmr addValidSteps checkInvalidStepId terminate
135 | Given initializeWithValidKeys
136 | When startEmr
137 | Then emrCreationIsSuccess
138 | When addValidSteps
139 | And checkInvalidStepId
140 | Then invalidStepIdErrorOccur
141 | When terminate
142 | Then terminationIsSuccess
143 |
144 |
145 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/roc/RocEdgeCoverage.feature:
--------------------------------------------------------------------------------
1 | Feature: Roc feature file generated from a state machine diagram
2 |
3 | Scenario: initializeWithValidKeys startEmr addValidSteps addInvalidSteps checkUntilGettingErrors
4 | Given initializeWithValidKeys
5 | When startEmr
6 | Then emrCreationIsSuccess
7 | When addValidSteps
8 | And addInvalidSteps
9 | And checkUntilGettingErrors
10 | Then invalidStepErrorOccur
11 |
12 |
13 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkStepsUntilComplete addValidSteps checkUntilRunning runUntilWaiting addInvalidSteps checkUntilGettingErrors
14 | Given initializeWithValidKeys
15 | When startEmr
16 | Then emrCreationIsSuccess
17 | When startUntilRunning
18 | Then emrIsRunning
19 | When addValidSteps
20 | And checkStepsUntilComplete
21 | Then stepsAreCompleteWaiting
22 | When addValidSteps
23 | And checkUntilRunning
24 | Then emrIsRunning
25 | When runUntilWaiting
26 | Then stepsAreCompleteWaiting
27 | When addInvalidSteps
28 | And checkUntilGettingErrors
29 | Then invalidStepErrorOccur
30 |
31 |
32 | Scenario: initializeWithValidKeys startEmr startUntilRunning addInvalidSteps checkUntilGettingErrors
33 | Given initializeWithValidKeys
34 | When startEmr
35 | Then emrCreationIsSuccess
36 | When startUntilRunning
37 | Then emrIsRunning
38 | When addInvalidSteps
39 | And checkUntilGettingErrors
40 | Then invalidStepErrorOccur
41 |
42 |
43 | Scenario: initializeWithValidKeys startEmr checkInvalidStepId terminate
44 | Given initializeWithValidKeys
45 | When startEmr
46 | Then emrCreationIsSuccess
47 | When checkInvalidStepId
48 | Then invalidStepIdErrorOccur
49 | When terminate
50 | Then terminationIsSuccess
51 |
52 |
53 | Scenario: initializeWithInvalidKeys startEmrWithErrorStatus
54 | Given initializeWithInvalidKeys
55 | When startEmrWithErrorStatus
56 | Then invalidKeyErrorOccur
57 |
58 |
59 | Scenario: initializeWithValidKeys startEmr addInvalidSteps addValidSteps checkUntilGettingErrors
60 | Given initializeWithValidKeys
61 | When startEmr
62 | Then emrCreationIsSuccess
63 | When addInvalidSteps
64 | And addValidSteps
65 | And checkUntilGettingErrors
66 | Then invalidStepErrorOccur
67 |
68 |
69 | Scenario: initializeWithValidKeys startEmr terminate
70 | Given initializeWithValidKeys
71 | When startEmr
72 | Then emrCreationIsSuccess
73 | When terminate
74 | Then terminationIsSuccess
75 |
76 |
77 | Scenario: initializeWithValidKeys startEmr startUntilRunning terminate
78 | Given initializeWithValidKeys
79 | When startEmr
80 | Then emrCreationIsSuccess
81 | When startUntilRunning
82 | Then emrIsRunning
83 | When terminate
84 | Then terminationIsSuccess
85 |
86 |
87 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting terminate
88 | Given initializeWithValidKeys
89 | When startEmr
90 | Then emrCreationIsSuccess
91 | When startUntilRunning
92 | Then emrIsRunning
93 | When runUntilWaiting
94 | Then stepsAreCompleteWaiting
95 | When terminate
96 | Then terminationIsSuccess
97 |
98 |
99 | Scenario: initializeWithValidKeys startEmr addValidSteps terminate
100 | Given initializeWithValidKeys
101 | When startEmr
102 | Then emrCreationIsSuccess
103 | When addValidSteps
104 | And terminate
105 | Then terminationIsSuccess
106 |
107 |
108 | Scenario: initializeWithValidKeys startEmr startUntilRunning checkInvalidStepId terminate
109 | Given initializeWithValidKeys
110 | When startEmr
111 | Then emrCreationIsSuccess
112 | When startUntilRunning
113 | Then emrIsRunning
114 | When checkInvalidStepId
115 | Then invalidStepIdErrorOccur
116 | When terminate
117 | Then terminationIsSuccess
118 |
119 |
120 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting checkInvalidStepId terminate
121 | Given initializeWithValidKeys
122 | When startEmr
123 | Then emrCreationIsSuccess
124 | When startUntilRunning
125 | Then emrIsRunning
126 | When runUntilWaiting
127 | Then stepsAreCompleteWaiting
128 | When checkInvalidStepId
129 | Then invalidStepIdErrorOccur
130 | When terminate
131 | Then terminationIsSuccess
132 |
133 |
134 | Scenario: initializeWithValidKeys startEmr addValidSteps checkInvalidStepId terminate
135 | Given initializeWithValidKeys
136 | When startEmr
137 | Then emrCreationIsSuccess
138 | When addValidSteps
139 | And checkInvalidStepId
140 | Then invalidStepIdErrorOccur
141 | When terminate
142 | Then terminationIsSuccess
143 |
144 |
145 |
--------------------------------------------------------------------------------
/src/integration-test/java/com/mdsol/skyfire/StateMachineAccessorIT.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import static org.junit.Assert.assertEquals;
9 | import static org.junit.Assert.assertNotNull;
10 |
11 | import java.io.IOException;
12 | import java.util.List;
13 | import java.util.Map;
14 |
15 | import org.apache.logging.log4j.LogManager;
16 | import org.apache.logging.log4j.Logger;
17 | import org.eclipse.emf.ecore.EObject;
18 | import org.eclipse.uml2.uml.FinalState;
19 | import org.eclipse.uml2.uml.Pseudostate;
20 | import org.eclipse.uml2.uml.Region;
21 | import org.eclipse.uml2.uml.State;
22 | import org.eclipse.uml2.uml.StateMachine;
23 | import org.eclipse.uml2.uml.Vertex;
24 | import org.junit.Test;
25 |
26 | /**
27 | * A JUnit test case for class {@link StateMachineAccessor}
28 | *
29 | * @author Nan Li
30 | * @version 1.0 Nov 28, 2012
31 | *
32 | */
33 | public class StateMachineAccessorIT {
34 |
35 | private final String vendingMachineXmlPath = System.getProperty("user.dir")
36 | + "/src/test/resources/testData/VendingMachine/model/VendingMachineFSM.uml";
37 | private static Logger logger = LogManager.getLogger("StateMachineAccessorIT");
38 |
39 | @Test
40 | public void testGetStateMachines() throws IOException {
41 | EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
42 | List statemachines = ModelAccessor.getStateMachines(object);
43 | assertEquals(1, statemachines.size());
44 | }
45 |
46 | @Test
47 | public void testGetRegions() throws IOException {
48 | EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
49 | List statemachines = ModelAccessor.getStateMachines(object);
50 | List regions = StateMachineAccessor.getRegions(statemachines.get(0));
51 | assertEquals(1, regions.size());
52 | }
53 |
54 | @Test
55 | public void testGetInitialStates() throws IOException {
56 | EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
57 | List statemachines = ModelAccessor.getStateMachines(object);
58 | List regions = StateMachineAccessor.getRegions(statemachines.get(0));
59 | List initialStates = StateMachineAccessor.getInitialStates(regions.get(0));
60 | assertEquals(1, initialStates.size());
61 | }
62 |
63 | @Test
64 | public void testGetFinalStates() throws IOException {
65 | EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
66 | List statemachines = ModelAccessor.getStateMachines(object);
67 | List regions = StateMachineAccessor.getRegions(statemachines.get(0));
68 | List finalStates = StateMachineAccessor.getFinalStates(regions.get(0));
69 | assertEquals(1, finalStates.size());
70 | }
71 |
72 | @Test
73 | public void testGetStates() throws IOException {
74 | EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
75 | List statemachines = ModelAccessor.getStateMachines(object);
76 | List regions = StateMachineAccessor.getRegions(statemachines.get(0));
77 | List states = StateMachineAccessor.getStates(regions.get(0));
78 | assertEquals(9, states.size());
79 | }
80 |
81 | @Test
82 | public void testCreateStateMappings() throws IOException {
83 | EObject object = StateMachineAccessor.getModelObject(vendingMachineXmlPath);
84 | List statemachines = StateMachineAccessor.getStateMachines(object);
85 | List regions = StateMachineAccessor.getRegions(statemachines.get(0));
86 | StateMachineAccessor stateMachine = new StateMachineAccessor(regions.get(0));
87 | Map stateMappings = stateMachine.getStateMappings();
88 | Map reversedStateMappings = stateMachine.getReversedStateMappings();
89 |
90 | assertNotNull(stateMappings);
91 | assertEquals(11, stateMappings.size());
92 | assertEquals(11, reversedStateMappings.size());
93 | assertNotNull(stateMachine.getInitialStates());
94 | assertNotNull(stateMachine.getFinalStates());
95 | assertNotNull(stateMachine.getEdges());
96 | logger.info(stateMachine.getEdges());
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/ConstraintMapping.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * A {@link ConstraintMapping} class that maps test code to a constraint.
12 | *
13 | * @author Nan Li
14 | * @version 1.0 Feb 19, 2013
15 | * @version 2015.1.0
16 | */
17 | public class ConstraintMapping extends Mapping {
18 |
19 | // names of the mappings that can be used to solve the constraint
20 | private List constSolvingMappings;
21 | // names of the mappings that use this constraint as preconditions
22 | private List preconditions;
23 | // names of the mappings that use this constraint as postconditions
24 | private List postconditions;
25 | // names of the mappings that use this constraint as state invariants
26 | private List stateinvariants;
27 |
28 | /**
29 | * Allocates a {@link ConstraintMapping} object and initialize it to represent the the mapping
30 | *
31 | * @param mappingName
32 | * the name of the mapping
33 | * @param type
34 | * the type of the identifiable element
35 | * @param identifiableElementName
36 | * the name of the identifiable element
37 | * @param testCode
38 | * the mapped test code
39 | * @param requiredMappings
40 | * the required mappings for this mapping
41 | * @param parameters
42 | * the names of object mappings that are used to be method parameters
43 | * @param callers
44 | * the names of object mappings that are used to call methods
45 | * @param returnObjects
46 | * the names of object mappings that are returned by methods
47 | * @param constSolvingMappings
48 | * the mappings that are used to solve the constraint
49 | * @param preconditions
50 | * the pre-conditions that use this constraint
51 | * @param postconditions
52 | * the post-conditions that use this constraint
53 | * @param stateinvariants
54 | * the state-invariants that use this constraint
55 | */
56 | public ConstraintMapping(final String mappingName, final IdentifiableElementType type,
57 | final String identifiableElementName, final String testCode,
58 | final List requiredMappings, final List parameters,
59 | final List callers, final List returnObjects,
60 | final List constSolvingMappings, final List preconditions,
61 | final List postconditions, final List stateinvariants) {
62 | super(mappingName, type, identifiableElementName, testCode, requiredMappings, parameters,
63 | callers, returnObjects);
64 | this.constSolvingMappings = constSolvingMappings;
65 | this.preconditions = preconditions;
66 | this.postconditions = postconditions;
67 | this.stateinvariants = stateinvariants;
68 | }
69 |
70 | /**
71 | * Gets the names of mappings that used to solve the constraints.
72 | *
73 | * @return a list of names of the mappings in a String format
74 | */
75 | public final List getConstSolvingMappings() {
76 | return constSolvingMappings;
77 | }
78 |
79 | /**
80 | * Sets the mappings specified by the parameter.
81 | *
82 | * @param constSolvingMappings
83 | * a list of names of the mappings that solve the constraint
84 | */
85 | public final void setConstSolvingMappings(final List constSolvingMappings) {
86 | this.constSolvingMappings = constSolvingMappings;
87 | }
88 |
89 | /**
90 | * Gets the names of mappings that use this constraint as postconditions
91 | *
92 | * @return a list of names of the mappings in a String format
93 | */
94 | public final List getPostconditions() {
95 | return postconditions;
96 | }
97 |
98 | /**
99 | * Sets the mappings specified by the parameter
100 | *
101 | * @param postconditions
102 | * a list of names of the mappings that use this constraint as postconditions
103 | */
104 | public final void setPostconditions(final List postconditions) {
105 | this.postconditions = postconditions;
106 | }
107 |
108 | /**
109 | * Gets the names of mappings that use this constraint as preconditions
110 | *
111 | * @return a list of names of the mappings in a String format
112 | */
113 | public final List getPreconditions() {
114 | return preconditions;
115 | }
116 |
117 | /**
118 | * Sets the mappings specified by the parameter
119 | *
120 | * @param preconditions
121 | * a list of names of the mappings that use this constraint as preconditions
122 | */
123 | public final void setPreconditions(final List preconditions) {
124 | this.preconditions = preconditions;
125 | }
126 |
127 | /**
128 | * Gets the names of mappings that use this constraint as state invariants
129 | *
130 | * @return a list of names of the mappings in a String format
131 | */
132 | public final List getStateinvariants() {
133 | return stateinvariants;
134 | }
135 |
136 | /**
137 | * Sets the mappings specified by the parameter
138 | *
139 | * @param stateinvariants
140 | * a list of names of the mappings that use this constraint as state invariants
141 | */
142 | public final void setStateinvariants(final List stateinvariants) {
143 | this.stateinvariants = stateinvariants;
144 | }
145 |
146 | }
147 |
--------------------------------------------------------------------------------
/src/test/resources/testData/roc/model/rocBasicModel.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/roc/model/rocBasicModel.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/Mapping.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * A class that represents an object of a mapping.
12 | *
13 | * @author Nan Li
14 | * @version 1.0 Nov 12, 2012
15 | *
16 | */
17 | public class Mapping {
18 | // name of the mapping
19 | private String name;
20 | // type of the mapped identifiable element
21 | private IdentifiableElementType type;
22 | // name of the identifiable element
23 | private String identifiableElementName;
24 | // test code that is mapped to
25 | private String testCode;
26 | // other mappings that are required for this mapping
27 | private List requiredMappings;
28 | // mappings that are used as method parameters
29 | // the parameters also appear in the list of required mappings
30 | // the parameters are listed separately for the ease of testing different
31 | // oracle methods
32 | private List parameters;
33 | // mappings for objects that call methods
34 | private List callers;
35 | // mappings for objects that are returned by methods
36 | private List returnObjects;
37 |
38 | /**
39 | * Allocates a {@link Mapping} object and initialize it to represent the the mapping
40 | *
41 | * @param mappingName
42 | * the name of the mapping
43 | * @param type
44 | * the type of the identifiable element
45 | * @param identifiableElementName
46 | * the name of the identifiable element
47 | * @param testCode
48 | * the mapped test code
49 | * @param requiredMappings
50 | * the required mappings for this mapping
51 | * @param parameters
52 | * the names of object mappings that are used to be method parameters
53 | * @param callers
54 | * the names of object mappings that are used to call methods
55 | * @param returnObjects
56 | * the names of object mappings that are returned by methods
57 | */
58 | public Mapping(final String mappingName, final IdentifiableElementType type,
59 | final String identifiableElementName, final String testCode,
60 | final List requiredMappings, final List parameters,
61 | final List callers, final List returnObjects) {
62 | this.name = mappingName;
63 | this.type = type;
64 | this.identifiableElementName = identifiableElementName;
65 | this.testCode = testCode;
66 | this.requiredMappings = requiredMappings;
67 | this.parameters = parameters;
68 | this.setCallers(callers);
69 | this.setReturnObjects(returnObjects);
70 | }
71 |
72 | /**
73 | * Gets the mapping name
74 | *
75 | * @return the mapping name
76 | */
77 | public final String getName() {
78 | return name;
79 | }
80 |
81 | /**
82 | * Sets the mapping name
83 | *
84 | * @param mappingName
85 | * the name of the mapping
86 | */
87 | public final void setName(final String mappingName) {
88 | this.name = mappingName;
89 | }
90 |
91 | /**
92 | * Gets the identifiable element type
93 | *
94 | * @return the type of the identifiable element
95 | */
96 | public final IdentifiableElementType getType() {
97 | return type;
98 | }
99 |
100 | /**
101 | * Sets the identifiable element type
102 | *
103 | * @param type
104 | * the type of the identifiable element
105 | */
106 | public final void setType(final IdentifiableElementType type) {
107 | this.type = type;
108 | }
109 |
110 | /**
111 | * Gets the name of the identifiable element
112 | *
113 | * @return the name of the identifiable element
114 | */
115 | public final String getIdentifiableElementName() {
116 | return identifiableElementName;
117 | }
118 |
119 | /**
120 | * Sets the name of the identifiable element
121 | *
122 | * @param identifiableElementName
123 | * the name of the identifiable element
124 | */
125 | public final void setIdentifiableElementName(final String identifiableElementName) {
126 | this.identifiableElementName = identifiableElementName;
127 | }
128 |
129 | /**
130 | * Gets the test code
131 | *
132 | * @return the mapped test code
133 | */
134 | public final String getTestCode() {
135 | return testCode;
136 | }
137 |
138 | /**
139 | * Sets the test code
140 | *
141 | * @param testCode
142 | * the mapped test code
143 | */
144 | public final void setTestCode(final String testCode) {
145 | this.testCode = testCode;
146 | }
147 |
148 | /**
149 | * Gets the required mappings for this mapping
150 | *
151 | * @return a list of names of required mappings
152 | */
153 | public final List getRequiredMappings() {
154 | return requiredMappings;
155 | }
156 |
157 | /**
158 | * Sets the required mappings
159 | *
160 | * @param requiredMappings
161 | * the required mappings for this mapping
162 | */
163 | public final void setRequiredMappings(final List requiredMappings) {
164 | this.requiredMappings = requiredMappings;
165 | }
166 |
167 | /**
168 | * Returns the parameters used in this mapping
169 | *
170 | * @return a list of {@link String}s
171 | */
172 | public final List getParameters() {
173 | return parameters;
174 | }
175 |
176 | /**
177 | * Sets the parameters
178 | *
179 | * @param parameters
180 | * the parameters used in this mapping
181 | */
182 | public final void setParameters(final List parameters) {
183 | this.parameters = parameters;
184 | }
185 |
186 | /**
187 | * Gets the objects that call methods
188 | *
189 | * @return a list of names of the objects that call methods in a String format
190 | */
191 | public final List getCallers() {
192 | return callers;
193 | }
194 |
195 | /**
196 | * Gets the objects that are returned by methods
197 | *
198 | * @return a list of names of the objects that call methods in a String format
199 | */
200 | public final List getReturnObjects() {
201 | return returnObjects;
202 | }
203 |
204 | /**
205 | * Sets the names of the callers
206 | *
207 | * @param callers
208 | * a list of names of callers
209 | */
210 | public final void setCallers(final List callers) {
211 | this.callers = callers;
212 | }
213 |
214 | /**
215 | * Sets the names of return objects
216 | *
217 | * @param returnObjects
218 | * a list of return objects
219 | */
220 | public final void setReturnObjects(final List returnObjects) {
221 | this.returnObjects = returnObjects;
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/mdsol-checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
--------------------------------------------------------------------------------
/src/integration-test/java/com/mdsol/skyfire/CucumberTestGeneratorIT.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import static org.junit.Assert.assertEquals;
9 | import static org.junit.Assert.assertNotNull;
10 | import static org.junit.Assert.assertTrue;
11 |
12 | import java.io.File;
13 | import java.io.IOException;
14 | import java.nio.file.Paths;
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | import org.apache.logging.log4j.LogManager;
19 | import org.apache.logging.log4j.Logger;
20 | import org.eclipse.emf.ecore.EObject;
21 | import org.eclipse.uml2.uml.Region;
22 | import org.eclipse.uml2.uml.StateMachine;
23 | import org.eclipse.uml2.uml.Transition;
24 | import org.junit.After;
25 | import org.junit.Before;
26 | import org.junit.Test;
27 |
28 | import coverage.graph.InvalidGraphException;
29 | import coverage.graph.Path;
30 | import coverage.web.InvalidInputException;
31 |
32 | /**
33 | * A JUnit test case for class {@link CucumberTestGenerator}
34 | *
35 | * @author Nan Li
36 | * @version 1.0 Nov 19, 2015
37 | *
38 | */
39 | public class CucumberTestGeneratorIT {
40 | private CucumberTestGenerator generator;
41 | private List tests;
42 |
43 | private String testResourceDir;
44 | private String rocPath;
45 | private String rocDirectory;
46 | private static final String ROCFEATUREFILENAME = "roc.feature";
47 | private static final String FIRSTTESTNAME = "first test";
48 | private String plinthPath;
49 | private String plinthDirectory;
50 |
51 | private static Logger logger = LogManager.getLogger("CucumberTestGeneratorIT");
52 |
53 | /**
54 | * Initialize variables
55 | */
56 | @Before
57 | public void setUp() {
58 | tests = new ArrayList<>();
59 | generator = new CucumberTestGenerator(tests);
60 |
61 | testResourceDir = System.getProperty("user.dir") + "/src/integration-test/resources/";
62 | rocPath = testResourceDir + "testData/roc/model/rocBasicModel.uml";
63 | rocDirectory = testResourceDir + "testData/roc/";
64 | plinthPath = testResourceDir + "testData/plinth/model/plinth.uml";
65 | plinthDirectory = testResourceDir + "testData/plinth/";
66 | }
67 |
68 | /**
69 | * Release resources
70 | */
71 | @After
72 | public void tearDown() {
73 | tests = null;
74 | generator = null;
75 | }
76 |
77 | @Test
78 | public void testConstructorAndGettersAndSetters() {
79 | FsmTest test = new FsmTest();
80 | test.setTestName(FIRSTTESTNAME);
81 | tests.add(test);
82 |
83 | assertEquals(FIRSTTESTNAME, generator.getTests().get(0).getTestName());
84 | }
85 |
86 | @Test
87 | public void testGenerateScenarios() {
88 | FsmTest test = new FsmTest();
89 | test.setTestName(FIRSTTESTNAME);
90 | tests.add(test);
91 | String featureDescription = "first feature";
92 |
93 | StringBuilder sb = generator.generateScenarios(featureDescription);
94 | assertNotNull(sb);
95 | }
96 |
97 | @Test
98 | public void testGenerateScenariosRoc()
99 | throws IOException, InvalidInputException, InvalidGraphException {
100 | EObject object = StateMachineAccessor.getModelObject(rocPath);
101 | List statemachines = StateMachineAccessor.getStateMachines(object);
102 | List regions = StateMachineAccessor.getRegions(statemachines.get(0));
103 | StateMachineAccessor stateMachine = new StateMachineAccessor(regions.get(0));
104 | List paths = null;
105 | try {
106 | paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
107 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
108 | TestCoverageCriteria.PRIMEPATHCOVERAGE);
109 | } catch (InvalidGraphException e) {
110 | logger.error("An invalid graph");
111 | logger.error("The initial states are: " + stateMachine.getInitialStates());
112 | logger.error("The final states are: " + stateMachine.getFinalStates());
113 | logger.error("The edges are: " + stateMachine.getEdges());
114 |
115 | throw new InvalidGraphException(e);
116 | }
117 |
118 | // get the vertices from a path and return a list of transitions based on the vertices
119 | if (paths != null && !paths.isEmpty()) {
120 | for (int i = 0; i < paths.size(); i++) {
121 | logger.info("No. " + i + " path: " + paths.get(i));
122 | List transitions = AbstractTestGenerator.convertVerticesToTransitions(
123 | AbstractTestGenerator.getPathByState(paths.get(i), stateMachine));
124 |
125 | String pathName = "";
126 | for (Transition transition : transitions) {
127 | pathName += (transition.getName() != null ? transition.getName() : "") + " ";
128 | }
129 | com.mdsol.skyfire.Test test = new com.mdsol.skyfire.FsmTest(String.valueOf(i),
130 | pathName, transitions);
131 | tests.add(test);
132 | logger.info("Test comment: " + test.getTestComment());
133 | }
134 | } else {
135 | logger.error("No test paths generated");
136 | }
137 |
138 | String featureDescription = "Roc feature file generated from a state machine diagram";
139 |
140 | StringBuilder sb = generator.generateScenarios(featureDescription);
141 | assertNotNull(sb);
142 |
143 | CucumberTestGenerator.writeFeatureFile(sb, rocDirectory + ROCFEATUREFILENAME);
144 | File file = new File(rocDirectory + ROCFEATUREFILENAME);
145 | assertTrue(file.exists());
146 | }
147 |
148 | /**
149 | * This tests show how a user should use skyfire to generate Cucumber features
150 | *
151 | * @throws IOException
152 | * when the model does not exist
153 | */
154 | @Test
155 | public void testGenerateScenariosRocUsingExternalAPI() throws IOException {
156 | String featureDescription = "Roc feature file generated from a state machine diagram";
157 | boolean generated = CucumberTestGenerator.generateCucumberScenario(Paths.get(rocPath),
158 | TestCoverageCriteria.EDGECOVERAGE, featureDescription,
159 | Paths.get(rocDirectory + ROCFEATUREFILENAME));
160 | assertTrue(generated);
161 | File file = new File(rocDirectory + ROCFEATUREFILENAME);
162 | assertTrue(file.exists());
163 | }
164 |
165 | /**
166 | * This tests show how a user should use skyfire to generate Cucumber features
167 | *
168 | * @throws IOException
169 | * when the specified model or the feature file to write is not found
170 | */
171 | @Test
172 | public void testGenerateScenariosPlinth() throws IOException {
173 | String featureDescription = "Plinth feature file generated from a state machine diagram";
174 | boolean generated = CucumberTestGenerator.generateCucumberScenarioWithQualifiedName(
175 | Paths.get(plinthPath), TestCoverageCriteria.NODECOVERAGE, featureDescription,
176 | Paths.get(plinthDirectory + "PlinthNodeCoverage.feature"));
177 | assertTrue(generated);
178 | File file = new File(plinthDirectory + "PlinthNodeCoverage.feature");
179 | assertTrue(file.exists());
180 |
181 | generated = CucumberTestGenerator.generateCucumberScenarioWithQualifiedName(
182 | Paths.get(plinthPath), TestCoverageCriteria.EDGECOVERAGE, featureDescription,
183 | Paths.get(plinthDirectory + "PlinthEdgeCoverage.feature"));
184 | assertTrue(generated);
185 | file = new File(plinthDirectory + "PlinthEdgeCoverage.feature");
186 | assertTrue(file.exists());
187 |
188 | generated = CucumberTestGenerator.generateCucumberScenarioWithQualifiedName(
189 | Paths.get(plinthPath), TestCoverageCriteria.EDGEPAIRCOVERAGE, featureDescription,
190 | Paths.get(plinthDirectory + "PlinthEdgePairCoverage.feature"));
191 | assertTrue(generated);
192 | file = new File(plinthDirectory + "PlinthEdgePairCoverage.feature");
193 | assertTrue(file.exists());
194 |
195 | generated = CucumberTestGenerator.generateCucumberScenarioWithQualifiedName(
196 | Paths.get(plinthPath), TestCoverageCriteria.PRIMEPATHCOVERAGE, featureDescription,
197 | Paths.get(plinthDirectory + "PlinthPrimeCoverage.feature"));
198 | assertTrue(generated);
199 | file = new File(plinthDirectory + "PlinthPrimeCoverage.feature");
200 | assertTrue(file.exists());
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/src/integration-test/java/com/mdsol/skyfire/AbstractTestGeneratorIT.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import static org.junit.Assert.assertNotNull;
9 |
10 | import java.io.IOException;
11 | import java.util.Iterator;
12 | import java.util.List;
13 |
14 | import org.apache.logging.log4j.LogManager;
15 | import org.apache.logging.log4j.Logger;
16 | import org.eclipse.emf.ecore.EObject;
17 | import org.eclipse.uml2.uml.FinalState;
18 | import org.eclipse.uml2.uml.Pseudostate;
19 | import org.eclipse.uml2.uml.PseudostateKind;
20 | import org.eclipse.uml2.uml.Region;
21 | import org.eclipse.uml2.uml.State;
22 | import org.eclipse.uml2.uml.StateMachine;
23 | import org.eclipse.uml2.uml.Transition;
24 | import org.eclipse.uml2.uml.Vertex;
25 | import org.junit.After;
26 | import org.junit.Before;
27 | import org.junit.Test;
28 |
29 | import coverage.graph.InvalidGraphException;
30 | import coverage.graph.Node;
31 | import coverage.graph.Path;
32 | import coverage.web.InvalidInputException;
33 |
34 | /**
35 | * A JUnit test case for class {@link AbstractTestGenerator}
36 | *
37 | * @author Nan Li
38 | * @version 1.0 Nov 28, 2012
39 | *
40 | */
41 | public class AbstractTestGeneratorIT {
42 |
43 | private String testResourceDir;
44 | private String vendingMachinePath;
45 | private String rocPath;
46 | private String plinthPath;
47 | private static Logger logger = LogManager.getLogger("AbstractTestGeneratorIT");
48 |
49 | @Before
50 | public final void setUp() {
51 | testResourceDir = System.getProperty("user.dir")
52 | + "/src/integration-test/resources/testData/";
53 | vendingMachinePath = testResourceDir + "VendingMachine/model/VendingMachineFSM.uml";
54 | rocPath = testResourceDir + "roc/model/rocBasicModel.uml";
55 | plinthPath = testResourceDir + "plinth/model/plinth.uml";
56 | }
57 |
58 | @After
59 | public void tearDown() {
60 | testResourceDir = null;
61 | vendingMachinePath = null;
62 | rocPath = null;
63 | plinthPath = null;
64 | }
65 |
66 | /**
67 | *
68 | * @throws IOException
69 | * when IO exceptions happen
70 | * @throws InvalidInputException
71 | * when there are invalid inputs for a graph
72 | * @throws InvalidGraphException
73 | * when the graph is invalid
74 | */
75 | @Test
76 | public final void testGetTestPaths()
77 | throws IOException, InvalidInputException, InvalidGraphException {
78 |
79 | final EObject object = StateMachineAccessor.getModelObject(vendingMachinePath);
80 | final List statemachines = StateMachineAccessor.getStateMachines(object);
81 | final List regions = StateMachineAccessor.getRegions(statemachines.get(0));
82 | final StateMachineAccessor stateMachine = new StateMachineAccessor(regions.get(0));
83 |
84 | final List paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
85 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
86 | TestCoverageCriteria.PRIMEPATHCOVERAGE);
87 |
88 | assertNotNull(paths);
89 | }
90 |
91 | /**
92 | *
93 | * @throws IOException
94 | * when IO exceptions happen
95 | * @throws InvalidInputException
96 | * when there are invalid inputs for a graph
97 | * @throws InvalidGraphException
98 | * when the graph is invalid
99 | */
100 | @Test
101 | public final void testGetTestPathsForRoc()
102 | throws IOException, InvalidInputException, InvalidGraphException {
103 |
104 | final EObject object = StateMachineAccessor.getModelObject(rocPath);
105 | final List statemachines = StateMachineAccessor.getStateMachines(object);
106 | final List regions = StateMachineAccessor.getRegions(statemachines.get(0));
107 | final StateMachineAccessor stateMachine = new StateMachineAccessor(regions.get(0));
108 |
109 | logger.info(statemachines.get(0));
110 | logger.info(regions.get(0));
111 | logger.info(stateMachine.getInitialStates());
112 | logger.info(stateMachine.getFinalStates());
113 | logger.info(stateMachine.getEdges());
114 |
115 | logger.info(stateMachine.getStateMappings());
116 |
117 | final String[] edges = stateMachine.getEdges().split("\n");
118 | for (String edge : edges) {
119 | final String[] vertices = edge.split(" ");
120 | logger.info(stateMachine.getReversedStateMappings().get(vertices[0]).getName() + " :: "
121 | + stateMachine.getReversedStateMappings().get(vertices[1]).getName());
122 | }
123 |
124 | List paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
125 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
126 | TestCoverageCriteria.NODECOVERAGE);
127 |
128 | assertNotNull(paths);
129 | logger.info(paths);
130 |
131 | for (Path path : paths) {
132 | final Iterator nodes = path.getNodeIterator();
133 | while (nodes.hasNext()) {
134 | final String node = nodes.next().toString();
135 | logger.info(stateMachine.getReversedStateMappings().get(node).getName());
136 | }
137 | }
138 |
139 | paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
140 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
141 | TestCoverageCriteria.EDGECOVERAGE);
142 |
143 | assertNotNull(paths);
144 | logger.info(paths);
145 | for (Path path : paths) {
146 | final Iterator nodes = path.getNodeIterator();
147 | while (nodes.hasNext()) {
148 | final String node = nodes.next().toString();
149 | logger.info(stateMachine.getReversedStateMappings().get(node).getName());
150 | }
151 | }
152 | }
153 |
154 | /**
155 | *
156 | * @throws IOException
157 | * when IO exceptions happen
158 | * @throws InvalidInputException
159 | * when there are invalid inputs for a graph
160 | * @throws InvalidGraphException
161 | * when the graph is invalid
162 | */
163 | @Test
164 | public final void testGetTestPathsForPlinth()
165 | throws IOException, InvalidInputException, InvalidGraphException {
166 |
167 | final EObject object = StateMachineAccessor.getModelObject(plinthPath);
168 | final List statemachines = StateMachineAccessor.getStateMachines(object);
169 | final List regions = StateMachineAccessor.getRegions(statemachines.get(0));
170 | final StateMachineAccessor stateMachine = new StateMachineAccessor(regions.get(0));
171 |
172 | logger.info(statemachines.get(0));
173 | logger.info(regions.get(0));
174 | logger.info(stateMachine.getInitialStates());
175 | logger.info(stateMachine.getFinalStates());
176 | logger.info(stateMachine.getEdges());
177 |
178 | for (Transition t : stateMachine.getTransitions()) {
179 | logger.info(t.getQualifiedName());
180 | logger.info(stateMachine.getStateMappings().get(t.getSource()) + " "
181 | + stateMachine.getStateMappings().get(t.getTarget()));
182 | }
183 |
184 | for (Vertex v : stateMachine.getStateMappings().keySet()) {
185 | if (v instanceof State) {
186 | logger.info(((State) v).getQualifiedName() + " "
187 | + stateMachine.getStateMappings().get(v));
188 | } else if (v instanceof FinalState) {
189 | logger.info(((FinalState) v).getQualifiedName() + " "
190 | + stateMachine.getStateMappings().get(v));
191 | } else if (((Pseudostate) v).getKind() == PseudostateKind.INITIAL_LITERAL) {
192 | logger.info(((Pseudostate) v).getQualifiedName() + " "
193 | + stateMachine.getStateMappings().get(v));
194 | }
195 | }
196 |
197 | List paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
198 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
199 | TestCoverageCriteria.NODECOVERAGE);
200 |
201 | assertNotNull(paths);
202 | logger.info(paths);
203 |
204 | paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
205 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
206 | TestCoverageCriteria.EDGECOVERAGE);
207 |
208 | assertNotNull(paths);
209 | logger.info(paths);
210 |
211 | paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
212 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
213 | TestCoverageCriteria.EDGEPAIRCOVERAGE);
214 |
215 | assertNotNull(paths);
216 | logger.info(paths);
217 |
218 | paths = AbstractTestGenerator.getTestPaths(stateMachine.getEdges(),
219 | stateMachine.getInitialStates(), stateMachine.getFinalStates(),
220 | TestCoverageCriteria.PRIMEPATHCOVERAGE);
221 |
222 | assertNotNull(paths);
223 | logger.info(paths);
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/src/test/resources/testData/VendingMachine/model/VendingMachineFSM.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | credit = 0
10 | stock = 0
11 |
12 |
13 |
14 | credit = 0
15 | stock = 0
16 |
17 |
18 | credit = 0
19 | stock = 0
20 |
21 | credit = 0
22 | 0 < stock < 10
23 |
24 |
25 | 0 < credit < 90
26 | stock = 0
27 |
28 |
29 | 0 < credit < 90
30 | 0 < stock < 10
31 |
32 |
33 | 0 < credit < 90
34 | stock = 10
35 |
36 |
37 |
38 | 0 < credit < 90
39 | stock = 0
40 |
41 | credit >= 90
42 | stock = 0
43 |
44 |
45 | credit >= 90
46 | 0< stock < 10
47 |
48 |
49 | credit >= 90
50 | stock = 10
51 |
52 |
53 | credit = 0
54 | stock = 10
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/VendingMachine/model/VendingMachineFSM.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | credit = 0
10 | stock = 0
11 |
12 |
13 |
14 | credit = 0
15 | stock = 0
16 |
17 |
18 | credit = 0
19 | stock = 0
20 |
21 | credit = 0
22 | 0 < stock < 10
23 |
24 |
25 | 0 < credit < 90
26 | stock = 0
27 |
28 |
29 | 0 < credit < 90
30 | 0 < stock < 10
31 |
32 |
33 | 0 < credit < 90
34 | stock = 10
35 |
36 |
37 |
38 | 0 < credit < 90
39 | stock = 0
40 |
41 | credit >= 90
42 | stock = 0
43 |
44 |
45 | credit >= 90
46 | 0< stock < 10
47 |
48 |
49 | credit >= 90
50 | stock = 10
51 |
52 |
53 | credit = 0
54 | stock = 10
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/roc/RocEdgePairCoverage.feature:
--------------------------------------------------------------------------------
1 | Feature: Roc feature file generated from a state machine diagram
2 |
3 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete addValidSteps checkUntilRunning terminate
4 | Given initializeWithValidKeys
5 | When startEmr
6 | Then emrCreationIsSuccess
7 | When addValidSteps
8 | And checkStepsUntilComplete
9 | Then stepsAreCompleteWaiting
10 | When addValidSteps
11 | And checkUntilRunning
12 | Then emrIsRunning
13 | When terminate
14 | Then terminationIsSuccess
15 |
16 |
17 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning checkInvalidStepId terminate
18 | Given initializeWithValidKeys
19 | When startEmr
20 | Then emrCreationIsSuccess
21 | When addValidSteps
22 | And checkUntilRunning
23 | Then emrIsRunning
24 | When checkInvalidStepId
25 | Then invalidStepIdErrorOccur
26 | When terminate
27 | Then terminationIsSuccess
28 |
29 |
30 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkUntilRunning runUntilWaiting checkInvalidStepId terminate
31 | Given initializeWithValidKeys
32 | When startEmr
33 | Then emrCreationIsSuccess
34 | When startUntilRunning
35 | Then emrIsRunning
36 | When addValidSteps
37 | And checkUntilRunning
38 | Then emrIsRunning
39 | When runUntilWaiting
40 | Then stepsAreCompleteWaiting
41 | When checkInvalidStepId
42 | Then invalidStepIdErrorOccur
43 | When terminate
44 | Then terminationIsSuccess
45 |
46 |
47 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps terminate
48 | Given initializeWithValidKeys
49 | When startEmr
50 | Then emrCreationIsSuccess
51 | When startUntilRunning
52 | Then emrIsRunning
53 | When runUntilWaiting
54 | Then stepsAreCompleteWaiting
55 | When addValidSteps
56 | And terminate
57 | Then terminationIsSuccess
58 |
59 |
60 | Scenario: initializeWithValidKeys startEmr addValidSteps addInvalidSteps checkUntilGettingErrors
61 | Given initializeWithValidKeys
62 | When startEmr
63 | Then emrCreationIsSuccess
64 | When addValidSteps
65 | And addInvalidSteps
66 | And checkUntilGettingErrors
67 | Then invalidStepErrorOccur
68 |
69 |
70 | Scenario: initializeWithValidKeys startEmr startUntilRunning addInvalidSteps addValidSteps checkUntilGettingErrors
71 | Given initializeWithValidKeys
72 | When startEmr
73 | Then emrCreationIsSuccess
74 | When startUntilRunning
75 | Then emrIsRunning
76 | When addInvalidSteps
77 | And addValidSteps
78 | And checkUntilGettingErrors
79 | Then invalidStepErrorOccur
80 |
81 |
82 | Scenario: initializeWithValidKeys startEmr addInvalidSteps addValidSteps addValidSteps checkUntilGettingErrors
83 | Given initializeWithValidKeys
84 | When startEmr
85 | Then emrCreationIsSuccess
86 | When addInvalidSteps
87 | And addValidSteps
88 | And addValidSteps
89 | And checkUntilGettingErrors
90 | Then invalidStepErrorOccur
91 |
92 |
93 | Scenario: initializeWithInvalidKeys startEmrWithErrorStatus
94 | Given initializeWithInvalidKeys
95 | When startEmrWithErrorStatus
96 | Then invalidKeyErrorOccur
97 |
98 |
99 | Scenario: initializeWithValidKeys startEmr terminate
100 | Given initializeWithValidKeys
101 | When startEmr
102 | Then emrCreationIsSuccess
103 | When terminate
104 | Then terminationIsSuccess
105 |
106 |
107 | Scenario: initializeWithValidKeys startEmr checkInvalidStepId terminate
108 | Given initializeWithValidKeys
109 | When startEmr
110 | Then emrCreationIsSuccess
111 | When checkInvalidStepId
112 | Then invalidStepIdErrorOccur
113 | When terminate
114 | Then terminationIsSuccess
115 |
116 |
117 | Scenario: initializeWithValidKeys startEmr startUntilRunning terminate
118 | Given initializeWithValidKeys
119 | When startEmr
120 | Then emrCreationIsSuccess
121 | When startUntilRunning
122 | Then emrIsRunning
123 | When terminate
124 | Then terminationIsSuccess
125 |
126 |
127 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning runUntilWaiting addInvalidSteps addValidSteps checkUntilGettingErrors
128 | Given initializeWithValidKeys
129 | When startEmr
130 | Then emrCreationIsSuccess
131 | When addValidSteps
132 | And checkUntilRunning
133 | Then emrIsRunning
134 | When runUntilWaiting
135 | Then stepsAreCompleteWaiting
136 | When addInvalidSteps
137 | And addValidSteps
138 | And checkUntilGettingErrors
139 | Then invalidStepErrorOccur
140 |
141 |
142 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete addValidSteps addInvalidSteps addValidSteps checkUntilGettingErrors
143 | Given initializeWithValidKeys
144 | When startEmr
145 | Then emrCreationIsSuccess
146 | When addValidSteps
147 | And checkStepsUntilComplete
148 | Then stepsAreCompleteWaiting
149 | When addValidSteps
150 | And addInvalidSteps
151 | And addValidSteps
152 | And checkUntilGettingErrors
153 | Then invalidStepErrorOccur
154 |
155 |
156 | Scenario: initializeWithValidKeys startEmr addValidSteps terminate
157 | Given initializeWithValidKeys
158 | When startEmr
159 | Then emrCreationIsSuccess
160 | When addValidSteps
161 | And terminate
162 | Then terminationIsSuccess
163 |
164 |
165 | Scenario: initializeWithValidKeys startEmr addValidSteps checkInvalidStepId terminate
166 | Given initializeWithValidKeys
167 | When startEmr
168 | Then emrCreationIsSuccess
169 | When addValidSteps
170 | And checkInvalidStepId
171 | Then invalidStepIdErrorOccur
172 | When terminate
173 | Then terminationIsSuccess
174 |
175 |
176 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete addInvalidSteps checkUntilGettingErrors
177 | Given initializeWithValidKeys
178 | When startEmr
179 | Then emrCreationIsSuccess
180 | When addValidSteps
181 | And checkStepsUntilComplete
182 | Then stepsAreCompleteWaiting
183 | When addInvalidSteps
184 | And checkUntilGettingErrors
185 | Then invalidStepErrorOccur
186 |
187 |
188 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkStepsUntilComplete addValidSteps checkStepsUntilComplete addValidSteps checkUntilRunning runUntilWaiting terminate
189 | Given initializeWithValidKeys
190 | When startEmr
191 | Then emrCreationIsSuccess
192 | When startUntilRunning
193 | Then emrIsRunning
194 | When addValidSteps
195 | And checkStepsUntilComplete
196 | Then stepsAreCompleteWaiting
197 | When addValidSteps
198 | And checkStepsUntilComplete
199 | Then stepsAreCompleteWaiting
200 | When addValidSteps
201 | And checkUntilRunning
202 | Then emrIsRunning
203 | When runUntilWaiting
204 | Then stepsAreCompleteWaiting
205 | When terminate
206 | Then terminationIsSuccess
207 |
208 |
209 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkUntilRunning addValidSteps checkUntilRunning runUntilWaiting addValidSteps checkUntilRunning addInvalidSteps checkUntilGettingErrors
210 | Given initializeWithValidKeys
211 | When startEmr
212 | Then emrCreationIsSuccess
213 | When startUntilRunning
214 | Then emrIsRunning
215 | When addValidSteps
216 | And checkUntilRunning
217 | Then emrIsRunning
218 | When addValidSteps
219 | And checkUntilRunning
220 | Then emrIsRunning
221 | When runUntilWaiting
222 | Then stepsAreCompleteWaiting
223 | When addValidSteps
224 | And checkUntilRunning
225 | Then emrIsRunning
226 | When addInvalidSteps
227 | And checkUntilGettingErrors
228 | Then invalidStepErrorOccur
229 |
230 |
231 | Scenario: initializeWithValidKeys startEmr addInvalidSteps checkUntilGettingErrors
232 | Given initializeWithValidKeys
233 | When startEmr
234 | Then emrCreationIsSuccess
235 | When addInvalidSteps
236 | And checkUntilGettingErrors
237 | Then invalidStepErrorOccur
238 |
239 |
240 | Scenario: initializeWithValidKeys startEmr startUntilRunning checkInvalidStepId terminate
241 | Given initializeWithValidKeys
242 | When startEmr
243 | Then emrCreationIsSuccess
244 | When startUntilRunning
245 | Then emrIsRunning
246 | When checkInvalidStepId
247 | Then invalidStepIdErrorOccur
248 | When terminate
249 | Then terminationIsSuccess
250 |
251 |
252 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps checkInvalidStepId terminate
253 | Given initializeWithValidKeys
254 | When startEmr
255 | Then emrCreationIsSuccess
256 | When startUntilRunning
257 | Then emrIsRunning
258 | When runUntilWaiting
259 | Then stepsAreCompleteWaiting
260 | When addValidSteps
261 | And checkInvalidStepId
262 | Then invalidStepIdErrorOccur
263 | When terminate
264 | Then terminationIsSuccess
265 |
266 |
267 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps addInvalidSteps checkUntilGettingErrors
268 | Given initializeWithValidKeys
269 | When startEmr
270 | Then emrCreationIsSuccess
271 | When startUntilRunning
272 | Then emrIsRunning
273 | When addValidSteps
274 | And addInvalidSteps
275 | And checkUntilGettingErrors
276 | Then invalidStepErrorOccur
277 |
278 |
279 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps terminate
280 | Given initializeWithValidKeys
281 | When startEmr
282 | Then emrCreationIsSuccess
283 | When startUntilRunning
284 | Then emrIsRunning
285 | When addValidSteps
286 | And terminate
287 | Then terminationIsSuccess
288 |
289 |
290 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkInvalidStepId terminate
291 | Given initializeWithValidKeys
292 | When startEmr
293 | Then emrCreationIsSuccess
294 | When startUntilRunning
295 | Then emrIsRunning
296 | When addValidSteps
297 | And checkInvalidStepId
298 | Then invalidStepIdErrorOccur
299 | When terminate
300 | Then terminationIsSuccess
301 |
302 |
303 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete terminate
304 | Given initializeWithValidKeys
305 | When startEmr
306 | Then emrCreationIsSuccess
307 | When addValidSteps
308 | And checkStepsUntilComplete
309 | Then stepsAreCompleteWaiting
310 | When terminate
311 | Then terminationIsSuccess
312 |
313 |
314 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete checkInvalidStepId terminate
315 | Given initializeWithValidKeys
316 | When startEmr
317 | Then emrCreationIsSuccess
318 | When addValidSteps
319 | And checkStepsUntilComplete
320 | Then stepsAreCompleteWaiting
321 | When checkInvalidStepId
322 | Then invalidStepIdErrorOccur
323 | When terminate
324 | Then terminationIsSuccess
325 |
326 |
327 |
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/util/JavaSupporter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire.util;
7 |
8 | import java.io.BufferedInputStream;
9 | import java.io.File;
10 | import java.io.FileInputStream;
11 | import java.io.FileOutputStream;
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.io.OutputStream;
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | import org.eclipse.uml2.uml.NamedElement;
19 |
20 | import com.mdsol.skyfire.Mapping;
21 |
22 | /**
23 | * A utility class used to support compilation of Java classes
24 | *
25 | * @author Nan Li
26 | * @version 1.0 Feb 8, 2013
27 | */
28 |
29 | public class JavaSupporter {
30 |
31 | /**
32 | * This default constructor should prevent instantiating utility class
33 | */
34 | protected JavaSupporter() {
35 | throw new UnsupportedOperationException();
36 | }
37 |
38 | /**
39 | * Returns all Java files in a directory specified by path
40 | *
41 | * @param path
42 | * the current path of a directory
43 | * @return a {@link java.util.List} of {@link java.io.File}s that are Java files
44 | */
45 | public static final List returnAllJavaFiles(final String path) {
46 |
47 | final File folder = new File(path);
48 | final File[] files = folder.listFiles();
49 | final List results = new ArrayList<>();
50 |
51 | for (final File file : files) {
52 | if (file.isFile() && file.getName().endsWith(".java")) {
53 | results.add(file);
54 | }
55 | }
56 |
57 | return results;
58 | }
59 |
60 | /**
61 | * Returns all Jar files in a directory specified by path
62 | *
63 | * @param path
64 | * the current path of a directory
65 | * @return a {@link java.util.List} of {@link java.io.File}s that are Jar files
66 | */
67 | public static final List returnAllJarFiles(final String path) {
68 |
69 | final File folder = new File(path);
70 | final File[] files = folder.listFiles();
71 | final List results = new ArrayList<>();
72 |
73 | for (final File file : files) {
74 | if (file.isFile() && file.getName().endsWith(".jar")) {
75 | results.add(file);
76 | }
77 | }
78 |
79 | return results;
80 | }
81 |
82 | /**
83 | * Removes the semicolon if there is one at the end of a String object.
84 | *
85 | * @param string
86 | * a statement having semicolons at the end in a String format
87 | * @return a String object without having a semicolon at the end
88 | */
89 | public static final String removeSemiColon(final String string) {
90 | String result = string;
91 | if (string.endsWith(";")) {
92 | result = string.substring(0, string.length() - 1);
93 | if (result.endsWith(";")) {
94 | result = removeSemiColon(result);
95 | }
96 | } else {
97 | return result;
98 | }
99 | return result;
100 | }
101 |
102 | /**
103 | * Copies a File object from the source to the destination.
104 | *
105 | * @param source
106 | * the source file
107 | * @param destination
108 | * the destination file
109 | * @throws IOException
110 | * when either the source or destination file is not found
111 | */
112 | public static final void copyFile(final File source, final File destination)
113 | throws IOException {
114 | final InputStream oInStream = new FileInputStream(source);
115 | final OutputStream oOutStream = new FileOutputStream(destination);
116 |
117 | // Transfer bytes from in to out
118 | final byte[] oBytes = new byte[1024];
119 | int nLength;
120 | final BufferedInputStream oBuffInputStream = new BufferedInputStream(oInStream);
121 |
122 | while ((nLength = oBuffInputStream.read(oBytes)) > 0) {
123 | oOutStream.write(oBytes, 0, nLength);
124 | }
125 |
126 | oInStream.close();
127 | oOutStream.close();
128 | }
129 |
130 | /**
131 | * Returns all UML files in a directory specified by path.
132 | *
133 | * @param path
134 | * the current path of a directory
135 | * @return a {@link java.util.List} of {@link java.io.File}s that are Java files
136 | */
137 | public static final List returnAllUmlFiles(final String path) {
138 |
139 | final File folder = new File(path);
140 | final File[] files = folder.listFiles();
141 | final List results = new ArrayList<>();
142 |
143 | for (final File file : files) {
144 | if (file.isFile() && file.getName().endsWith(".uml")) {
145 | results.add(file);
146 | }
147 | }
148 |
149 | return results;
150 | }
151 |
152 | /**
153 | * Returns all sub-directories in a directory specified by path.
154 | *
155 | * @param path
156 | * the current path of a directory
157 | * @return a {@link java.util.List} of {@link java.io.File}s that are Java files
158 | */
159 | public static final List returnAllDirectories(final String path) {
160 |
161 | final File folder = new File(path);
162 | final File[] files = folder.listFiles();
163 | final List results = new ArrayList<>();
164 |
165 | for (final File file : files) {
166 | if (file.isDirectory()) {
167 | results.add(file);
168 | }
169 | }
170 | return results;
171 | }
172 |
173 | /**
174 | * Get the names of a list of File objects.
175 | *
176 | * @param files
177 | * a list of File objects
178 | * @return an array of names of File objects
179 | */
180 | public static final Object[] getFileNames(final List files) {
181 | final List fileNames = new ArrayList<>();
182 | for (final File file : files) {
183 | fileNames.add(file.getName());
184 | }
185 | return fileNames.toArray();
186 | }
187 |
188 | /**
189 | * Get the names of a list of {@link org.eclipse.uml2.uml.NamedElement} objects.
190 | *
191 | * @param elements
192 | * a list of {@link org.eclipse.uml2.uml.NamedElement} objects
193 | * @return an array of names of {@link org.eclipse.uml2.uml.NamedElement} objects
194 | */
195 | public static final Object[] getElementNames(final List elements) {
196 | final List elementNames = new ArrayList<>();
197 | for (final NamedElement element : elements) {
198 | elementNames.add(element.getName());
199 | }
200 | return elementNames.toArray();
201 | }
202 |
203 | /**
204 | * Get the names of a list of {@link edu.gmu.swe.taf.Mapping} objects.
205 | *
206 | * @param mappings
207 | * a list of {@link edu.gmu.swe.taf.Mapping} objects
208 | * @return an array of names of {@link edu.gmu.swe.taf.Mapping} objects
209 | */
210 | public static final Object[] getMappingNames(final List extends Mapping> mappings) {
211 | final List mappingNames = new ArrayList<>();
212 | for (final Mapping mapping : mappings) {
213 | mappingNames.add(mapping.getName());
214 | }
215 | return mappingNames.toArray();
216 | }
217 |
218 | /**
219 | * Convert a packageName separated by dot to a file path having the package names separated by
220 | * slash.
221 | *
222 | * @param packageName
223 | * a package name that could have dot or have no dot
224 | * @return a path in a String format
225 | */
226 | public static final String returnPackages(final String packageName) {
227 | if (packageName != null && packageName.trim().length() > 0) {
228 | String name = packageName;
229 | if (packageName.startsWith("package")) {
230 | name = name.substring(7, name.length()).trim();
231 | }
232 | if (name.endsWith(";")) {
233 | name = removeSemiColon(name);
234 | }
235 | final String[] levels = name.split("\\.");
236 | String directories = "";
237 | for (final String level : levels) {
238 | directories += level + "/";
239 | }
240 | return directories;
241 | }
242 | return "";
243 | }
244 |
245 | /**
246 | * Removes the header "package" and ";" at the end if any.
247 | *
248 | * @param packageName
249 | * a package name in a String format
250 | * @return the package name without "package" keyword and ";"
251 | */
252 | public static final String cleanUpPackageName(final String packageName) {
253 | if (packageName != null && packageName.trim().length() > 0) {
254 | String name = packageName;
255 | if (packageName.startsWith("package")) {
256 | name = name.substring(7, name.length()).trim();
257 | }
258 | if (name.endsWith(";")) {
259 | name = removeSemiColon(name);
260 | }
261 | return name.trim();
262 | }
263 | return "";
264 | }
265 |
266 | /**
267 | * Removes the brackets in the toString() result used by List
268 | *
269 | * @param listString
270 | * toString() result by java.util.List
271 | * @return the same String representation without brackets
272 | */
273 | public static final String removeBrackets(final String listString) {
274 | if (listString.startsWith("[") && listString.endsWith("]")) {
275 | // remove brackets
276 | return listString.substring(1, listString.length() - 1);
277 | } else {
278 | return listString;
279 | }
280 | }
281 |
282 | }
283 |
--------------------------------------------------------------------------------
/Eclipse Public License - Version 1.0:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 1.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
4 |
5 | 1. DEFINITIONS
6 |
7 | "Contribution" means:
8 |
9 | a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
10 | b) in the case of each subsequent Contributor:
11 | i) changes to the Program, and
12 | ii) additions to the Program;
13 | where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
14 | "Contributor" means any person or entity that distributes the Program.
15 |
16 | "Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
17 |
18 | "Program" means the Contributions distributed in accordance with this Agreement.
19 |
20 | "Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
21 |
22 | 2. GRANT OF RIGHTS
23 |
24 | a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
25 | b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
26 | c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
27 | d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
28 | 3. REQUIREMENTS
29 |
30 | A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
31 |
32 | a) it complies with the terms and conditions of this Agreement; and
33 | b) its license agreement:
34 | i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
35 | ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
36 | iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
37 | iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
38 | When the Program is made available in source code form:
39 |
40 | a) it must be made available under this Agreement; and
41 | b) a copy of this Agreement must be included with each copy of the Program.
42 | Contributors may not remove or alter any copyright notices contained within the Program.
43 |
44 | Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
45 |
46 | 4. COMMERCIAL DISTRIBUTION
47 |
48 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
49 |
50 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
51 |
52 | 5. NO WARRANTY
53 |
54 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
55 |
56 | 6. DISCLAIMER OF LIABILITY
57 |
58 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
59 |
60 | 7. GENERAL
61 |
62 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
63 |
64 | If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
65 |
66 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
67 |
68 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
69 |
70 | This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
--------------------------------------------------------------------------------
/src/main/java/com/mdsol/skyfire/ModelAccessor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import java.io.IOException;
9 | import java.net.URL;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | import org.apache.logging.log4j.LogManager;
15 | import org.apache.logging.log4j.Logger;
16 | import org.eclipse.acceleo.common.IAcceleoConstants;
17 | import org.eclipse.acceleo.common.internal.utils.AcceleoPackageRegistry;
18 | import org.eclipse.acceleo.common.internal.utils.workspace.AcceleoWorkspaceUtil;
19 | import org.eclipse.acceleo.common.internal.utils.workspace.BundleURLConverter;
20 | import org.eclipse.acceleo.common.utils.ModelUtils;
21 | import org.eclipse.acceleo.model.mtl.MtlPackage;
22 | import org.eclipse.acceleo.model.mtl.resource.AcceleoResourceSetImpl;
23 | import org.eclipse.acceleo.model.mtl.resource.EMtlBinaryResourceFactoryImpl;
24 | import org.eclipse.acceleo.model.mtl.resource.EMtlResourceFactoryImpl;
25 | import org.eclipse.emf.common.EMFPlugin;
26 | import org.eclipse.emf.common.util.EList;
27 | import org.eclipse.emf.common.util.URI;
28 | import org.eclipse.emf.ecore.EObject;
29 | import org.eclipse.emf.ecore.EPackage;
30 | import org.eclipse.emf.ecore.EcorePackage;
31 | import org.eclipse.emf.ecore.plugin.EcorePlugin;
32 | import org.eclipse.emf.ecore.resource.ResourceSet;
33 | import org.eclipse.emf.ecore.resource.URIConverter;
34 | import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
35 | import org.eclipse.emf.ecore.util.EcoreUtil;
36 | import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
37 | import org.eclipse.ocl.ecore.EcoreEnvironment;
38 | import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
39 | import org.eclipse.ocl.expressions.ExpressionsPackage;
40 | import org.eclipse.uml2.uml.Element;
41 | import org.eclipse.uml2.uml.Model;
42 | import org.eclipse.uml2.uml.StateMachine;
43 |
44 | /**
45 | * A class that provides functions to access UML models. Classes in Acceleo are used to be helpers
46 | * to access the models.
47 | *
48 | * @author Nan Li
49 | * @version 1.0 Nov 14, 2012
50 | */
51 | public class ModelAccessor {
52 |
53 | private static Logger logger = LogManager.getLogger("ModelAccessor");
54 |
55 | /**
56 | * Gets the {@link org.eclipse.emf.ecore.EObject} object of a UML model specified by path
57 | *
58 | * @param path
59 | * a String representation of the path of a UML model
60 | * @return an {@link org.eclipse.emf.ecore.EObject} object
61 | * @throws IOException
62 | * when the path to the model is not found
63 | */
64 | public static EObject getModelObject(final String path) throws IOException {
65 |
66 | final URI modelURI = URI.createFileURI(path);
67 |
68 | final URIConverter uriConverter = createURIConverter();
69 |
70 | @SuppressWarnings("deprecation")
71 | final Map uriMap = EcorePlugin.computePlatformURIMap();
72 |
73 | final ResourceSet modelResourceSet = new AcceleoResourceSetImpl();
74 | modelResourceSet.setPackageRegistry(AcceleoPackageRegistry.INSTANCE);
75 |
76 | if (uriConverter != null) {
77 | modelResourceSet.setURIConverter(uriConverter);
78 | }
79 |
80 | // make sure that metamodel projects in the workspace override those in
81 | // plugins
82 | modelResourceSet.getURIConverter().getURIMap().putAll(uriMap);
83 |
84 | registerResourceFactories(modelResourceSet);
85 | registerPackages(modelResourceSet);
86 |
87 | final URI newModelURI = URI.createURI(modelURI.toString(), true);
88 | final EObject model = ModelUtils.load(newModelURI, modelResourceSet);
89 | return model;
90 | }
91 |
92 | /**
93 | * Gets all objects of {@link org.eclipse.uml2.uml.StateMachine} in the model
94 | *
95 | * @param model
96 | * a UML model to parse
97 | * @return a list of {@link org.eclipse.uml2.uml.StateMachine} in the model
98 | */
99 | public static List getStateMachines(final EObject model) {
100 |
101 | final List result = new ArrayList<>();
102 | final EList elements = ((Model) model).getOwnedElements();
103 |
104 | for (final Element elementObject : elements) {
105 | if (elementObject instanceof StateMachine) {
106 | result.add((StateMachine) elementObject);
107 | }
108 | }
109 |
110 | return result;
111 | }
112 |
113 | /**
114 | * The methods below are copied from Acceleo.
115 | */
116 |
117 | /**
118 | * Creates the URI Converter we'll use to load our modules. Take note that this should never be
119 | * used out of Eclipse.
120 | *
121 | * @return The created URI Converter.
122 | * @since 3.0
123 | */
124 | protected static URIConverter createURIConverter() {
125 | if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
126 | return null;
127 | }
128 |
129 | return new ExtensibleURIConverterImpl() {
130 | /**
131 | * {@inheritDoc}
132 | *
133 | */
134 | @Override
135 | public URI normalize(final URI uri) {
136 | URI normalized = getURIMap().get(uri);
137 | if (normalized == null) {
138 | final BundleURLConverter conv = new BundleURLConverter(uri.toString());
139 | if (conv.resolveBundle() != null) {
140 | normalized = URI.createURI(conv.resolveAsPlatformPlugin());
141 | getURIMap().put(uri, normalized);
142 | }
143 | }
144 | if (normalized != null) {
145 | return normalized;
146 | }
147 | return super.normalize(uri);
148 | }
149 | };
150 | }
151 |
152 | /**
153 | * This will update the resource set's package registry with all usual EPackages.
154 | *
155 | * @param resourceSet
156 | * The resource set which registry has to be updated.
157 | */
158 | public static void registerPackages(final ResourceSet resourceSet) {
159 | resourceSet.getPackageRegistry().put(EcorePackage.eINSTANCE.getNsURI(),
160 | EcorePackage.eINSTANCE);
161 |
162 | resourceSet.getPackageRegistry().put(
163 | org.eclipse.ocl.ecore.EcorePackage.eINSTANCE.getNsURI(),
164 | org.eclipse.ocl.ecore.EcorePackage.eINSTANCE);
165 | resourceSet.getPackageRegistry().put(ExpressionsPackage.eINSTANCE.getNsURI(),
166 | ExpressionsPackage.eINSTANCE);
167 |
168 | resourceSet.getPackageRegistry().put(MtlPackage.eINSTANCE.getNsURI(), MtlPackage.eINSTANCE);
169 |
170 | resourceSet.getPackageRegistry().put("http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore",
171 | getOCLStdLibPackage());
172 |
173 | if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
174 | resourceSet.getPackageRegistry().put(
175 | org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(),
176 | org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
177 | }
178 | }
179 |
180 | /**
181 | * This will update the resource set's resource factory registry with all usual factories.
182 | *
183 | * @param resourceSet
184 | * The resource set which registry has to be updated.
185 | */
186 | public static void registerResourceFactories(final ResourceSet resourceSet) {
187 | resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore",
188 | new EcoreResourceFactoryImpl());
189 | resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap()
190 | .put(IAcceleoConstants.BINARY_CONTENT_TYPE, new EMtlBinaryResourceFactoryImpl());
191 | resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap()
192 | .put(IAcceleoConstants.XMI_CONTENT_TYPE, new EMtlResourceFactoryImpl());
193 | }
194 |
195 | /**
196 | * Returns the package containing the OCL standard library.
197 | *
198 | * @return The package containing the OCL standard library.
199 | */
200 | protected static EPackage getOCLStdLibPackage() {
201 | final EcoreEnvironmentFactory factory = new EcoreEnvironmentFactory();
202 | final EcoreEnvironment environment = (EcoreEnvironment) factory.createEnvironment();
203 | final EPackage oclStdLibPackage = (EPackage) EcoreUtil
204 | .getRootContainer(environment.getOCLStandardLibrary().getBag());
205 | environment.dispose();
206 | return oclStdLibPackage;
207 | }
208 |
209 | /**
210 | * Clients can override this if the default behavior doesn't properly find the emtl module URL.
211 | *
212 | * @param moduleName
213 | * Name of the module we're searching for.
214 | * @return The template's URL. This will use Eclipse-specific behavior if possible, and use the
215 | * class loader otherwise.
216 | */
217 | protected final URL findModuleURL(final String moduleName) {
218 | URL moduleURL = null;
219 | if (EMFPlugin.IS_ECLIPSE_RUNNING) {
220 | try {
221 | moduleURL = AcceleoWorkspaceUtil.getResourceURL(getClass(), moduleName);
222 | } catch (final IOException e) {
223 | // Swallow this, we'll try and locate the module through the
224 | // class loader
225 | logger.error(e);
226 | }
227 | }
228 | if (moduleURL == null) {
229 | moduleURL = getClass().getResource(moduleName);
230 | }
231 | return moduleURL;
232 | }
233 |
234 | /**
235 | * Creates the URI that will be used to resolve the template that is to be launched.
236 | *
237 | * @param entry
238 | * The path towards the template file. Could be a jar or file scheme URI, or we'll
239 | * assume it represents a relative path.
240 | * @return The actual URI from which the template file can be resolved.
241 | */
242 | protected final URI createTemplateURI(final String entry) {
243 | if (entry.startsWith("file:") || entry.startsWith("jar:")) { //$NON-NLS-1$ //$NON-NLS-2$
244 | return URI.createURI(URI.decode(entry));
245 | }
246 | return URI.createFileURI(URI.decode(entry));
247 | }
248 |
249 | /**
250 | * Checks whether the given EPackage class is located in the workspace.
251 | *
252 | * @param ePackageClass
253 | * The EPackage class we need to take into account.
254 | * @return true if the given class has been loaded from a dynamically installed
255 | * bundle, false otherwise.
256 | * @since 3.1
257 | */
258 | public static boolean isInWorkspace(final Class extends EPackage> ePackageClass) {
259 | return EMFPlugin.IS_ECLIPSE_RUNNING
260 | && AcceleoWorkspaceUtil.INSTANCE.isInDynamicBundle(ePackageClass);
261 | }
262 | }
263 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/src/integration-test/resources/testData/roc/RocPrimePathCoverage.feature:
--------------------------------------------------------------------------------
1 | Feature: Roc feature file generated from a state machine diagram
2 |
3 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps checkStepsUntilComplete addValidSteps checkUntilRunning runUntilWaiting addValidSteps checkUntilRunning terminate
4 | Given initializeWithValidKeys
5 | When startEmr
6 | Then emrCreationIsSuccess
7 | When startUntilRunning
8 | Then emrIsRunning
9 | When runUntilWaiting
10 | Then stepsAreCompleteWaiting
11 | When addValidSteps
12 | And checkStepsUntilComplete
13 | Then stepsAreCompleteWaiting
14 | When addValidSteps
15 | And checkUntilRunning
16 | Then emrIsRunning
17 | When runUntilWaiting
18 | Then stepsAreCompleteWaiting
19 | When addValidSteps
20 | And checkUntilRunning
21 | Then emrIsRunning
22 | When terminate
23 | Then terminationIsSuccess
24 |
25 |
26 | Scenario: initializeWithValidKeys startEmr addInvalidSteps addValidSteps checkUntilGettingErrors
27 | Given initializeWithValidKeys
28 | When startEmr
29 | Then emrCreationIsSuccess
30 | When addInvalidSteps
31 | And addValidSteps
32 | And checkUntilGettingErrors
33 | Then invalidStepErrorOccur
34 |
35 |
36 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning addValidSteps checkUntilRunning addValidSteps checkUntilRunning terminate
37 | Given initializeWithValidKeys
38 | When startEmr
39 | Then emrCreationIsSuccess
40 | When addValidSteps
41 | And checkUntilRunning
42 | Then emrIsRunning
43 | When addValidSteps
44 | And checkUntilRunning
45 | Then emrIsRunning
46 | When addValidSteps
47 | And checkUntilRunning
48 | Then emrIsRunning
49 | When terminate
50 | Then terminationIsSuccess
51 |
52 |
53 | Scenario: initializeWithInvalidKeys startEmrWithErrorStatus
54 | Given initializeWithInvalidKeys
55 | When startEmrWithErrorStatus
56 | Then invalidKeyErrorOccur
57 |
58 |
59 | Scenario: initializeWithValidKeys startEmr terminate
60 | Given initializeWithValidKeys
61 | When startEmr
62 | Then emrCreationIsSuccess
63 | When terminate
64 | Then terminationIsSuccess
65 |
66 |
67 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps checkUntilRunning checkInvalidStepId terminate
68 | Given initializeWithValidKeys
69 | When startEmr
70 | Then emrCreationIsSuccess
71 | When startUntilRunning
72 | Then emrIsRunning
73 | When runUntilWaiting
74 | Then stepsAreCompleteWaiting
75 | When addValidSteps
76 | And checkUntilRunning
77 | Then emrIsRunning
78 | When checkInvalidStepId
79 | Then invalidStepIdErrorOccur
80 | When terminate
81 | Then terminationIsSuccess
82 |
83 |
84 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps checkUntilRunning addInvalidSteps checkUntilGettingErrors
85 | Given initializeWithValidKeys
86 | When startEmr
87 | Then emrCreationIsSuccess
88 | When startUntilRunning
89 | Then emrIsRunning
90 | When runUntilWaiting
91 | Then stepsAreCompleteWaiting
92 | When addValidSteps
93 | And checkUntilRunning
94 | Then emrIsRunning
95 | When addInvalidSteps
96 | And checkUntilGettingErrors
97 | Then invalidStepErrorOccur
98 |
99 |
100 | Scenario: initializeWithValidKeys startEmr checkInvalidStepId terminate
101 | Given initializeWithValidKeys
102 | When startEmr
103 | Then emrCreationIsSuccess
104 | When checkInvalidStepId
105 | Then invalidStepIdErrorOccur
106 | When terminate
107 | Then terminationIsSuccess
108 |
109 |
110 | Scenario: initializeWithValidKeys startEmr addValidSteps terminate
111 | Given initializeWithValidKeys
112 | When startEmr
113 | Then emrCreationIsSuccess
114 | When addValidSteps
115 | And terminate
116 | Then terminationIsSuccess
117 |
118 |
119 | Scenario: initializeWithValidKeys startEmr addInvalidSteps checkUntilGettingErrors
120 | Given initializeWithValidKeys
121 | When startEmr
122 | Then emrCreationIsSuccess
123 | When addInvalidSteps
124 | And checkUntilGettingErrors
125 | Then invalidStepErrorOccur
126 |
127 |
128 | Scenario: initializeWithValidKeys startEmr startUntilRunning terminate
129 | Given initializeWithValidKeys
130 | When startEmr
131 | Then emrCreationIsSuccess
132 | When startUntilRunning
133 | Then emrIsRunning
134 | When terminate
135 | Then terminationIsSuccess
136 |
137 |
138 | Scenario: initializeWithValidKeys startEmr addValidSteps addInvalidSteps checkUntilGettingErrors
139 | Given initializeWithValidKeys
140 | When startEmr
141 | Then emrCreationIsSuccess
142 | When addValidSteps
143 | And addInvalidSteps
144 | And checkUntilGettingErrors
145 | Then invalidStepErrorOccur
146 |
147 |
148 | Scenario: initializeWithValidKeys startEmr startUntilRunning checkInvalidStepId terminate
149 | Given initializeWithValidKeys
150 | When startEmr
151 | Then emrCreationIsSuccess
152 | When startUntilRunning
153 | Then emrIsRunning
154 | When checkInvalidStepId
155 | Then invalidStepIdErrorOccur
156 | When terminate
157 | Then terminationIsSuccess
158 |
159 |
160 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete terminate
161 | Given initializeWithValidKeys
162 | When startEmr
163 | Then emrCreationIsSuccess
164 | When addValidSteps
165 | And checkStepsUntilComplete
166 | Then stepsAreCompleteWaiting
167 | When terminate
168 | Then terminationIsSuccess
169 |
170 |
171 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning terminate
172 | Given initializeWithValidKeys
173 | When startEmr
174 | Then emrCreationIsSuccess
175 | When addValidSteps
176 | And checkUntilRunning
177 | Then emrIsRunning
178 | When terminate
179 | Then terminationIsSuccess
180 |
181 |
182 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps terminate
183 | Given initializeWithValidKeys
184 | When startEmr
185 | Then emrCreationIsSuccess
186 | When startUntilRunning
187 | Then emrIsRunning
188 | When addValidSteps
189 | And terminate
190 | Then terminationIsSuccess
191 |
192 |
193 | Scenario: initializeWithValidKeys startEmr startUntilRunning addInvalidSteps checkUntilGettingErrors
194 | Given initializeWithValidKeys
195 | When startEmr
196 | Then emrCreationIsSuccess
197 | When startUntilRunning
198 | Then emrIsRunning
199 | When addInvalidSteps
200 | And checkUntilGettingErrors
201 | Then invalidStepErrorOccur
202 |
203 |
204 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting terminate
205 | Given initializeWithValidKeys
206 | When startEmr
207 | Then emrCreationIsSuccess
208 | When startUntilRunning
209 | Then emrIsRunning
210 | When runUntilWaiting
211 | Then stepsAreCompleteWaiting
212 | When terminate
213 | Then terminationIsSuccess
214 |
215 |
216 | Scenario: initializeWithValidKeys startEmr addValidSteps checkInvalidStepId terminate
217 | Given initializeWithValidKeys
218 | When startEmr
219 | Then emrCreationIsSuccess
220 | When addValidSteps
221 | And checkInvalidStepId
222 | Then invalidStepIdErrorOccur
223 | When terminate
224 | Then terminationIsSuccess
225 |
226 |
227 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkStepsUntilComplete terminate
228 | Given initializeWithValidKeys
229 | When startEmr
230 | Then emrCreationIsSuccess
231 | When startUntilRunning
232 | Then emrIsRunning
233 | When addValidSteps
234 | And checkStepsUntilComplete
235 | Then stepsAreCompleteWaiting
236 | When terminate
237 | Then terminationIsSuccess
238 |
239 |
240 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning addInvalidSteps checkUntilGettingErrors
241 | Given initializeWithValidKeys
242 | When startEmr
243 | Then emrCreationIsSuccess
244 | When addValidSteps
245 | And checkUntilRunning
246 | Then emrIsRunning
247 | When addInvalidSteps
248 | And checkUntilGettingErrors
249 | Then invalidStepErrorOccur
250 |
251 |
252 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkInvalidStepId terminate
253 | Given initializeWithValidKeys
254 | When startEmr
255 | Then emrCreationIsSuccess
256 | When startUntilRunning
257 | Then emrIsRunning
258 | When addValidSteps
259 | And checkInvalidStepId
260 | Then invalidStepIdErrorOccur
261 | When terminate
262 | Then terminationIsSuccess
263 |
264 |
265 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps addInvalidSteps checkUntilGettingErrors
266 | Given initializeWithValidKeys
267 | When startEmr
268 | Then emrCreationIsSuccess
269 | When startUntilRunning
270 | Then emrIsRunning
271 | When addValidSteps
272 | And addInvalidSteps
273 | And checkUntilGettingErrors
274 | Then invalidStepErrorOccur
275 |
276 |
277 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addInvalidSteps checkUntilGettingErrors
278 | Given initializeWithValidKeys
279 | When startEmr
280 | Then emrCreationIsSuccess
281 | When startUntilRunning
282 | Then emrIsRunning
283 | When runUntilWaiting
284 | Then stepsAreCompleteWaiting
285 | When addInvalidSteps
286 | And checkUntilGettingErrors
287 | Then invalidStepErrorOccur
288 |
289 |
290 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps terminate
291 | Given initializeWithValidKeys
292 | When startEmr
293 | Then emrCreationIsSuccess
294 | When startUntilRunning
295 | Then emrIsRunning
296 | When runUntilWaiting
297 | Then stepsAreCompleteWaiting
298 | When addValidSteps
299 | And terminate
300 | Then terminationIsSuccess
301 |
302 |
303 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting checkInvalidStepId terminate
304 | Given initializeWithValidKeys
305 | When startEmr
306 | Then emrCreationIsSuccess
307 | When startUntilRunning
308 | Then emrIsRunning
309 | When runUntilWaiting
310 | Then stepsAreCompleteWaiting
311 | When checkInvalidStepId
312 | Then invalidStepIdErrorOccur
313 | When terminate
314 | Then terminationIsSuccess
315 |
316 |
317 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning runUntilWaiting terminate
318 | Given initializeWithValidKeys
319 | When startEmr
320 | Then emrCreationIsSuccess
321 | When addValidSteps
322 | And checkUntilRunning
323 | Then emrIsRunning
324 | When runUntilWaiting
325 | Then stepsAreCompleteWaiting
326 | When terminate
327 | Then terminationIsSuccess
328 |
329 |
330 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning checkInvalidStepId terminate
331 | Given initializeWithValidKeys
332 | When startEmr
333 | Then emrCreationIsSuccess
334 | When addValidSteps
335 | And checkUntilRunning
336 | Then emrIsRunning
337 | When checkInvalidStepId
338 | Then invalidStepIdErrorOccur
339 | When terminate
340 | Then terminationIsSuccess
341 |
342 |
343 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete checkInvalidStepId terminate
344 | Given initializeWithValidKeys
345 | When startEmr
346 | Then emrCreationIsSuccess
347 | When addValidSteps
348 | And checkStepsUntilComplete
349 | Then stepsAreCompleteWaiting
350 | When checkInvalidStepId
351 | Then invalidStepIdErrorOccur
352 | When terminate
353 | Then terminationIsSuccess
354 |
355 |
356 | Scenario: initializeWithValidKeys startEmr addValidSteps checkStepsUntilComplete addInvalidSteps checkUntilGettingErrors
357 | Given initializeWithValidKeys
358 | When startEmr
359 | Then emrCreationIsSuccess
360 | When addValidSteps
361 | And checkStepsUntilComplete
362 | Then stepsAreCompleteWaiting
363 | When addInvalidSteps
364 | And checkUntilGettingErrors
365 | Then invalidStepErrorOccur
366 |
367 |
368 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkStepsUntilComplete addInvalidSteps checkUntilGettingErrors
369 | Given initializeWithValidKeys
370 | When startEmr
371 | Then emrCreationIsSuccess
372 | When startUntilRunning
373 | Then emrIsRunning
374 | When addValidSteps
375 | And checkStepsUntilComplete
376 | Then stepsAreCompleteWaiting
377 | When addInvalidSteps
378 | And checkUntilGettingErrors
379 | Then invalidStepErrorOccur
380 |
381 |
382 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps checkInvalidStepId terminate
383 | Given initializeWithValidKeys
384 | When startEmr
385 | Then emrCreationIsSuccess
386 | When startUntilRunning
387 | Then emrIsRunning
388 | When runUntilWaiting
389 | Then stepsAreCompleteWaiting
390 | When addValidSteps
391 | And checkInvalidStepId
392 | Then invalidStepIdErrorOccur
393 | When terminate
394 | Then terminationIsSuccess
395 |
396 |
397 | Scenario: initializeWithValidKeys startEmr startUntilRunning runUntilWaiting addValidSteps addInvalidSteps checkUntilGettingErrors
398 | Given initializeWithValidKeys
399 | When startEmr
400 | Then emrCreationIsSuccess
401 | When startUntilRunning
402 | Then emrIsRunning
403 | When runUntilWaiting
404 | Then stepsAreCompleteWaiting
405 | When addValidSteps
406 | And addInvalidSteps
407 | And checkUntilGettingErrors
408 | Then invalidStepErrorOccur
409 |
410 |
411 | Scenario: initializeWithValidKeys startEmr startUntilRunning addValidSteps checkStepsUntilComplete checkInvalidStepId terminate
412 | Given initializeWithValidKeys
413 | When startEmr
414 | Then emrCreationIsSuccess
415 | When startUntilRunning
416 | Then emrIsRunning
417 | When addValidSteps
418 | And checkStepsUntilComplete
419 | Then stepsAreCompleteWaiting
420 | When checkInvalidStepId
421 | Then invalidStepIdErrorOccur
422 | When terminate
423 | Then terminationIsSuccess
424 |
425 |
426 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning runUntilWaiting checkInvalidStepId terminate
427 | Given initializeWithValidKeys
428 | When startEmr
429 | Then emrCreationIsSuccess
430 | When addValidSteps
431 | And checkUntilRunning
432 | Then emrIsRunning
433 | When runUntilWaiting
434 | Then stepsAreCompleteWaiting
435 | When checkInvalidStepId
436 | Then invalidStepIdErrorOccur
437 | When terminate
438 | Then terminationIsSuccess
439 |
440 |
441 | Scenario: initializeWithValidKeys startEmr addValidSteps checkUntilRunning runUntilWaiting addInvalidSteps checkUntilGettingErrors
442 | Given initializeWithValidKeys
443 | When startEmr
444 | Then emrCreationIsSuccess
445 | When addValidSteps
446 | And checkUntilRunning
447 | Then emrIsRunning
448 | When runUntilWaiting
449 | Then stepsAreCompleteWaiting
450 | When addInvalidSteps
451 | And checkUntilGettingErrors
452 | Then invalidStepErrorOccur
453 |
454 |
455 |
--------------------------------------------------------------------------------
/src/integration-test/java/com/mdsol/skyfire/AccessingModelsIT.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
3 | * and the accompanying materials are made under the terms of MIT license.
4 | * Author: Nan Li, nli@mdsol.com
5 | ******************************************************************************/
6 | package com.mdsol.skyfire;
7 |
8 | import java.io.IOException;
9 | import java.net.URL;
10 | import java.util.HashMap;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | import org.apache.logging.log4j.LogManager;
15 | import org.apache.logging.log4j.Logger;
16 | import org.eclipse.acceleo.common.IAcceleoConstants;
17 | import org.eclipse.acceleo.common.internal.utils.AcceleoPackageRegistry;
18 | import org.eclipse.acceleo.common.internal.utils.workspace.AcceleoWorkspaceUtil;
19 | import org.eclipse.acceleo.common.internal.utils.workspace.BundleURLConverter;
20 | import org.eclipse.acceleo.common.utils.ModelUtils;
21 | import org.eclipse.acceleo.model.mtl.MtlPackage;
22 | import org.eclipse.acceleo.model.mtl.resource.AcceleoResourceSetImpl;
23 | import org.eclipse.acceleo.model.mtl.resource.EMtlBinaryResourceFactoryImpl;
24 | import org.eclipse.acceleo.model.mtl.resource.EMtlResourceFactoryImpl;
25 | import org.eclipse.emf.common.EMFPlugin;
26 | import org.eclipse.emf.common.util.EList;
27 | import org.eclipse.emf.common.util.URI;
28 | import org.eclipse.emf.ecore.EObject;
29 | import org.eclipse.emf.ecore.EPackage;
30 | import org.eclipse.emf.ecore.EcorePackage;
31 | import org.eclipse.emf.ecore.plugin.EcorePlugin;
32 | import org.eclipse.emf.ecore.resource.ResourceSet;
33 | import org.eclipse.emf.ecore.resource.URIConverter;
34 | import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
35 | import org.eclipse.emf.ecore.util.EcoreUtil;
36 | import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
37 | import org.eclipse.ocl.ecore.EcoreEnvironment;
38 | import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
39 | import org.eclipse.ocl.expressions.ExpressionsPackage;
40 | import org.eclipse.uml2.uml.Element;
41 | import org.eclipse.uml2.uml.FinalState;
42 | import org.eclipse.uml2.uml.Model;
43 | import org.eclipse.uml2.uml.Package;
44 | import org.eclipse.uml2.uml.Pseudostate;
45 | import org.eclipse.uml2.uml.Region;
46 | import org.eclipse.uml2.uml.StateMachine;
47 | import org.eclipse.uml2.uml.Transition;
48 | import org.eclipse.uml2.uml.Vertex;
49 | import org.junit.Test;
50 |
51 | import coverage.graph.Graph;
52 | import coverage.graph.GraphUtil;
53 | import coverage.graph.InvalidGraphException;
54 | import coverage.graph.Path;
55 | import coverage.web.InvalidInputException;
56 |
57 | public class AccessingModelsIT {
58 |
59 | private static Logger logger = LogManager.getLogger("ModelAccessorIT");
60 |
61 | @Test
62 | public void accessingModelstest()
63 | throws IOException, InvalidInputException, InvalidGraphException {
64 | String path = System.getProperty("user.dir")
65 | + "/src/test/resources/testData/VendingMachine/model";
66 | String umlPath = path + "/VendingMachineFSM.uml";
67 |
68 | URI modelURI = URI.createFileURI(umlPath);
69 |
70 | URIConverter uriConverter = createURIConverter();
71 |
72 | Map uriMap = EcorePlugin.computePlatformURIMap();
73 |
74 | ResourceSet modelResourceSet = new AcceleoResourceSetImpl();
75 | modelResourceSet.setPackageRegistry(AcceleoPackageRegistry.INSTANCE);
76 |
77 | if (uriConverter != null) {
78 | modelResourceSet.setURIConverter(uriConverter);
79 | }
80 |
81 | // make sure that metamodel projects in the workspace override those in plugins
82 | modelResourceSet.getURIConverter().getURIMap().putAll(uriMap);
83 |
84 | registerResourceFactories(modelResourceSet);
85 | registerPackages(modelResourceSet);
86 |
87 | URI newModelURI = URI.createURI(modelURI.toString(), true);
88 | EObject model = ModelUtils.load(newModelURI, modelResourceSet);
89 |
90 | EList packages = ((Model) model).getNestedPackages();
91 | for (Package packageObject : packages) {
92 | logger.info(packageObject.getName());
93 | }
94 |
95 | EList elements = ((Model) model).getOwnedElements();
96 |
97 | for (Element elementObject : elements) {
98 | if (elementObject instanceof StateMachine) {
99 | EList regions = ((StateMachine) elementObject).getRegions();
100 | for (Region region : regions) {
101 |
102 | EList transitions = region.getTransitions();
103 | EList vertices = region.getSubvertices();
104 |
105 | HashMap map = new HashMap<>();
106 | map.put("State1", "1");
107 | map.put("State2", "2");
108 | map.put("State3", "3");
109 | map.put("State4", "4");
110 | map.put("State5", "5");
111 | map.put("State6", "6");
112 | map.put("State7", "7");
113 | map.put("State8", "8");
114 | map.put("State9", "9");
115 |
116 | processVertices(vertices, map);
117 |
118 | String sourceNumber = "0";
119 | String targetNumber = "10";
120 | String edges = processTransitions(transitions, map);
121 | logger.info(edges);
122 | logger.info(getTestPaths(edges, sourceNumber, targetNumber));
123 | }
124 | }
125 | }
126 | }
127 |
128 | private void processVertices(final EList vertices, final HashMap map) {
129 | for (Vertex vertex : vertices) {
130 | logger.info(vertex.getName());
131 |
132 | if (vertex instanceof FinalState)
133 | map.put(vertex.getName(), "10");
134 | if (vertex instanceof Pseudostate) {
135 | map.put(vertex.getName(), "0");
136 | printOutgoingEdges(vertex);
137 | }
138 | }
139 | }
140 |
141 | private void printOutgoingEdges(final Vertex vertex) {
142 | EList outgoings = vertex.getOutgoings();
143 | for (Transition t : outgoings) {
144 | logger.info(vertex.getName() + "'s transition: " + t.getName());
145 | }
146 | }
147 |
148 | private String processTransitions(final List transitions,
149 | final HashMap map) {
150 | String edges = "";
151 | for (Transition transition : transitions) {
152 | // transitions may not have a source or target because some of them are
153 | // leftover
154 | // they do not appear in the UML diagram but they do exist in the UML model
155 | if (transition.getSource() != null && transition.getTarget() != null) {
156 | logger.info(
157 | transition.getSource().getName() + "; " + transition.getTarget().getName());
158 |
159 | if (map.containsKey(transition.getSource().getName())) {
160 | edges = edges + map.get(transition.getSource().getName());
161 | }
162 | if (map.containsKey(transition.getTarget().getName())) {
163 | edges = edges + " " + map.get(transition.getTarget().getName());
164 | }
165 | edges = edges + "\n";
166 | }
167 | }
168 |
169 | return edges;
170 | }
171 |
172 | public List getTestPaths(final String edges, final String initialNodes,
173 | final String finalNodes) throws InvalidGraphException {
174 | Graph g = null;
175 | try {
176 | g = GraphUtil.readGraph(edges, initialNodes, finalNodes);
177 | } catch (InvalidInputException e) {
178 | logger.error(e);
179 | }
180 | try {
181 | if (g != null) {
182 | g.validate();
183 | }
184 | } catch (InvalidGraphException e) {
185 | logger.error(e);
186 | }
187 | List edgeTRs = null;
188 | if (g != null) {
189 | edgeTRs = g.findEdgeCoverage();
190 | }
191 |
192 | return edgeTRs;
193 |
194 | }
195 |
196 | /**
197 | * Creates the URI Converter we'll use to load our modules. Take note that this should never be
198 | * used out of Eclipse.
199 | *
200 | * @return The created URI Converter.
201 | * @since 3.0
202 | */
203 | protected URIConverter createURIConverter() {
204 | if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
205 | return null;
206 | }
207 |
208 | return new ExtensibleURIConverterImpl() {
209 | /**
210 | * {@inheritDoc}
211 | *
212 | * @see org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl#normalize(org.eclipse.emf.common.util.URI)
213 | */
214 | @Override
215 | public URI normalize(final URI uri) {
216 | URI normalized = getURIMap().get(uri);
217 | if (normalized == null) {
218 | BundleURLConverter conv = new BundleURLConverter(uri.toString());
219 | if (conv.resolveBundle() != null) {
220 | normalized = URI.createURI(conv.resolveAsPlatformPlugin());
221 | getURIMap().put(uri, normalized);
222 | }
223 | }
224 | if (normalized != null) {
225 | return normalized;
226 | }
227 | return super.normalize(uri);
228 | }
229 | };
230 | }
231 |
232 | /**
233 | * This will update the resource set's package registry with all usual EPackages.
234 | *
235 | * @param resourceSet
236 | * The resource set which registry has to be updated.
237 | */
238 | public void registerPackages(final ResourceSet resourceSet) {
239 | resourceSet.getPackageRegistry().put(EcorePackage.eINSTANCE.getNsURI(),
240 | EcorePackage.eINSTANCE);
241 |
242 | resourceSet.getPackageRegistry().put(
243 | org.eclipse.ocl.ecore.EcorePackage.eINSTANCE.getNsURI(),
244 | org.eclipse.ocl.ecore.EcorePackage.eINSTANCE);
245 | resourceSet.getPackageRegistry().put(ExpressionsPackage.eINSTANCE.getNsURI(),
246 | ExpressionsPackage.eINSTANCE);
247 |
248 | resourceSet.getPackageRegistry().put(MtlPackage.eINSTANCE.getNsURI(), MtlPackage.eINSTANCE);
249 |
250 | resourceSet.getPackageRegistry().put("http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore", //$NON-NLS-1$
251 | getOCLStdLibPackage());
252 |
253 | if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
254 | resourceSet.getPackageRegistry().put(
255 | org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(),
256 | org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
257 | }
258 | }
259 |
260 | /**
261 | * This will update the resource set's resource factory registry with all usual factories.
262 | *
263 | * @param resourceSet
264 | * The resource set which registry has to be updated.
265 | */
266 | public void registerResourceFactories(final ResourceSet resourceSet) {
267 | resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", //$NON-NLS-1$
268 | new EcoreResourceFactoryImpl());
269 | resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap()
270 | .put(IAcceleoConstants.BINARY_CONTENT_TYPE, new EMtlBinaryResourceFactoryImpl());
271 | resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap()
272 | .put(IAcceleoConstants.XMI_CONTENT_TYPE, new EMtlResourceFactoryImpl());
273 | }
274 |
275 | /**
276 | * Returns the package containing the OCL standard library.
277 | *
278 | * @return The package containing the OCL standard library.
279 | */
280 | protected EPackage getOCLStdLibPackage() {
281 | EcoreEnvironmentFactory factory = new EcoreEnvironmentFactory();
282 | EcoreEnvironment environment = (EcoreEnvironment) factory.createEnvironment();
283 | EPackage oclStdLibPackage = (EPackage) EcoreUtil
284 | .getRootContainer(environment.getOCLStandardLibrary().getBag());
285 | environment.dispose();
286 | return oclStdLibPackage;
287 | }
288 |
289 | /**
290 | * Clients can override this if the default behavior doesn't properly find the emtl module URL.
291 | *
292 | * @param moduleName
293 | * Name of the module we're searching for.
294 | * @return The template's URL. This will use Eclipse-specific behavior if possible, and use the
295 | * class loader otherwise.
296 | */
297 | protected URL findModuleURL(final String moduleName) {
298 | URL moduleURL = null;
299 | if (EMFPlugin.IS_ECLIPSE_RUNNING) {
300 | try {
301 | moduleURL = AcceleoWorkspaceUtil.getResourceURL(getClass(), moduleName);
302 | } catch (IOException e) {
303 | // Swallow this, we'll try and locate the module through the class loader
304 | logger.error(e);
305 | }
306 | }
307 | if (moduleURL == null) {
308 | moduleURL = getClass().getResource(moduleName);
309 | }
310 | return moduleURL;
311 | }
312 |
313 | /**
314 | * Creates the URI that will be used to resolve the template that is to be launched.
315 | *
316 | * @param entry
317 | * The path towards the template file. Could be a jar or file scheme URI, or we'll
318 | * assume it represents a relative path.
319 | * @return The actual URI from which the template file can be resolved.
320 | */
321 | protected URI createTemplateURI(final String entry) {
322 | if (entry.startsWith("file:") || entry.startsWith("jar:")) { //$NON-NLS-1$ //$NON-NLS-2$
323 | return URI.createURI(URI.decode(entry));
324 | }
325 | return URI.createFileURI(URI.decode(entry));
326 | }
327 |
328 | /**
329 | * Checks whether the given EPackage class is located in the workspace.
330 | *
331 | * @param ePackageClass
332 | * The EPackage class we need to take into account.
333 | * @return true if the given class has been loaded from a dynamically installed
334 | * bundle, false otherwise.
335 | * @since 3.1
336 | */
337 | public boolean isInWorkspace(final Class extends EPackage> ePackageClass) {
338 | return EMFPlugin.IS_ECLIPSE_RUNNING
339 | && AcceleoWorkspaceUtil.INSTANCE.isInDynamicBundle(ePackageClass);
340 | }
341 |
342 | }
343 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.mdsol
5 | skyfire
6 | 1.0.2
7 | com.mdsol.skyfire
8 | A application that generates Cucumber-compatible abstract tests from a UML behavioral model
9 | https://github.com/mdsol/skyfire/
10 |
11 |
12 | Medidata Solutions, Inc
13 | www.mdsol.com
14 |
15 |
16 |
17 |
18 | MIT License
19 | http://www.opensource.org/licenses/mit-license.php
20 |
21 |
22 |
23 |
24 |
25 | nli
26 | Nan Li
27 | nli@mdsol.com
28 | Medidata Solutions
29 | http://www.mdsol.com
30 |
31 | Architect
32 | Developer
33 | Test Automation Engineer
34 |
35 | -5
36 |
37 |
38 | aescalona
39 | Anthony Escalona
40 | aescalona@mdsol.com
41 | Medidata Solutions
42 | http://www.mdsol.com
43 |
44 | Test Automation Manager
45 |
46 | -5
47 |
48 |
49 |
50 |
51 | scm:git:git@github.com:mdsol/skyfire.git
52 | scm:git:git@github.com:mdsol/skyfire.git
53 | git@github.com:mdsol/skyfire.git
54 |
55 |
56 |
57 |
58 | Eclipse - Acceleo Snapshots
59 | https://repo.eclipse.org/content/repositories/acceleo-snapshots
60 |
61 |
62 | Eclipse - Acceleo Release
63 | https://repo.eclipse.org/content/repositories/acceleo-releases
64 |
65 |
66 |
67 |
68 |
69 | junit
70 | junit
71 | 4.11
72 | test
73 |
74 |
75 |
76 | org.apache.logging.log4j
77 | log4j-api
78 | 2.4.1
79 |
80 |
81 |
82 | org.apache.logging.log4j
83 | log4j-core
84 | 2.4.1
85 |
86 |
87 |
88 | org.mockito
89 | mockito-all
90 | 1.8.2
91 | jar
92 |
93 |
94 |
95 | net.sourceforge.htmlunit
96 | htmlunit
97 | 2.17
98 |
99 |
100 |
101 | org.easymock
102 | easymockclassextension
103 | 3.2
104 |
105 |
106 |
107 | org.eclipse.emf
108 | org.eclipse.emf.common
109 | 2.11.0-v20150123-0347
110 |
111 |
112 |
113 | org.eclipse.uml2
114 | org.eclipse.uml2.uml
115 | 4.1.2.v20140202-2055
116 |
117 |
118 |
119 | org.eclipse.uml2
120 | types
121 | 1.0.0.v20120913-1441
122 |
123 |
124 |
125 | org.eclipse.uml2
126 | common
127 | 1.7.0.v20120913-1441
128 |
129 |
130 |
131 | org.eclipse.emf
132 | org.eclipse.emf.ecore
133 | 2.11.0-v20150123-0347
134 |
135 |
136 |
137 | org.eclipse.emf
138 | org.eclipse.emf.ecore.xmi
139 | 2.11.0-v20150123-0347
140 |
141 |
142 | org.eclipse.core
143 | runtime
144 | 3.10.0-v20140318-2214
145 |
146 |
147 |
148 | org.eclipse.acceleo
149 | org.eclipse.acceleo.model
150 | 3.5.0-SNAPSHOT
151 |
152 |
153 |
154 | org.eclipse.acceleo
155 | org.eclipse.acceleo.common
156 | 3.5.0-SNAPSHOT
157 |
158 |
159 |
160 | org.eclipse.ocl
161 | org.eclipse.ocl.ecore
162 | 3.3.0.v20130520-1222
163 |
164 |
165 |
166 | org.eclipse.ocl
167 | org.eclipse.ocl
168 | 3.3.0.v20130909-1552
169 |
170 |
171 |
172 | org.eclipse.ocl
173 | org.eclipse.ocl.common
174 | 1.1.0.v20130531-0544
175 |
176 |
177 |
178 | edu.gmu.swe
179 | coverage
180 | 0.9
181 |
182 |
183 |
184 |
185 |
186 | ossrh
187 | https://oss.sonatype.org/content/repositories/snapshots
188 |
189 |
190 | ossrh
191 | https://oss.sonatype.org/service/local/staging/deploy/maven2/
192 |
193 |
194 |
195 |
196 | ${groupId}.${artifactId}.${version}
197 |
198 |
199 | org.apache.maven.plugins
200 | maven-gpg-plugin
201 | 1.5
202 |
203 |
204 | sign-artifacts
205 | verify
206 |
207 | sign
208 |
209 |
210 |
211 |
212 |
213 |
214 | org.sonatype.plugins
215 | nexus-staging-maven-plugin
216 | 1.6.3
217 | true
218 |
219 | ossrh
220 | https://oss.sonatype.org/
221 | true
222 |
223 |
224 |
225 |
226 | org.apache.maven.plugins
227 | maven-compiler-plugin
228 | 3.3
229 |
230 | 1.7
231 | 1.7
232 |
233 |
234 |
235 |
236 | org.apache.maven.plugins
237 | maven-source-plugin
238 | 2.4
239 |
240 |
241 | attach-sources
242 |
243 | jar
244 |
245 |
246 |
247 |
248 |
249 |
250 | org.apache.maven.plugins
251 | maven-javadoc-plugin
252 | 2.10.3
253 |
254 |
255 | attach-javadocs
256 |
257 | jar
258 |
259 |
260 |
261 |
262 |
263 |
264 | org.apache.maven.plugins
265 | maven-checkstyle-plugin
266 | 2.17
267 |
268 |
269 | validate
270 | validate
271 |
272 | mdsol-checkstyle.xml
273 | UTF-8
274 | true
275 | true
276 | false
277 |
278 |
279 | check
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 | org.apache.maven.plugins
288 | maven-surefire-plugin
289 | 2.18
290 |
291 |
292 | ${surefireArgLine}
293 |
294 |
295 | **/IT*.java
296 |
297 |
298 |
299 |
300 |
301 | org.codehaus.mojo
302 | build-helper-maven-plugin
303 | 1.9.1
304 |
305 |
306 |
307 |
308 | add-integration-test-sources
309 | generate-test-sources
310 |
311 | add-test-source
312 |
313 |
314 |
315 |
316 | src/integration-test/java
317 |
318 |
319 |
320 |
321 |
322 | add-integration-test-resources
323 | generate-test-resources
324 |
325 | add-test-resource
326 |
327 |
328 |
329 |
330 |
333 |
334 | true
335 | src/integration-test/resources
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 | org.apache.maven.plugins
346 | maven-failsafe-plugin
347 | 2.18
348 |
349 |
351 |
352 | integration-tests
353 |
354 | integration-test
355 | verify
356 |
357 |
358 |
359 | ${failsafeArgLine}
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 | org.jacoco
368 | jacoco-maven-plugin
369 | 0.7.5.201505241946
370 |
371 |
373 |
374 | pre-unit-test
375 |
376 | prepare-agent
377 |
378 |
379 |
380 | ${project.build.directory}/coverage-reports/jacoco-ut.exec
381 |
383 | surefireArgLine
384 |
385 |
386 |
388 |
389 | post-unit-test
390 | test
391 |
392 | report
393 |
394 |
395 |
396 | ${project.build.directory}/coverage-reports/jacoco-ut.exec
397 |
398 | ${project.reporting.outputDirectory}/jacoco-ut
399 |
400 |
401 |
402 |
403 |
405 |
406 | pre-integration-test
407 | pre-integration-test
408 |
409 | prepare-agent
410 |
411 |
412 |
413 | ${project.build.directory}/coverage-reports/jacoco-it.exec
414 |
416 | failsafeArgLine
417 |
418 |
419 |
421 |
422 | post-integration-test
423 | post-integration-test
424 |
425 | report
426 |
427 |
428 |
429 | ${project.build.directory}/coverage-reports/jacoco-it.exec
430 |
431 | ${project.reporting.outputDirectory}/jacoco-it
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 | org.apache.maven.plugins
443 | maven-checkstyle-plugin
444 | 2.17
445 |
446 | mdsol-checkstyle.xml
447 |
448 |
449 |
450 |
451 | checkstyle
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 | UTF-8
461 | UTF-8
462 |
463 |
464 |
--------------------------------------------------------------------------------