|
a/src/test/java/net/timbusproject/extractors/test/ArchiUtilsTest.java |
|
b/src/test/java/net/timbusproject/extractors/test/ArchiUtilsTest.java |
|
... |
|
... |
2 |
|
2 |
|
3 |
import static org.junit.Assert.assertEquals;
|
3 |
import static org.junit.Assert.assertEquals;
|
4 |
import static org.junit.Assert.assertNotNull;
|
4 |
import static org.junit.Assert.assertNotNull;
|
5 |
import static org.junit.Assert.assertTrue;
|
5 |
import static org.junit.Assert.assertTrue;
|
6 |
|
6 |
|
7 |
import java.io.File;
|
|
|
8 |
import java.io.IOException;
|
|
|
9 |
import java.nio.file.Paths;
|
7 |
import java.nio.file.Paths;
|
10 |
import java.util.ArrayList;
|
8 |
import java.util.ArrayList;
|
11 |
import java.util.List;
|
9 |
import java.util.List;
|
12 |
|
10 |
|
13 |
import net.sf.taverna.t2.commandline.exceptions.DatabaseConfigurationException;
|
|
|
14 |
import net.sf.taverna.t2.commandline.exceptions.InvalidOptionException;
|
|
|
15 |
import net.sf.taverna.t2.commandline.exceptions.OpenDataflowException;
|
|
|
16 |
import net.sf.taverna.t2.commandline.exceptions.ReadInputException;
|
|
|
17 |
import net.sf.taverna.t2.invocation.TokenOrderException;
|
|
|
18 |
import net.sf.taverna.t2.security.credentialmanager.CMException;
|
|
|
19 |
import net.sf.taverna.t2.workflowmodel.EditException;
|
|
|
20 |
import net.sf.taverna.t2.workflowmodel.InvalidDataflowException;
|
|
|
21 |
import net.sf.taverna.t2.workflowmodel.processor.iteration.IterationTypeMismatchException;
|
|
|
22 |
import net.sf.taverna.t2.workflowmodel.serialization.DeserializationException;
|
|
|
23 |
import net.timbusproject.extractors.modules.tavernaextractor.TavernaExtractor;
|
11 |
import net.timbusproject.extractors.modules.tavernaextractor.TavernaExtractor;
|
24 |
import net.timbusproject.extractors.modules.tavernaextractor.utils.ArchiUtils;
|
12 |
import net.timbusproject.extractors.modules.tavernaextractor.utils.ArchiUtils;
|
25 |
|
13 |
|
|
|
14 |
import org.junit.BeforeClass;
|
26 |
import org.junit.Ignore;
|
15 |
import org.junit.Ignore;
|
27 |
import org.junit.Test;
|
16 |
import org.junit.Test;
|
28 |
|
17 |
|
29 |
import uk.ac.bolton.archimate.model.IAccessRelationship;
|
18 |
import uk.ac.bolton.archimate.model.IAccessRelationship;
|
30 |
import uk.ac.bolton.archimate.model.IArchimateElement;
|
19 |
import uk.ac.bolton.archimate.model.IArchimateElement;
|
31 |
import uk.ac.bolton.archimate.model.IBusinessObject;
|
20 |
import uk.ac.bolton.archimate.model.IBusinessObject;
|
32 |
import uk.ac.bolton.archimate.model.IBusinessProcess;
|
21 |
import uk.ac.bolton.archimate.model.IBusinessProcess;
|
33 |
import uk.ac.bolton.archimate.model.IRelationship;
|
22 |
import uk.ac.bolton.archimate.model.IRelationship;
|
34 |
import uk.ac.bolton.archimate.model.ITriggeringRelationship;
|
23 |
import uk.ac.bolton.archimate.model.ITriggeringRelationship;
|
35 |
|
24 |
|
36 |
import com.google.common.base.Joiner;
|
|
|
37 |
|
|
|
38 |
public class ArchiUtilsTest {
|
25 |
public class ArchiUtilsTest {
|
39 |
|
26 |
|
40 |
/*
|
27 |
/*
|
41 |
* Following constants are related to the matchbox.archi file found in the resource folder
|
28 |
* Following constants are related to the matchbox.archi file found in the resource folder
|
42 |
*/
|
29 |
*/
|
43 |
final int RELATIONS_COUNT = 168;
|
30 |
final int RELATIONS_COUNT = 168;
|
44 |
final int TRIGGERING_RELATIONS_COUNT = 11;
|
31 |
final int TRIGGERING_RELATIONS_COUNT = 11;
|
45 |
final String ELEMENT_NAME = "stdout";
|
|
|
46 |
|
32 |
|
47 |
private static List<IRelationship> ALL_RELATIONS;
|
33 |
private static List<IRelationship> ALL_RELATIONS;
|
48 |
private static List<IArchimateElement> ALL_PROCESSES;
|
34 |
private static List<IArchimateElement> ALL_PROCESSES;
|
49 |
private static List<IArchimateElement> ALL_BUSINESSOBJECTS;
|
35 |
private static List<IArchimateElement> ALL_BUSINESSOBJECTS;
|
50 |
private static TavernaExtractor matchboxExtractor;
|
36 |
private static TavernaExtractor matchboxExtractor;
|
51 |
private static TavernaExtractor wsdlActivityExtractor;
|
37 |
private static TavernaExtractor wsdlActivityExtractor;
|
52 |
private static TavernaExtractor beanshellActivityExtractor;
|
38 |
private static TavernaExtractor beanshellActivityExtractor;
|
53 |
private static TavernaExtractor loopingExtractor;
|
39 |
private static TavernaExtractor loopingExtractor;
|
54 |
|
40 |
|
55 |
// @BeforeClass
|
41 |
@BeforeClass
|
56 |
public static void customInit() throws Exception {
|
42 |
public static void customInit() throws Exception {
|
57 |
|
43 |
|
|
|
44 |
|
58 |
matchboxExtractor = new TavernaExtractor(true);
|
45 |
matchboxExtractor = new TavernaExtractor(true);
|
59 |
|
|
|
60 |
// TavernaExtractor.setArchimateOutputPath(Joiner.on(File.separator).skipNulls()
|
|
|
61 |
// .join("test", "resources", "matchbox.archi"));
|
|
|
62 |
// TavernaExtractor.setInputFileName(Joiner.on(File.separator).skipNulls()
|
|
|
63 |
// .join("test", "resources", "matchbox.t2flow"));
|
|
|
64 |
|
|
|
65 |
TavernaExtractor.setArchimateOutputPath(Paths.get("test", "resources", "matchbox.archi"));
|
46 |
matchboxExtractor.setArchimateOutputPath(Paths.get("test", "resources", "matchbox.archi"));
|
66 |
TavernaExtractor.setInputFileName(Paths.get("test", "resources", "matchbox.t2flow"));
|
47 |
matchboxExtractor.setInputFileName(Paths.get("test", "resources", "matchbox.t2flow"));
|
67 |
|
48 |
|
68 |
matchboxExtractor.process(false);
|
49 |
matchboxExtractor.process(false);
|
69 |
ALL_RELATIONS = matchboxExtractor.getRelations();
|
50 |
ALL_RELATIONS = matchboxExtractor.getRelations();
|
70 |
ALL_PROCESSES = matchboxExtractor.getBusinessProcesses();
|
51 |
ALL_PROCESSES = matchboxExtractor.getBusinessProcesses();
|
71 |
ALL_BUSINESSOBJECTS = matchboxExtractor.getBusinessObjects();
|
52 |
ALL_BUSINESSOBJECTS = matchboxExtractor.getBusinessObjects();
|
72 |
}
|
53 |
}
|
73 |
|
54 |
|
74 |
@Test
|
55 |
@Test
|
|
|
56 |
@Ignore
|
75 |
public void test_Looping() throws Exception {
|
57 |
public void test_Looping() throws Exception {
|
76 |
|
58 |
|
77 |
loopingExtractor = new TavernaExtractor(true);
|
59 |
loopingExtractor = new TavernaExtractor(true);
|
78 |
// TavernaExtractor.setArchimateOutputPath(Joiner.on(File.separator).skipNulls()
|
|
|
79 |
// .join("test", "resources", "looping.archimate"));
|
|
|
80 |
// TavernaExtractor.setInputFileName(Joiner.on(File.separator).skipNulls()
|
|
|
81 |
// .join("test", "resources", "looping.t2flow"));
|
|
|
82 |
|
|
|
83 |
TavernaExtractor.setArchimateOutputPath(Paths.get("test", "resources", "looping.archimate"));
|
60 |
loopingExtractor.setArchimateOutputPath(Paths.get("test", "resources", "looping.archimate"));
|
84 |
TavernaExtractor.setInputFileName(Paths.get("test", "resources", "looping.t2flow"));
|
61 |
loopingExtractor.setInputFileName(Paths.get("test", "resources", "looping.t2flow"));
|
85 |
|
|
|
86 |
loopingExtractor.process(false);
|
62 |
loopingExtractor.process(false);
|
87 |
}
|
63 |
}
|
88 |
|
64 |
|
89 |
@Test
|
65 |
@Test
|
|
|
66 |
@Ignore
|
90 |
public void test_processWSDLActivity() throws Exception {
|
67 |
public void test_processWSDLActivity() throws Exception {
|
91 |
|
68 |
|
92 |
wsdlActivityExtractor = new TavernaExtractor(true);
|
69 |
wsdlActivityExtractor = new TavernaExtractor(true);
|
93 |
// TavernaExtractor.setArchimateOutputPath(Joiner.on(File.separator).skipNulls()
|
|
|
94 |
// .join("test", "resources", "WSDLActivity.archimate"));
|
|
|
95 |
// TavernaExtractor.setInputFileName(Joiner.on(File.separator).skipNulls()
|
|
|
96 |
// .join("test", "resources", "WSDLActivity.t2flow"));
|
|
|
97 |
|
|
|
98 |
TavernaExtractor.setArchimateOutputPath(Paths.get("test", "resources", "WSDLActivity.archimate"));
|
70 |
wsdlActivityExtractor.setArchimateOutputPath(Paths.get("test", "resources", "WSDLActivity.archimate"));
|
99 |
TavernaExtractor.setInputFileName(Paths.get("test", "resources", "WSDLActivity.t2flow"));
|
71 |
wsdlActivityExtractor.setInputFileName(Paths.get("test", "resources", "WSDLActivity.t2flow"));
|
100 |
|
|
|
101 |
wsdlActivityExtractor.process(false);
|
72 |
wsdlActivityExtractor.process(false);
|
102 |
}
|
73 |
}
|
103 |
|
74 |
|
104 |
@Test
|
75 |
@Test
|
|
|
76 |
@Ignore
|
105 |
public void test_processLocalToolActivity() throws Exception {
|
77 |
public void test_processLocalToolActivity() throws Exception {
|
106 |
|
78 |
|
107 |
wsdlActivityExtractor = new TavernaExtractor(true);
|
79 |
wsdlActivityExtractor = new TavernaExtractor(true);
|
108 |
// TavernaExtractor.setArchimateOutputPath(Joiner.on(File.separator).skipNulls()
|
|
|
109 |
// .join("test", "resources", "localTool.archimate"));
|
|
|
110 |
// TavernaExtractor.setInputFileName(Joiner.on(File.separator).skipNulls()
|
|
|
111 |
// .join("test", "resources", "localTool.t2flow"));
|
|
|
112 |
|
|
|
113 |
TavernaExtractor.setArchimateOutputPath(Paths.get("test", "resources", "localTool.archimate"));
|
80 |
wsdlActivityExtractor.setArchimateOutputPath(Paths.get("test", "resources", "localTool.archimate"));
|
114 |
TavernaExtractor.setInputFileName(Paths.get("test", "resources", "localTool.t2flow"));
|
81 |
wsdlActivityExtractor.setInputFileName(Paths.get("test", "resources", "localTool.t2flow"));
|
115 |
|
|
|
116 |
wsdlActivityExtractor.process(false);
|
82 |
wsdlActivityExtractor.process(false);
|
117 |
}
|
83 |
}
|
118 |
|
84 |
|
119 |
@Test
|
85 |
@Test
|
|
|
86 |
@Ignore
|
120 |
public void test_processSSHToolActivity() throws Exception {
|
87 |
public void test_processSSHToolActivity() throws Exception {
|
121 |
|
88 |
|
122 |
wsdlActivityExtractor = new TavernaExtractor(true);
|
89 |
wsdlActivityExtractor = new TavernaExtractor(true);
|
123 |
// TavernaExtractor.setArchimateOutputPath(Joiner.on(File.separator).skipNulls()
|
|
|
124 |
// .join("test", "resources", "sshTool.archimate"));
|
|
|
125 |
// TavernaExtractor.setInputFileName(Joiner.on(File.separator).skipNulls()
|
|
|
126 |
// .join("test", "resources", "sshTool.t2flow"));
|
|
|
127 |
|
|
|
128 |
TavernaExtractor.setArchimateOutputPath(Paths.get("test", "resources", "sshTool.archimate"));
|
90 |
wsdlActivityExtractor.setArchimateOutputPath(Paths.get("test", "resources", "sshTool.archimate"));
|
129 |
TavernaExtractor.setInputFileName(Paths.get("test", "resources", "sshTool.t2flow"));
|
91 |
wsdlActivityExtractor.setInputFileName(Paths.get("test", "resources", "sshTool.t2flow"));
|
130 |
|
|
|
131 |
wsdlActivityExtractor.process(false);
|
92 |
wsdlActivityExtractor.process(false);
|
132 |
}
|
93 |
}
|
133 |
|
94 |
|
134 |
@Test
|
95 |
@Test
|
135 |
@Ignore
|
96 |
@Ignore
|
136 |
public void test_processBeanshellActivity() throws Exception {
|
97 |
public void test_processBeanshellActivity() throws Exception {
|
137 |
|
98 |
|
138 |
beanshellActivityExtractor = new TavernaExtractor(true);
|
99 |
beanshellActivityExtractor = new TavernaExtractor(true);
|
139 |
// TavernaExtractor.setArchimateOutputPath(Joiner.on(File.separator).skipNulls()
|
|
|
140 |
// .join("test", "resources", "beanshellLActivity.archimate"));
|
|
|
141 |
// TavernaExtractor.setInputFileName(Joiner.on(File.separator).skipNulls()
|
|
|
142 |
// .join("test", "resources", "beanshellLActivity.t2flow"));
|
|
|
143 |
|
|
|
144 |
TavernaExtractor.setArchimateOutputPath(Paths.get("test", "resources", "beanshellLActivity.archimate"));
|
100 |
beanshellActivityExtractor.setArchimateOutputPath(Paths.get("test", "resources", "beanshellLActivity.archimate"));
|
145 |
TavernaExtractor.setInputFileName(Paths.get("test", "resources", "beanshellLActivity.t2flow"));
|
101 |
beanshellActivityExtractor.setInputFileName(Paths.get("test", "resources", "beanshellLActivity.t2flow"));
|
146 |
|
|
|
147 |
beanshellActivityExtractor.process(false);
|
102 |
beanshellActivityExtractor.process(false);
|
148 |
}
|
103 |
}
|
149 |
|
104 |
|
150 |
@Test
|
105 |
@Test
|
151 |
@Ignore("Grouping already implemented!")
|
106 |
@Ignore("Grouping already implemented!")
|
|
... |
|
... |
215 |
int numberOfElements = elements.size();
|
170 |
int numberOfElements = elements.size();
|
216 |
assertEquals(6, numberOfElements);
|
171 |
assertEquals(6, numberOfElements);
|
217 |
|
172 |
|
218 |
// dirty - check if each item is of type IBusinessObject and if
|
173 |
// dirty - check if each item is of type IBusinessObject and if
|
219 |
// the list contains the correct elements via their names
|
174 |
// the list contains the correct elements via their names
|
220 |
List<String> list = new ArrayList<String>();
|
175 |
List<String> list = new ArrayList<>();
|
221 |
for (IArchimateElement element : elements) {
|
176 |
for (IArchimateElement element : elements) {
|
222 |
assertTrue(element instanceof IBusinessObject);
|
177 |
assertTrue(element instanceof IBusinessObject);
|
223 |
list.add(element.getName());
|
178 |
list.add(element.getName());
|
224 |
}
|
179 |
}
|
225 |
ArrayList<String> expected_list = new ArrayList<String>() {
|
180 |
ArrayList<String> expected_list = new ArrayList<String>() {
|
|
... |
|
... |
244 |
IBusinessProcess target = (IBusinessProcess) ArchiUtils.getElementsByname("report", ALL_PROCESSES).get(0);
|
199 |
IBusinessProcess target = (IBusinessProcess) ArchiUtils.getElementsByname("report", ALL_PROCESSES).get(0);
|
245 |
|
200 |
|
246 |
List<IArchimateElement> completeList = ArchiUtils.getElementsInBetween(source, target, ALL_RELATIONS);
|
201 |
List<IArchimateElement> completeList = ArchiUtils.getElementsInBetween(source, target, ALL_RELATIONS);
|
247 |
|
202 |
|
248 |
// testlist - get each element by name
|
203 |
// testlist - get each element by name
|
249 |
List<IArchimateElement> testList = new ArrayList<IArchimateElement>();
|
204 |
List<IArchimateElement> testList = new ArrayList<>();
|
250 |
testList.add(ArchiUtils.getElementsByname("cid", ALL_BUSINESSOBJECTS).get(0));
|
205 |
testList.add(ArchiUtils.getElementsByname("cid", ALL_BUSINESSOBJECTS).get(0));
|
251 |
testList.add(ArchiUtils.getElementsByname("fm", ALL_BUSINESSOBJECTS).get(0));
|
206 |
testList.add(ArchiUtils.getElementsByname("fm", ALL_BUSINESSOBJECTS).get(0));
|
252 |
testList.add(ArchiUtils.getElementsByname("iid", ALL_BUSINESSOBJECTS).get(0));
|
207 |
testList.add(ArchiUtils.getElementsByname("iid", ALL_BUSINESSOBJECTS).get(0));
|
253 |
testList.add(ArchiUtils.getElementsByname("md", ALL_BUSINESSOBJECTS).get(0));
|
208 |
testList.add(ArchiUtils.getElementsByname("md", ALL_BUSINESSOBJECTS).get(0));
|
254 |
testList.add(ArchiUtils.getElementsByname("prec", ALL_BUSINESSOBJECTS).get(0));
|
209 |
testList.add(ArchiUtils.getElementsByname("prec", ALL_BUSINESSOBJECTS).get(0));
|