-
Notifications
You must be signed in to change notification settings - Fork 4
/
UMLCreateObject.xtend
60 lines (48 loc) · 1.85 KB
/
UMLCreateObject.xtend
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
/*******************************************************************************
* Copyright (c) 2016 I-BP.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Arthur Daussy - initial API and implementation
* Jacob Geisel - initial API and implementation
*******************************************************************************/
package fr.ibp.odv.boem.tests.uml
import fr.ibp.odv.boem.lib.BoemFactory
import org.eclipse.uml2.uml.Interface
import org.eclipse.uml2.uml.Model
import org.eclipse.uml2.uml.Operation
import org.eclipse.uml2.uml.UMLPackage
import org.eclipse.uml2.uml.VisibilityKind
import org.junit.Test
import static org.junit.Assert.*
class UMLCreateObject extends AbstractUMLTest {
//Initializing Factory for BOEM
extension BoemFactory factory = new BoemFactory(UMLPackage.eINSTANCE)
@Test
def void testSimpleCreation() {
val model = Model.build [ // Simple creation
it.name = "myUmlModel" // Simple set
visibility = VisibilityKind.PUBLIC_LITERAL // it keyword is not necessary
]
assertEquals("myUmlModel", model.name)
assertEquals(VisibilityKind.PUBLIC_LITERAL, model.visibility)
}
@Test
def void testNestedCreation() {
val model = Model.build [
name = "myUmlModel"
visibility = VisibilityKind.PUBLIC_LITERAL
packagedElements += Interface.build [ // Nested creation
name = "myInterface"
ownedOperations += Operation.build [
name = "myOperation"
]
]
]
assertEquals("myInterface", model.packagedElements.get(0).name)
assertEquals("myOperation", (model.packagedElements.get(0) as Interface).operations.get(0).name)
}
}