diff --git a/org.modeldriven.alf.tests/pom.xml b/org.modeldriven.alf.tests/pom.xml index ae9b55001..8ccc977f0 100644 --- a/org.modeldriven.alf.tests/pom.xml +++ b/org.modeldriven.alf.tests/pom.xml @@ -35,7 +35,13 @@ org.modeldriven.alf 1.0.0-SNAPSHOT test - + + + org.apache.commons + commons-lang3 + 3.10 + test + src-tests diff --git a/org.modeldriven.alf.tests/src-tests/org/modeldriven/alf/ElementFactoryTest.java b/org.modeldriven.alf.tests/src-tests/org/modeldriven/alf/ElementFactoryTest.java new file mode 100644 index 000000000..24ef8f555 --- /dev/null +++ b/org.modeldriven.alf.tests/src-tests/org/modeldriven/alf/ElementFactoryTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright 2019-2020 Model Driven Solutions, Inc. + * All rights reserved worldwide. This program and the accompanying materials + * are made available for use under the terms of the GNU General Public License + * (GPL) version 3 that accompanies this distribution and is available at + * http://www.gnu.org/licenses/gpl-3.0.html. For alternative licensing terms, + * contact Model Driven Solutions. + *******************************************************************************/ +package org.modeldriven.alf; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.Arrays; +import java.util.List; + +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import org.modeldriven.alf.uml.ElementFactory; + +import org.apache.commons.lang3.tuple.Pair; + +public class ElementFactoryTest { + @Test + void simple() { + + List> classNames = Arrays.asList( + Pair.of("Package", "Package"), + Pair.of("Class", "Class_"), + Pair.of("Classifier", "Classifier"), + Pair.of("Activity", "Activity") + ); + classNames.stream().forEach(expectation -> { + Class javaInterface = ElementFactory.interfaceForName(expectation.getLeft()); + assertNotNull(javaInterface); + assertEquals(expectation.getRight(), javaInterface.getSimpleName()); + assertTrue(javaInterface.isInterface()); + }); + + assertNull(ElementFactory.interfaceForName("Foo")); + } +} \ No newline at end of file