-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for enumeration and enumeration literal creation
- Loading branch information
1 parent
3f7835d
commit 6f942a0
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...raw.remote.tests/src/org/eclipse/epsilon/emc/magicdraw/remote/EnumerationLiteralTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 University of York. | ||
* 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: | ||
* Alfa Yohannis - Add a test for enumeration and enumeration literal creation | ||
*******************************************************************************/ | ||
package org.eclipse.epsilon.emc.magicdraw.remote; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.io.File; | ||
|
||
import org.eclipse.epsilon.eol.EolModule; | ||
import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tests for Enumeration and EnumerationLiteral creation, with MagicDraw running on the | ||
* <code>resources/example-zoo.mdzip</code> project. | ||
*/ | ||
public class EnumerationLiteralTest { | ||
|
||
private MagicDrawModel m; | ||
|
||
|
||
@Test | ||
public void createEnumerationLiteral() throws Exception { | ||
String script = | ||
"var enum = new Enumeration;\n" | ||
+ "enum.name = \"MyEnum\";\n" | ||
+ "var literal = new EnumerationLiteral;\n" | ||
+ "literal.name = \"FIRST\";\n" | ||
+ "enum.ownedLiteral.add(literal);\n" | ||
+ "return literal.id;"; | ||
EolModule module = createEOLModule(); | ||
module.parse(script); | ||
String id = (String) module.execute(); | ||
Object result = m.getElementById(id); | ||
assertNotNull("EnumerationLiteral should have been created (not null)", result); | ||
} | ||
|
||
|
||
private EolModule createEOLModule() { | ||
EolModule module = new EolModule(); | ||
module.getContext().getModelRepository().addModel(m); | ||
return module; | ||
} | ||
|
||
|
||
@Before | ||
public void createZooModel() throws EolModelLoadingException { | ||
m = new MagicDrawModel(); | ||
m.setName("Model"); | ||
|
||
m.setProjectURL(new File("resources/example-zoo.mdzip").getAbsoluteFile().toURI().toString()); | ||
m.setReadOnLoad(true); | ||
m.setStoredOnDisposal(false); | ||
|
||
m.load(); | ||
} | ||
|
||
@After | ||
public void disposeModel() { | ||
if (m != null) { | ||
m.close(); | ||
} | ||
} | ||
} |