[1603] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
| 15 | package de.ugoe.cs.autoquest.plugin.uml;
|
---|
| 16 |
|
---|
| 17 | import java.io.File;
|
---|
| 18 | import java.util.Collection;
|
---|
| 19 | import java.util.Iterator;
|
---|
| 20 | import java.util.LinkedList;
|
---|
| 21 | import java.util.List;
|
---|
[1643] | 22 | import java.util.Random;
|
---|
[1898] | 23 | import java.util.logging.Level;
|
---|
[1603] | 24 |
|
---|
[1763] | 25 | import org.apache.commons.lang.SerializationUtils;
|
---|
[1643] | 26 | import org.eclipse.uml2.uml.Interaction;
|
---|
[1603] | 27 | import org.eclipse.uml2.uml.Model;
|
---|
| 28 | import org.eclipse.uml2.uml.StateMachine;
|
---|
| 29 | import org.eclipse.uml2.uml.Transition;
|
---|
| 30 | import org.eclipse.uml2.uml.UMLPackage;
|
---|
| 31 | import org.junit.After;
|
---|
[1898] | 32 | import org.junit.BeforeClass;
|
---|
[1603] | 33 | import org.junit.Test;
|
---|
| 34 |
|
---|
[1759] | 35 | import de.fraunhofer.fokus.testing.ModelUtils;
|
---|
[1603] | 36 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
| 37 | import de.ugoe.cs.autoquest.plugin.http.HTTPLogParser;
|
---|
[1643] | 38 | import de.ugoe.cs.autoquest.plugin.http.HTTPUtils;
|
---|
[1603] | 39 | import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType;
|
---|
| 40 | import de.ugoe.cs.autoquest.plugin.uml.eventcore.UMLTransitionType;
|
---|
[1643] | 41 | import de.ugoe.cs.autoquest.testgeneration.RandomWalkGenerator;
|
---|
| 42 | import de.ugoe.cs.autoquest.usageprofiles.FirstOrderMarkovModel;
|
---|
[1763] | 43 | import de.ugoe.cs.autoquest.usageprofiles.IStochasticProcess;
|
---|
[1898] | 44 | import de.ugoe.cs.util.console.TextConsole;
|
---|
[1603] | 45 |
|
---|
| 46 | /**
|
---|
| 47 | * <p>
|
---|
| 48 | * Tests for AutoQUESTs UMLUtils
|
---|
| 49 | * </p>
|
---|
| 50 | *
|
---|
| 51 | * @author Steffen Herbold
|
---|
| 52 | */
|
---|
| 53 | public class UMLUtilsTest {
|
---|
[1625] | 54 |
|
---|
[1606] | 55 | private final static String OUTPUT_DIR = "target/tmp/test-outputs/";
|
---|
[1625] | 56 |
|
---|
[1898] | 57 | @BeforeClass
|
---|
| 58 | public static void setUpBeforeClass() throws Exception {
|
---|
[1900] | 59 | new TextConsole(Level.INFO);
|
---|
[1898] | 60 | }
|
---|
| 61 |
|
---|
[1625] | 62 | @After
|
---|
| 63 | public void tearDown() throws Exception {
|
---|
| 64 | deleteFiles(new File(OUTPUT_DIR));
|
---|
| 65 | }
|
---|
[1603] | 66 |
|
---|
[1625] | 67 | @Test(expected = java.lang.RuntimeException.class)
|
---|
| 68 | public void testCreateUMLTransitionSequence_1() throws Exception {
|
---|
[1603] | 69 | // parse log file
|
---|
| 70 | HTTPLogParser parser = new HTTPLogParser();
|
---|
| 71 | parser.parseFile(new File(ClassLoader.getSystemResource("createSequence_1_usagedata.log")
|
---|
| 72 | .getFile()));
|
---|
| 73 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
| 74 | Model model =
|
---|
[1759] | 75 | ModelUtils.loadModel(ClassLoader
|
---|
[1603] | 76 | .getSystemResourceAsStream("createSequence_1_model.uml"));
|
---|
| 77 |
|
---|
| 78 | StateMachine stateMachine =
|
---|
| 79 | (StateMachine) model.getPackagedElement("PatientIDBehavior", true,
|
---|
| 80 | UMLPackage.Literals.STATE_MACHINE, true);
|
---|
| 81 |
|
---|
| 82 | Collection<List<Event>> umlSequences = new LinkedList<>();
|
---|
| 83 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 84 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 85 | Event event = eventIter.next();
|
---|
| 86 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 87 | eventIter.remove();
|
---|
| 88 | }
|
---|
| 89 | else {
|
---|
| 90 | if (!event.getType().toString().contains("ixsmq")) {
|
---|
| 91 | eventIter.remove();
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | umlSequences.add(UMLUtils.createUMLTransitionSequence(httpSequence, stateMachine));
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
[1625] | 99 |
|
---|
[1603] | 100 | @Test
|
---|
[1625] | 101 | public void testConvertStateMachineToUsageProfile_1() throws Exception {
|
---|
[1603] | 102 | // parse log file
|
---|
| 103 | HTTPLogParser parser = new HTTPLogParser();
|
---|
| 104 | parser.parseFile(new File(ClassLoader.getSystemResource("createSequence_1_usagedata.log")
|
---|
| 105 | .getFile()));
|
---|
| 106 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
| 107 | Model model =
|
---|
[1759] | 108 | ModelUtils.loadModel(ClassLoader
|
---|
[1603] | 109 | .getSystemResourceAsStream("createSequence_1_model.uml"));
|
---|
| 110 |
|
---|
| 111 | StateMachine stateMachine =
|
---|
| 112 | (StateMachine) model.getPackagedElement("PatientIDBehavior", true,
|
---|
| 113 | UMLPackage.Literals.STATE_MACHINE, true);
|
---|
| 114 |
|
---|
| 115 | Collection<List<Event>> umlSequences = new LinkedList<>();
|
---|
| 116 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 117 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 118 | Event event = eventIter.next();
|
---|
| 119 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 120 | eventIter.remove();
|
---|
| 121 | }
|
---|
| 122 | else {
|
---|
| 123 | if (!event.getType().toString().contains("ixsmq")) {
|
---|
| 124 | eventIter.remove();
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[1625] | 129 | List<List<Transition>> matchingSequences =
|
---|
| 130 | UMLUtils.determineMatchingTransitionSequences(httpSequence, stateMachine);
|
---|
[1603] | 131 | if (matchingSequences.size() >= 1) {
|
---|
| 132 | List<Event> umlEventSequence = new LinkedList<>();
|
---|
| 133 | for (Transition transition : matchingSequences.get(0)) {
|
---|
| 134 | umlEventSequence.add(new Event(new UMLTransitionType(transition)));
|
---|
| 135 | }
|
---|
| 136 | umlSequences.add(umlEventSequence);
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 | UMLUtils.convertStateMachineToUsageProfile(umlSequences, stateMachine);
|
---|
[1625] | 140 |
|
---|
[1759] | 141 | ModelUtils.writeModelToFile(model, OUTPUT_DIR + "convertStateMachineToUsageProfile_1.uml");
|
---|
[1603] | 142 | }
|
---|
[1625] | 143 |
|
---|
| 144 | @Test
|
---|
| 145 | public void testCreateInteractionFromEventSequence_1() throws Exception {
|
---|
| 146 | // parse log file
|
---|
| 147 | HTTPLogParser parser =
|
---|
| 148 | new HTTPLogParser(new File(ClassLoader
|
---|
[1643] | 149 | .getSystemResource("testCreateInteractionFromEventSequence_1_properties.txt")
|
---|
| 150 | .getFile()));
|
---|
| 151 | parser
|
---|
| 152 | .parseFile(new File(ClassLoader
|
---|
| 153 | .getSystemResource("testCreateInteractionFromEventSequence_1_usagedata.log")
|
---|
| 154 | .getFile()));
|
---|
[1625] | 155 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
[1759] | 156 |
|
---|
[1625] | 157 | Model model =
|
---|
[1759] | 158 | ModelUtils.loadModel(ClassLoader
|
---|
[1625] | 159 | .getSystemResourceAsStream("testCreateInteractionFromEventSequence_1_model.uml"));
|
---|
| 160 |
|
---|
| 161 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 162 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 163 | Event event = eventIter.next();
|
---|
| 164 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 165 | eventIter.remove();
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 |
|
---|
[1896] | 169 | UMLUtils.createInteractionFromEventSequence(httpSequence, model, "testSequence", null);
|
---|
[1625] | 170 | }
|
---|
[1752] | 171 |
|
---|
[1759] | 172 | ModelUtils.writeModelToFile(model, OUTPUT_DIR + "testCreateInteractionFromEventSequence_1_result.uml");
|
---|
[1625] | 173 | }
|
---|
[1835] | 174 |
|
---|
| 175 | @Test
|
---|
| 176 | public void testCreateInteractionFromEventSequence_2() throws Exception {
|
---|
| 177 | // parse log file
|
---|
| 178 | HTTPLogParser parser =
|
---|
| 179 | new HTTPLogParser(new File(ClassLoader
|
---|
| 180 | .getSystemResource("testCreateInteractionFromEventSequence_2_properties.txt")
|
---|
| 181 | .getFile()));
|
---|
| 182 | parser
|
---|
| 183 | .parseFile(new File(ClassLoader
|
---|
| 184 | .getSystemResource("testCreateInteractionFromEventSequence_2_usagedata.log")
|
---|
| 185 | .getFile()));
|
---|
| 186 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
[1625] | 187 |
|
---|
[1835] | 188 | Model model =
|
---|
| 189 | ModelUtils.loadModel(ClassLoader
|
---|
| 190 | .getSystemResourceAsStream("testCreateInteractionFromEventSequence_2_model.uml"));
|
---|
| 191 |
|
---|
| 192 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 193 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 194 | Event event = eventIter.next();
|
---|
| 195 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 196 | eventIter.remove();
|
---|
| 197 | }
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[1896] | 200 | UMLUtils.createInteractionFromEventSequence(httpSequence, model, "testSequence", null);
|
---|
[1835] | 201 | }
|
---|
| 202 |
|
---|
[1898] | 203 | ModelUtils.writeModelToFile(model, OUTPUT_DIR + "testCreateInteractionFromEventSequence_1_result.uml");
|
---|
[1835] | 204 | }
|
---|
[1896] | 205 |
|
---|
| 206 | @Test
|
---|
[1643] | 207 | public void testCalculateUsageScore_1() throws Exception {
|
---|
| 208 | // parse log file
|
---|
| 209 | HTTPLogParser parser =
|
---|
| 210 | new HTTPLogParser(new File(ClassLoader
|
---|
| 211 | .getSystemResource("testCalculateUsageScore_1_properties.txt").getFile()));
|
---|
| 212 | parser.parseFile(new File(ClassLoader
|
---|
| 213 | .getSystemResource("testCalculateUsageScore_1_usagedata.log").getFile()));
|
---|
| 214 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
[1759] | 215 |
|
---|
[1643] | 216 | Model model =
|
---|
[1759] | 217 | ModelUtils.loadModel(ClassLoader
|
---|
[1643] | 218 | .getSystemResourceAsStream("testCalculateUsageScore_1_model.uml"));
|
---|
| 219 |
|
---|
| 220 | Collection<List<Event>> simpleSOAPSequences = new LinkedList<>();
|
---|
| 221 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 222 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 223 | Event event = eventIter.next();
|
---|
| 224 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 225 | eventIter.remove();
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
| 228 | simpleSOAPSequences.add(HTTPUtils.convertToSimpleSOAPEvent(httpSequence));
|
---|
| 229 | // simpleSOAPSequences.add(httpSequence);
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | FirstOrderMarkovModel usageProfile = new FirstOrderMarkovModel(new Random(1));
|
---|
| 233 | usageProfile.train(simpleSOAPSequences);
|
---|
| 234 |
|
---|
| 235 | Collection<List<Event>> genSeqs =
|
---|
| 236 | (new RandomWalkGenerator(10, 1, 100, true, 500)).generateTestSuite(usageProfile);
|
---|
| 237 |
|
---|
| 238 | int i = 1;
|
---|
| 239 | int[] lengths = new int[genSeqs.size()];
|
---|
| 240 | for (List<Event> seq : genSeqs) {
|
---|
[1896] | 241 | UMLUtils.createInteractionFromEventSequence(seq, model, "seq_" + i, null);
|
---|
[1643] | 242 | lengths[i - 1] = seq.size();
|
---|
| 243 | i++;
|
---|
| 244 | }
|
---|
| 245 | for (int j = 0; j < genSeqs.size(); j++) {
|
---|
| 246 | Interaction interaction =
|
---|
| 247 | (Interaction) model.getPackagedElement("seq_" + j, true,
|
---|
| 248 | UMLPackage.Literals.INTERACTION, true);
|
---|
| 249 | double usageScore = UMLUtils.calculateUsageScore(interaction, usageProfile);
|
---|
[1752] | 250 | System.out.format("usage score %02d: %.2f \t %d\n", j + 1, usageScore, lengths[j]);
|
---|
[1643] | 251 | }
|
---|
| 252 | }
|
---|
[1763] | 253 |
|
---|
| 254 | @Test
|
---|
| 255 | public void testCreateScheduling_1() throws Exception {
|
---|
| 256 | Model model =
|
---|
| 257 | ModelUtils.loadModel(ClassLoader
|
---|
| 258 | .getSystemResourceAsStream("testCreateScheduling_1_testsuite.uml"));
|
---|
| 259 |
|
---|
| 260 | IStochasticProcess usageProfile = (IStochasticProcess) SerializationUtils.deserialize(ClassLoader.getSystemResourceAsStream("testCreateScheduling_1_usageprofile.dat"));
|
---|
| 261 |
|
---|
[1896] | 262 | UMLUtils.createScheduling(model, usageProfile, null);
|
---|
[1763] | 263 |
|
---|
| 264 | ModelUtils.writeModelToFile(model, OUTPUT_DIR + "testCreateScheduling_1_result.uml");
|
---|
| 265 | }
|
---|
[1898] | 266 |
|
---|
| 267 | @Test
|
---|
| 268 | public void testValidateModelWithLog_1() throws Exception {
|
---|
| 269 | HTTPLogParser parser =
|
---|
| 270 | new HTTPLogParser(new File(ClassLoader
|
---|
| 271 | .getSystemResource("testCreateInteractionFromEventSequence_1_properties.txt")
|
---|
| 272 | .getFile()));
|
---|
| 273 | parser
|
---|
| 274 | .parseFile(new File(ClassLoader
|
---|
| 275 | .getSystemResource("testCreateInteractionFromEventSequence_1_usagedata.log")
|
---|
| 276 | .getFile()));
|
---|
| 277 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
[1643] | 278 |
|
---|
[1898] | 279 |
|
---|
| 280 | Model model =
|
---|
| 281 | ModelUtils.loadModel(ClassLoader
|
---|
| 282 | .getSystemResourceAsStream("testCreateInteractionFromEventSequence_1_model.uml"));
|
---|
| 283 |
|
---|
[1900] | 284 | int violations = UMLUtils.validateModelWithLog(httpSequences, model, null);
|
---|
| 285 | if( violations==0 ) {
|
---|
| 286 | System.out.println("No problems found.");
|
---|
| 287 | } else {
|
---|
| 288 | System.out.println(violations + " violations found.");
|
---|
| 289 | }
|
---|
[1898] | 290 | }
|
---|
| 291 |
|
---|
| 292 | @Test
|
---|
| 293 | public void testValidateModelWithLog_2() throws Exception {
|
---|
| 294 | HTTPLogParser parser =
|
---|
| 295 | new HTTPLogParser(new File(ClassLoader
|
---|
| 296 | .getSystemResource("testCreateInteractionFromEventSequence_2_properties.txt")
|
---|
| 297 | .getFile()));
|
---|
| 298 | parser
|
---|
| 299 | .parseFile(new File(ClassLoader
|
---|
| 300 | .getSystemResource("testCreateInteractionFromEventSequence_2_usagedata.log")
|
---|
| 301 | .getFile()));
|
---|
| 302 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
| 303 |
|
---|
| 304 |
|
---|
| 305 | Model model =
|
---|
| 306 | ModelUtils.loadModel(ClassLoader
|
---|
| 307 | .getSystemResourceAsStream("testCreateInteractionFromEventSequence_2_model.uml"));
|
---|
| 308 |
|
---|
[1900] | 309 | int violations = UMLUtils.validateModelWithLog(httpSequences, model, null);
|
---|
| 310 | if( violations==0 ) {
|
---|
| 311 | System.out.println("No problems found.");
|
---|
| 312 | } else {
|
---|
| 313 | System.out.println(violations + " violations found.");
|
---|
| 314 | }
|
---|
[1898] | 315 | }
|
---|
| 316 |
|
---|
| 317 | @Test
|
---|
[1914] | 318 | public void testValidateModelWithLog_HL7_RLUS_v3() throws Exception {
|
---|
[1898] | 319 | HTTPLogParser parser =
|
---|
| 320 | new HTTPLogParser(new File(ClassLoader
|
---|
| 321 | .getSystemResource("hl7_servicenamemap.txt")
|
---|
| 322 | .getFile()));
|
---|
| 323 | parser
|
---|
| 324 | .parseFile(new File(ClassLoader
|
---|
| 325 | .getSystemResource("testCreateInteractionFromEventSequence_1_usagedata.log")
|
---|
| 326 | .getFile()));
|
---|
| 327 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
| 328 |
|
---|
| 329 |
|
---|
| 330 | Model model =
|
---|
| 331 | ModelUtils.loadModel(ClassLoader
|
---|
[1914] | 332 | .getSystemResourceAsStream("hl7model_v3.uml"));
|
---|
[1898] | 333 |
|
---|
[1914] | 334 | int violations = UMLUtils.validateModelWithLog(httpSequences, model, "RLUSTestSuite_1");
|
---|
| 335 | if( violations==0 ) {
|
---|
| 336 | System.out.println("No problems found.");
|
---|
| 337 | } else {
|
---|
| 338 | System.out.println(violations + " violations found.");
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 | // remove everything but rlusService from sequences
|
---|
| 342 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 343 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 344 | Event event = eventIter.next();
|
---|
| 345 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 346 | eventIter.remove();
|
---|
| 347 | } else {
|
---|
| 348 | SOAPEventType eventType = (SOAPEventType) event.getType();
|
---|
| 349 | if( !"rlusService".equals(eventType.getServiceName()) ) {
|
---|
| 350 | eventIter.remove();
|
---|
| 351 | }
|
---|
| 352 | }
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | UMLUtils.createInteractionFromEventSequence(httpSequence, model, "foo", "RLUSTestSuite_1");
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | ModelUtils.writeModelToFile(model, OUTPUT_DIR + "hl7_v3_result.uml");
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | @Test
|
---|
| 362 | public void testValidateModelWithLog_HL7_IXS_v3() throws Exception {
|
---|
| 363 | HTTPLogParser parser =
|
---|
| 364 | new HTTPLogParser(new File(ClassLoader
|
---|
| 365 | .getSystemResource("hl7_ixs_servicenamemap.txt")
|
---|
| 366 | .getFile()));
|
---|
| 367 | parser
|
---|
| 368 | .parseFile(new File(ClassLoader
|
---|
| 369 | .getSystemResource("testCreateInteractionFromEventSequence_1_usagedata.log")
|
---|
| 370 | .getFile()));
|
---|
| 371 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
| 372 |
|
---|
| 373 |
|
---|
| 374 | Model model =
|
---|
| 375 | ModelUtils.loadModel(ClassLoader
|
---|
| 376 | .getSystemResourceAsStream("hl7model_v3.uml"));
|
---|
| 377 |
|
---|
[1900] | 378 | int violations = UMLUtils.validateModelWithLog(httpSequences, model, "IXSTestSuite_1");
|
---|
| 379 | if( violations==0 ) {
|
---|
| 380 | System.out.println("No problems found.");
|
---|
| 381 | } else {
|
---|
| 382 | System.out.println(violations + " violations found.");
|
---|
| 383 | }
|
---|
[1914] | 384 |
|
---|
| 385 | // remove everything but rlusService from sequences
|
---|
| 386 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 387 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 388 | Event event = eventIter.next();
|
---|
| 389 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 390 | eventIter.remove();
|
---|
| 391 | } else {
|
---|
| 392 | SOAPEventType eventType = (SOAPEventType) event.getType();
|
---|
| 393 | if( !"ixsService".equals(eventType.getServiceName()) ) {
|
---|
| 394 | eventIter.remove();
|
---|
| 395 | }
|
---|
| 396 | }
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 | UMLUtils.createInteractionFromEventSequence(httpSequence, model, "foo", "IXSTestSuite_1");
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 | ModelUtils.writeModelToFile(model, OUTPUT_DIR + "hl7_v3_result.uml");
|
---|
[1898] | 403 | }
|
---|
[1908] | 404 |
|
---|
| 405 | @Test
|
---|
| 406 | public void testValidateModelWithLog_ITA_v2() throws Exception {
|
---|
| 407 | HTTPLogParser parser =
|
---|
| 408 | new HTTPLogParser(new File(ClassLoader
|
---|
| 409 | .getSystemResource("ita_v2_servicenamemap.txt")
|
---|
| 410 | .getFile()));
|
---|
| 411 | parser
|
---|
| 412 | .parseFile(new File(ClassLoader
|
---|
| 413 | .getSystemResource("ita_usagejournal_v2_2.log")
|
---|
| 414 | .getFile()));
|
---|
| 415 | Collection<List<Event>> httpSequences = parser.getSequences();
|
---|
[1898] | 416 |
|
---|
[1908] | 417 |
|
---|
| 418 | Model model =
|
---|
| 419 | ModelUtils.loadModel(ClassLoader
|
---|
| 420 | .getSystemResourceAsStream("ita_model_v2.uml"));
|
---|
| 421 |
|
---|
| 422 | int violations = UMLUtils.validateModelWithLog(httpSequences, model, null);
|
---|
| 423 | if( violations==0 ) {
|
---|
| 424 | System.out.println("No problems found.");
|
---|
| 425 | } else {
|
---|
| 426 | System.out.println(violations + " violations found.");
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | // remove everything but transport from sequences
|
---|
| 430 | for (List<Event> httpSequence : httpSequences) {
|
---|
| 431 | for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) {
|
---|
| 432 | Event event = eventIter.next();
|
---|
| 433 | if (!(event.getType() instanceof SOAPEventType)) {
|
---|
| 434 | eventIter.remove();
|
---|
| 435 | } else {
|
---|
| 436 | SOAPEventType eventType = (SOAPEventType) event.getType();
|
---|
| 437 | if( !"TransportService".equals(eventType.getServiceName()) ) {
|
---|
| 438 | eventIter.remove();
|
---|
| 439 | }
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 | UMLUtils.createInteractionFromEventSequence(httpSequence, model, "foo", "LogisticsTestSuite");
|
---|
| 444 | }
|
---|
| 445 |
|
---|
| 446 | ModelUtils.writeModelToFile(model, OUTPUT_DIR + "ita_v2_result.uml");
|
---|
| 447 |
|
---|
| 448 | }
|
---|
| 449 |
|
---|
[1625] | 450 | private void deleteFiles(File file) {
|
---|
| 451 | if (file.exists()) {
|
---|
| 452 | if (file.isDirectory()) {
|
---|
| 453 | for (File child : file.listFiles()) {
|
---|
| 454 | deleteFiles(child);
|
---|
| 455 | }
|
---|
| 456 | }
|
---|
[1603] | 457 |
|
---|
[1625] | 458 | try {
|
---|
| 459 | file.delete();
|
---|
| 460 | }
|
---|
| 461 | catch (Exception e) {
|
---|
| 462 | // ignore and delete as much as possible
|
---|
| 463 | }
|
---|
| 464 | }
|
---|
| 465 | }
|
---|
| 466 |
|
---|
[1603] | 467 | }
|
---|