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 org.eclipse.uml2.uml.Model;
|
---|
18 | import org.eclipse.uml2.uml.Package;
|
---|
19 | import org.eclipse.uml2.uml.Profile;
|
---|
20 | import org.eclipse.uml2.uml.Stereotype;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * <p>
|
---|
24 | * Helper functions for working with the UML Testing Profile (UTP).
|
---|
25 | * </p>
|
---|
26 | *
|
---|
27 | * @author Steffen Herbold
|
---|
28 | */
|
---|
29 | public class UTPUtils {
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * <p>
|
---|
33 | * Retrieves the UTP profile from a UML {@link Package}, if it is applied.
|
---|
34 | * </p>
|
---|
35 | *
|
---|
36 | * @param umlModel
|
---|
37 | * model where the profile is retrieved from or added to
|
---|
38 | * @return UTP profile
|
---|
39 | */
|
---|
40 | public static Profile getOrApplyUtpProfile(Model umlModel) {
|
---|
41 | // TODO apply UTP if it is missing
|
---|
42 | return umlModel.getAppliedProfile("utp");
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * <p>
|
---|
47 | * Retrieves the UTP TestCase stereotype. In case UTP is not yet applied to the model, it is
|
---|
48 | * applied automatically.
|
---|
49 | * </p>
|
---|
50 | *
|
---|
51 | * @param umlModel
|
---|
52 | * model for the which the UTP TestCase stereotype is retrieved
|
---|
53 | * @return UTP TestCase stereotype
|
---|
54 | */
|
---|
55 | public static Stereotype getTestCaseStereotype(Model umlModel) {
|
---|
56 | return (Stereotype) getOrApplyUtpProfile(umlModel).getOwnedMember("TestCase");
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * <p>
|
---|
61 | * Retrieves the UTP TestComponent stereotype. In case UTP is not yet applied to the model, it
|
---|
62 | * is applied automatically.
|
---|
63 | * </p>
|
---|
64 | *
|
---|
65 | * @param umlModel
|
---|
66 | * model for the which the UTP TestComponent stereotype is retrieved
|
---|
67 | * @return UTP TestComponent stereotype
|
---|
68 | */
|
---|
69 | public static Stereotype getTestComponentStereotype(Model umlModel) {
|
---|
70 | return (Stereotype) getOrApplyUtpProfile(umlModel).getOwnedMember("TestComponent");
|
---|
71 | }
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * <p>
|
---|
75 | * Retrieves the UTP TestContext stereotype. In case UTP is not yet applied to the model, it is
|
---|
76 | * applied automatically.
|
---|
77 | * </p>
|
---|
78 | *
|
---|
79 | * @param umlModel
|
---|
80 | * model for the which the UTP TestContext stereotype is retrieved
|
---|
81 | * @return UTP TestContext stereotype
|
---|
82 | */
|
---|
83 | public static Stereotype getTestContextStereotype(Model umlModel) {
|
---|
84 | return (Stereotype) getOrApplyUtpProfile(umlModel).getOwnedMember("TestContext");
|
---|
85 | }
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * <p>
|
---|
89 | * Retrieves the UTP SUT stereotype. In case UTP is not yet applied to the model, it is applied
|
---|
90 | * automatically.
|
---|
91 | * </p>
|
---|
92 | *
|
---|
93 | * @param umlModel
|
---|
94 | * model for the which the UTP SUT stereotype is retrieved
|
---|
95 | * @return UTP SUT stereotype
|
---|
96 | */
|
---|
97 | public static Stereotype getSUTStereotype(Model umlModel) {
|
---|
98 | return (Stereotype) getOrApplyUtpProfile(umlModel).getOwnedMember("SUT");
|
---|
99 | }
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * <p>
|
---|
103 | * Retrieves the UTP LiteralAny stereotype. In case UTP is not yet applied to the model, it is
|
---|
104 | * applied automatically.
|
---|
105 | * </p>
|
---|
106 | *
|
---|
107 | * @param umlModel
|
---|
108 | * model for the which the UTP LiteralAny stereotype is retrieved
|
---|
109 | * @return UTP LiteralAny stereotype
|
---|
110 | */
|
---|
111 | public static Stereotype getLiteralAnyStereotype(Model umlModel) {
|
---|
112 | return (Stereotype) getOrApplyUtpProfile(umlModel).getOwnedMember("LiteralAny");
|
---|
113 | }
|
---|
114 |
|
---|
115 | }
|
---|