diff options
Diffstat (limited to 'deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco')
32 files changed, 2024 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ANDTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ANDTests.java new file mode 100644 index 00000000000..dbca9a6dbd6 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ANDTests.java @@ -0,0 +1,86 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.papyrus.core.queries.test.Activator;
+import org.eclipse.papyrus.infra.queries.core.configuration.ModiscoQueryConfiguration;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test class for {@link AND} query
+ */
+public class ANDTests extends AbstractQueryUtilTest implements IQueryNames {
+
+ /** query on which tests are based */
+ protected static ModelQuery andQuery;
+
+ /** model query configuration model */
+ protected static ModiscoQueryConfiguration configuration;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // retrieve the query
+ andQuery = QueryUtil.retrieveModelQuery(AND_Boolean_1_Boolean_1, IQueryNames.CoreQueriesSet_Name);
+ assertNotNull("Query " + AND_Boolean_1_Boolean_1 + " was not found.", andQuery);
+
+ // retrieve the configuration
+ configuration = TestUtil.loadQueryConfiguration(Activator.PLUGIN_ID, IQueryNames.ANDConfiguration_Path);
+ assertNotNull("Configuration " + IQueryNames.ANDConfiguration_Path + " was not found.", configuration);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.QueryConfiguration)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryEObjectQueryConfiguration() {
+ // test if no exception is thrown
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(umlPackage, configuration);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertFalse("Query result should be false", result);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/AbstractQueryUtilTest.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/AbstractQueryUtilTest.java new file mode 100644 index 00000000000..2e9c13be42e --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/AbstractQueryUtilTest.java @@ -0,0 +1,87 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.core.queries.test.Activator;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+
+/**
+ * Abstract class for all tests
+ */
+public abstract class AbstractQueryUtilTest implements IQueryNames {
+
+ /** path to the uml model to load */
+ public static final String BASIC_UML_MODEL = "/resources/basic.uml";
+
+ /** path to the ecore model to load */
+ public static final String BASIC_ECORE_MODEL = "/resources/basic.ecore";
+
+ /** main uml model */
+ protected static EObject umlPackage;
+
+ /** sub class: basicClass */
+ protected static Class umlClass;
+
+
+ /** main ecore package */
+ protected static EObject ecorePackage;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeAbstractClass() throws Exception {
+ umlPackage = TestUtil.loadModel(Activator.PLUGIN_ID, BASIC_UML_MODEL);
+ assertNotNull("test model was not found.", umlPackage);
+
+ // retrieve the UML class
+ if(umlPackage instanceof Package) {
+ umlClass = (Class)((Package)umlPackage).getOwnedMember(UML_CLASS_NAME);
+ }
+ assertNotNull("test class was not found.", umlClass);
+
+ ecorePackage = TestUtil.loadModel(Activator.PLUGIN_ID, BASIC_ECORE_MODEL);
+ assertNotNull("test model was not found.", ecorePackage);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterAbstractClass() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/BooleanMultipleTest_NoParametersTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/BooleanMultipleTest_NoParametersTests.java new file mode 100644 index 00000000000..4268608f477 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/BooleanMultipleTest_NoParametersTests.java @@ -0,0 +1,107 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.runtime.ModelQueryParameterValue;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests cases for {@link BooleanTest_NoParameters}
+ */
+public class BooleanMultipleTest_NoParametersTests extends AbstractQueryUtilTest {
+
+ /** query on which tests are based */
+ protected static ModelQuery booleanMultipleQuery;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ booleanMultipleQuery = QueryUtil.retrieveModelQuery(Messages.QueryUtilTest_TestName_BooleanMultipleTest_NoParameters, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_BooleanMultipleTest_NoParameters + " was not found.", booleanMultipleQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#retrieveModelQuery(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public final void testRetrieveModelQuery_BooleanTest_NoParameters() {
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_BooleanMultipleTest_NoParameters + " was not found.", booleanMultipleQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidQuery(org.eclipse.emf.facet.infra.query.ModelQuery)}.
+ */
+ @Test
+ public final void testIsValidQuery_BooleanTest_NoParameters() {
+ IStatus status = QueryUtil.isValidBooleanQuery(booleanMultipleQuery);
+ assertFalse("Query " + Messages.QueryUtilTest_TestName_BooleanMultipleTest_NoParameters + " should not be a valid query, as it returns many booleans. Current Status: " + status.getMessage(), status.isOK());
+
+ status = QueryUtil.isValidQuery(booleanMultipleQuery);
+ assertTrue("Query should be a valid query. Current Status: " + status.getMessage(), status.isOK());
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, java.util.List)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryBooleanTest_NoParameters() {
+ boolean exceptionThrown = false;
+ boolean result = false;
+
+ // test with not an element context
+ try {
+ result = QueryUtil.evaluateBooleanQuery(booleanMultipleQuery, ecorePackage, new ArrayList<ModelQueryParameterValue>());
+ assertFalse("The query should not be valid, as the query is not valid", result);
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertTrue("An Exception should be thrown", exceptionThrown);
+
+ // test with not an element context
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(booleanMultipleQuery, ecorePackage, new ArrayList<ModelQueryParameterValue>());
+ assertFalse("The query should not be valid, as the query is not valid", result);
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertTrue("An exception should be thrown", exceptionThrown);
+
+ // test with not an element context
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(booleanMultipleQuery, ecorePackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("The query should not be valid, as the query is not valid", result);
+ // assertTrue("An exception should be thrown", exceptionThrown);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/BooleanTest_NoParametersTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/BooleanTest_NoParametersTests.java new file mode 100644 index 00000000000..bc25ff4ad97 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/BooleanTest_NoParametersTests.java @@ -0,0 +1,106 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.runtime.ModelQueryParameterValue;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests cases for {@link BooleanTest_NoParameters}
+ */
+public class BooleanTest_NoParametersTests extends AbstractQueryUtilTest {
+
+ /** query on which tests are based */
+ protected static ModelQuery booleanQuery;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ booleanQuery = QueryUtil.retrieveModelQuery(Messages.QueryUtilTest_TestName_BooleanTest_NoParameters, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_BooleanTest_NoParameters + " was not found.", booleanQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#retrieveModelQuery(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public final void testRetrieveModelQuery_BooleanTest_NoParameters() {
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_BooleanTest_NoParameters + " was not found.", booleanQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidQuery(org.eclipse.emf.facet.infra.query.ModelQuery)}.
+ */
+ @Test
+ public final void testIsValidQuery_BooleanTest_NoParameters() {
+ IStatus status = QueryUtil.isValidQuery(booleanQuery);
+ assertTrue("Query " + Messages.QueryUtilTest_TestName_BooleanTest_NoParameters + " should be a valid query. Current Status: " + status.getMessage(), status.isOK());
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, java.util.List)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryBooleanTest_NoParameters() {
+ boolean exceptionThrown;
+ boolean result;
+
+ // test with null as parameter
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(booleanQuery, umlPackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertTrue(result);
+ assertFalse("No Exception should be thrown", exceptionThrown);
+
+ // test with an empty array list
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(booleanQuery, umlPackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertTrue(result);
+ assertFalse("No Exception should be thrown", exceptionThrown);
+
+ // test with not an element context
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(booleanQuery, ecorePackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("The query should not be valid, as the element is not a UML Element", result);
+ // assertTrue("An exception should be thrown", exceptionThrown);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IQueryNames.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IQueryNames.java new file mode 100644 index 00000000000..2ece8ece34b --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IQueryNames.java @@ -0,0 +1,96 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+
+/**
+ * Interface that contains all query names available in the test query set
+ */
+public interface IQueryNames {
+
+ /** query set: configurationTestQuerySet */
+ public static final String CoreQueriesConfigurationSet_Name = "CoreQueriesConfigurationSet";
+
+ /** query set for queries */
+ public static final String CoreQueriesSet_Name = "CoreQueriesTest";
+
+ /** configuration name for IsNamed query test */
+ public static final String IsNamedQueryConfiguration_Path = "/resources/IsNamedQueryConfiguration.configuration";
+
+ /** query isNamed (String[1]) : boolean */
+ public final static String IsNamed_String_1 = "IsNamed";
+
+ /** query isNameLongerThan (boolean[1], Integer[1) : boolean */
+ public static String isNameLongerThan_Boolean_1_Integer_1 = "IsNameLongerThan";
+
+ /** query ListelementWithName */
+ public static String ListElementsWithName_String_1 = "ListElementsWithName";
+
+ /** query ListelementWithName */
+ public static String ListElementsInstanceofClassifiers = "ListElementsInstanceofClassifiers";
+
+ /** configuration name for ListElementsInstanceofClassifiersWithNameContainingBasic query test */
+ public static final String ListElementsInstanceofClassifiersWithNameContainingBasic_path = "/resources/ListElementsInstanceofClassifiersWithNameContainingBasic.configuration";
+
+ /** configuration name for ListElementWithName query test */
+ public static final String ListElementsWithNameQueryConfiguration_Path = "/resources/ListElementsWithNameBasic.configuration";
+
+ /** query AND (boolean[1], booelan[1) : boolean */
+ public static String AND_Boolean_1_Boolean_1 = "AND";
+
+ /** configuration 1 name for IsNamed query test */
+ public static final String IsNameLongerThanConfiguration1_Path = "/resources/IsNameLongerThanQueryConfiguration1.configuration";
+
+ /** configuration 2 name for IsNamed query test */
+ public static final String IsNameLongerThanConfiguration2_Path = "/resources/IsNameLongerThanQueryConfiguration2.configuration";
+
+ /** configuration name for and query test */
+ public static final String ANDConfiguration_Path = "/resources/AndConfiguration.configuration";
+
+ /** Query: BooleanTest_String_1(String[1]) : boolean */
+ public final static String BooleanTest_String_1 = "BooleanTest_String_1";
+
+ /** parameter name */
+ public final static String BooleanTest_String_1_StringParamName = "paramString";
+
+ /** Query: BooleanTest_Boolean_1_Integer_1(Boolean[1], Integer[1]) : boolean */
+ public final static String BooleanTest_Boolean_1_Integer_1 = "BooleanTest_Boolean_1_Integer_1";
+
+ /** parameter name */
+ public final static String BooleanTest_Boolean_1_Integer_1_BooleanParamName = "paramBoolean";
+
+ /** parameter name */
+ public final static String BooleanTest_Boolean_1_Integer_1_IntegetParamName = "paramInteger";
+
+ /** Query: BooleanTest_Enum_1(Enum[1]) : boolean */
+ public final static String BooleanTest_Enum_1 = "BooleanTest_Enum_1";
+
+ /** parameter name */
+ public final static String BooleanTest_Enum_1_EnumParamName = "paramEnum";
+
+ /** Query: BooleanTest_String_3(String[3]) : boolean */
+ public final static String BooleanTest_String_3 = "BooleanTest_String_3";
+
+ /** parameter name */
+ public final static String BooleanTest_String_3_StringParamName = "paramString3";
+
+ /** Query: BooleanTest_String_Star(String[*]) : boolean */
+ public final static String BooleanTest_String_Star = "BooleanTest_String_Star";
+
+ /** parameter name */
+ public final static String BooleanTest_String_Star_StringParamName = "paramStringStar";
+
+ /** name of the class in the test model */
+ public static final String UML_CLASS_NAME = "BasicClass";
+
+}
+
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IsNameLongerThanTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IsNameLongerThanTests.java new file mode 100644 index 00000000000..e6f9243b45c --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IsNameLongerThanTests.java @@ -0,0 +1,155 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.papyrus.core.queries.test.Activator;
+import org.eclipse.papyrus.infra.queries.core.configuration.ModiscoQueryConfiguration;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test class for boolean and integer parameters for queries
+ */
+public class IsNameLongerThanTests extends AbstractQueryUtilTest implements IQueryNames {
+
+ /** query on which tests are based */
+ protected static ModelQuery isNameLongerThanQuery;
+
+ /** model query configuration model n°1 */
+ protected static ModiscoQueryConfiguration configuration1;
+
+ /** model query configuration model n°2 */
+ protected static ModiscoQueryConfiguration configuration2;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // retrieve the query
+ isNameLongerThanQuery = QueryUtil.retrieveModelQuery(isNameLongerThan_Boolean_1_Integer_1, IQueryNames.CoreQueriesSet_Name);
+ assertNotNull("Query " + isNameLongerThan_Boolean_1_Integer_1 + " was not found.", isNameLongerThanQuery);
+
+ // retrieve the configuration
+ configuration1 = TestUtil.loadQueryConfiguration(Activator.PLUGIN_ID, IQueryNames.IsNameLongerThanConfiguration1_Path);
+ assertNotNull("Configuration " + IQueryNames.IsNameLongerThanConfiguration1_Path + " was not found.", configuration1);
+
+ // retrieve the configuration
+ configuration2 = TestUtil.loadQueryConfiguration(Activator.PLUGIN_ID, IQueryNames.IsNameLongerThanConfiguration2_Path);
+ assertNotNull("Configuration " + IQueryNames.IsNameLongerThanConfiguration2_Path + " was not found.", configuration2);
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.ModiscoQueryConfiguration)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryEObjectModiscoQueryConfigurationPackage1() {
+ // test if no exception is thrown
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(umlPackage, configuration1);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertFalse("Query result should be false", result);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.ModiscoQueryConfiguration)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryEObjectModiscoQueryConfigurationClass1() {
+ // test if no exception is thrown
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(umlClass, configuration1);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertTrue("Query result should be true", result);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.ModiscoQueryConfiguration)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryEObjectModiscoQueryConfigurationPackage2() {
+ // test if no exception is thrown
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(umlPackage, configuration2);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertFalse("Query result should be true", result);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.ModiscoQueryConfiguration)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryEObjectModiscoQueryConfigurationClass2() {
+ // test if no exception is thrown
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(umlClass, configuration2);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertFalse("Query result should be false", result);
+ }
+
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IsNamedTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IsNamedTests.java new file mode 100644 index 00000000000..472d97cfa77 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/IsNamedTests.java @@ -0,0 +1,114 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.papyrus.core.queries.test.Activator;
+import org.eclipse.papyrus.infra.queries.core.configuration.ModiscoQueryConfiguration;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * test class for the configuration evaluation for string parameters
+ */
+public class IsNamedTests extends AbstractQueryUtilTest implements IQueryNames {
+
+ /** query on which tests are based */
+ protected static ModelQuery isNamedQuery;
+
+ /** model query configuration model */
+ protected static ModiscoQueryConfiguration configuration;
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // retrieve the query
+ isNamedQuery = QueryUtil.retrieveModelQuery(IsNamed_String_1, IQueryNames.CoreQueriesSet_Name);
+ assertNotNull("Query " + IsNamed_String_1 + " was not found.", isNamedQuery);
+
+ // retrieve the configuration
+ configuration = TestUtil.loadQueryConfiguration(Activator.PLUGIN_ID, IQueryNames.IsNamedQueryConfiguration_Path);
+ assertNotNull("Configuration " + IQueryNames.IsNamedQueryConfiguration_Path + " was not found.", configuration);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.ModiscoQueryConfiguration)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQueryModelQueryEObjectModiscoQueryConfigurationValid() {
+ // test if no exception is thrown
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(umlPackage, configuration);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertTrue("Query result should be true", result);
+
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.ModiscoQueryConfiguration)}
+ */
+ @Test
+ public final void testEvaluateBooleanQueryModelQueryEObjectModiscoQueryConfigurationNotValid() {
+ // test if no exception is thrown
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(umlPackage.eContents().get(0), configuration);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertFalse("Query result should be false", result);
+
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ListElementsInstanceofClassifiersWithNameContainingBasicTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ListElementsInstanceofClassifiersWithNameContainingBasicTests.java new file mode 100644 index 00000000000..8c1d7874891 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ListElementsInstanceofClassifiersWithNameContainingBasicTests.java @@ -0,0 +1,71 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.papyrus.core.queries.test.Activator;
+import org.eclipse.papyrus.infra.queries.core.configuration.ModiscoQueryConfiguration;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test class for query chaining, with list of elements given from one list to another
+ */
+public class ListElementsInstanceofClassifiersWithNameContainingBasicTests extends AbstractQueryUtilTest implements IQueryNames {
+
+ /** query on which tests are based */
+ protected static ModelQuery query;
+
+ /** model query configuration model */
+ protected static ModiscoQueryConfiguration configuration;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // retrieve the query
+ query = QueryUtil.retrieveModelQuery(ListElementsInstanceofClassifiers, IQueryNames.CoreQueriesSet_Name);
+ assertNotNull("Query " + ListElementsInstanceofClassifiers + " was not found.", query);
+
+ // retrieve the configuration
+ configuration = TestUtil.loadQueryConfiguration(Activator.PLUGIN_ID, IQueryNames.ListElementsInstanceofClassifiersWithNameContainingBasic_path);
+ assertNotNull("Configuration " + IQueryNames.ListElementsInstanceofClassifiersWithNameContainingBasic_path + " was not found.", configuration);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateQuery(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.QueryConfiguration)}.
+ */
+ @Test
+ public final void testEvaluateQueryEObjectQueryConfiguration() {
+ // test if no exception is thrown
+ Object result = false;
+ try {
+ result = QueryUtil.evaluateQuery(umlPackage, configuration);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertNotNull("Query result should not be null", result);
+ assertTrue("Result should be of type list, but is: " + result, result instanceof List<?>);
+ assertTrue("There should be 2 elements in the result list - root package and one class. Currently: " + ((List<Object>)result).size(), ((List<Object>)result).size() == 2);
+
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ListElementsWithNameTest.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ListElementsWithNameTest.java new file mode 100644 index 00000000000..64025d548e4 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/ListElementsWithNameTest.java @@ -0,0 +1,92 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.papyrus.core.queries.test.Activator;
+import org.eclipse.papyrus.infra.queries.core.configuration.ModiscoQueryConfiguration;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test Case for List Element
+ */
+public class ListElementsWithNameTest extends AbstractQueryUtilTest implements IQueryNames {
+
+ /** query on which tests are based */
+ protected static ModelQuery query;
+
+ /** model query configuration model */
+ protected static ModiscoQueryConfiguration configuration;
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // retrieve the query
+ query = QueryUtil.retrieveModelQuery(ListElementsWithName_String_1, IQueryNames.CoreQueriesSet_Name);
+ assertNotNull("Query " + ListElementsWithName_String_1 + " was not found.", query);
+
+ // retrieve the configuration
+ configuration = TestUtil.loadQueryConfiguration(Activator.PLUGIN_ID, IQueryNames.ListElementsWithNameQueryConfiguration_Path);
+ assertNotNull("Configuration " + IQueryNames.ListElementsWithNameQueryConfiguration_Path + " was not found.", configuration);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.core.queries.configuration.ModiscoQueryConfiguration)}
+ * .
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public final void testEvaluateBooleanQueryEObjectModiscoQueryConfiguration() {
+ // test if no exception is thrown
+ Object result = false;
+ try {
+ result = QueryUtil.evaluateQuery(umlPackage, configuration);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertNotNull("Query result should not be null", result);
+ assertTrue("Result should be of type list, but is: " + result, result instanceof List<?>);
+ assertTrue("There should be 3 elements in the result list - root package and 2 owned class. Currently: " + ((List<Object>)result).size(), ((List<Object>)result).size() == 3);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/Messages.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/Messages.java new file mode 100644 index 00000000000..565011b1863 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/Messages.java @@ -0,0 +1,41 @@ +package org.eclipse.papyrus.core.queries.test.modisco;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.core.queries.test.modisco.messages"; //$NON-NLS-1$
+
+ public static String QueryUtilTest_Error_CatalogIsNull;
+
+ public static String QueryUtilTest_Error_Exceptionthrown_QueryShouldNotBeFound;
+
+ public static String QueryUtilTest_Error_NoExceptionThrown_QuerySetNotFound;
+
+ public static String QueryUtilTest_Error_NoExceptionThrown_UnfoundableQuery;
+
+ public static String QueryUtilTest_Error_NotNull_UnfoundableQuery;
+
+ public static String QueryUtilTest_Error_NotNull_UnfoundableQuerySet;
+
+ public static String QueryUtilTest_NotFoundQuery;
+
+ public static String QueryUtilTest_NotFoundQuerySet;
+
+ public static String QueryUtilTest_QuerySetName_CoreQueriesTest;
+
+ public static String QueryUtilTest_TestName_BooleanTest_NoParameters;
+
+ public static String QueryUtilTest_TestName_StringTest_NoParameters;
+
+ public static String QueryUtilTest_TestName_StringMultipleTest_NoParameters;
+
+ public static String QueryUtilTest_TestName_BooleanMultipleTest_NoParameters;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/QueryUtilBasicTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/QueryUtilBasicTests.java new file mode 100644 index 00000000000..7fb77e77264 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/QueryUtilBasicTests.java @@ -0,0 +1,129 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.core.ModelQuerySetCatalog;
+import org.eclipse.papyrus.infra.queries.core.modisco.ModelQueryNotFoundException;
+import org.eclipse.papyrus.infra.queries.core.modisco.ModelQuerySetNotFoundException;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test class for {@link QueryUtil}
+ */
+public class QueryUtilBasicTests {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#QueryUtil()}.
+ */
+ @Test
+ public final void testQueryUtil() {
+ ModelQuerySetCatalog catalog = ModelQuerySetCatalog.getSingleton();
+ assertNotNull(Messages.QueryUtilTest_Error_CatalogIsNull, catalog);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#retrieveModelQuery(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public final void testRetrieveModelQuery_NoQuerySet() {
+ // do not retrieve the query set
+ boolean exceptionThrown = false;
+ ModelQuery queryNoSet = null;
+ try {
+ queryNoSet = QueryUtil.retrieveModelQuery(Messages.QueryUtilTest_NotFoundQuery, Messages.QueryUtilTest_NotFoundQuerySet);
+ } catch (ModelQuerySetNotFoundException e) {
+ exceptionThrown = true;
+ }
+ assertTrue(Messages.QueryUtilTest_Error_NoExceptionThrown_QuerySetNotFound, exceptionThrown);
+ assertNull(Messages.QueryUtilTest_Error_NotNull_UnfoundableQuerySet, queryNoSet);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#retrieveModelQuery(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public final void testRetrieveModelQuery_NoQuery() {
+ // do not retrieve the query
+ boolean exceptionThrown = false;
+ ModelQuery queryNoQuery = null;
+ try {
+ queryNoQuery = QueryUtil.retrieveModelQuery(Messages.QueryUtilTest_NotFoundQuery, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ } catch (ModelQueryNotFoundException e) {
+ exceptionThrown = true;
+ } catch (ModelQuerySetNotFoundException e) {
+ exceptionThrown = true;
+ }
+ assertTrue(Messages.QueryUtilTest_Error_NoExceptionThrown_UnfoundableQuery, exceptionThrown);
+ assertNull(Messages.QueryUtilTest_Error_NotNull_UnfoundableQuery, queryNoQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#retrieveModelQuery(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public final void testRetrieveModelQuery_QueryFound() {
+ // retrieve a query
+ boolean exceptionThrown = false;
+ ModelQuery queryBooleanTest_NoParameters = null;
+ try {
+ queryBooleanTest_NoParameters = QueryUtil.retrieveModelQuery(Messages.QueryUtilTest_TestName_BooleanTest_NoParameters, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ } catch (ModelQueryNotFoundException e) {
+ exceptionThrown = true;
+ } catch (ModelQuerySetNotFoundException e) {
+ exceptionThrown = true;
+ }
+ assertFalse(Messages.QueryUtilTest_Error_Exceptionthrown_QueryShouldNotBeFound, exceptionThrown);
+ Assert.assertNotNull(queryBooleanTest_NoParameters != null);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/QueryUtil_Parameters.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/QueryUtil_Parameters.java new file mode 100644 index 00000000000..b242d26dc93 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/QueryUtil_Parameters.java @@ -0,0 +1,192 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.eclipse.uml2.uml.VisibilityKind;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test Class for {@link QueryUtil#isValidParameterSet(org.eclipse.emf.facet.infra.query.ModelQuery, java.util.Map)}
+ */
+public class QueryUtil_Parameters extends AbstractQueryUtilTest {
+
+ /** queries on which tests are based */
+ protected static ModelQuery queryBooleanTest_String_1, queryBooleanTest_Boolean_1_Integer_1, queryBooleanTest_Enum_1, queryBooleanTest_String_3, queryBooleanTest_String_Star;
+
+ // list of possible values to test
+ /** value: String */
+ protected static String paramStringValue = "string";
+
+ /** value: Integer */
+ protected static int paramIntValue = 1;
+
+ /** value: boolean */
+ protected static boolean paramBooleanValue = true;
+
+ /** value: Enumeration */
+ protected static VisibilityKind paramEnumValue = VisibilityKind.PUBLIC_LITERAL;
+
+ /** list of Strings */
+ protected static List<String> paramStringList2Value = Arrays.asList("string1", "String2");
+
+ /** list of Strings */
+ protected static List<String> paramStringList4Value = Arrays.asList("string1", "String2", "string3", "String4");
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ queryBooleanTest_String_1 = QueryUtil.retrieveModelQuery(BooleanTest_String_1, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + BooleanTest_String_1 + " was not found.", queryBooleanTest_String_1);
+
+ queryBooleanTest_Boolean_1_Integer_1 = QueryUtil.retrieveModelQuery(BooleanTest_Boolean_1_Integer_1, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + BooleanTest_Boolean_1_Integer_1 + " was not found.", queryBooleanTest_Boolean_1_Integer_1);
+
+ queryBooleanTest_Enum_1 = QueryUtil.retrieveModelQuery(BooleanTest_Enum_1, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + BooleanTest_Enum_1 + " was not found.", queryBooleanTest_Enum_1);
+
+ queryBooleanTest_String_3 = QueryUtil.retrieveModelQuery(BooleanTest_String_3, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + BooleanTest_String_3 + " was not found.", queryBooleanTest_String_3);
+
+ queryBooleanTest_String_Star = QueryUtil.retrieveModelQuery(BooleanTest_String_Star, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + BooleanTest_String_Star + " was not found.", queryBooleanTest_String_Star);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidParameterSet(org.eclipse.emf.facet.infra.query.ModelQuery, java.util.Map)}.
+ */
+ @Test
+ public final void testIsValidParameterSet_String_Valid() {
+ // public static final IStatus isValidParameterSet(ModelQuery query, Map<String, Object> parameters);
+ HashMap<String, Object> validParamSet = new HashMap<String, Object>();
+ validParamSet.put(BooleanTest_String_1_StringParamName, paramStringValue);
+ IStatus status = QueryUtil.isValidParameterSet(queryBooleanTest_String_1, validParamSet);
+
+ assertTrue("Status should be OK: " + status, status.isOK());
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidParameterSet(org.eclipse.emf.facet.infra.query.ModelQuery, java.util.Map)}.
+ */
+ @Test
+ public final void testIsValidParameterSet_String_WrongName() {
+ // public static final IStatus isValidParameterSet(ModelQuery query, Map<String, Object> parameters);
+ HashMap<String, Object> validParamSet = new HashMap<String, Object>();
+ validParamSet.put(BooleanTest_String_1_StringParamName + "NotValid", paramStringValue);
+ IStatus status = QueryUtil.isValidParameterSet(queryBooleanTest_String_1, validParamSet);
+
+ assertTrue("Status should be ERROR: " + status, status.getSeverity() == IStatus.ERROR);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidParameterSet(org.eclipse.emf.facet.infra.query.ModelQuery, java.util.Map)}.
+ */
+ @Test
+ public final void testIsValidParameterSet_String_WrongSize() {
+ // public static final IStatus isValidParameterSet(ModelQuery query, Map<String, Object> parameters);
+ HashMap<String, Object> validParamSet = new HashMap<String, Object>();
+ validParamSet.put(BooleanTest_String_1_StringParamName, paramStringValue);
+ validParamSet.put(BooleanTest_String_1_StringParamName + "NotValid", paramStringValue);
+ IStatus status = QueryUtil.isValidParameterSet(queryBooleanTest_String_1, validParamSet);
+
+ assertTrue("Status should be ERROR: " + status, status.getSeverity() == IStatus.ERROR);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidParameterSet(org.eclipse.emf.facet.infra.query.ModelQuery, java.util.Map)}.
+ */
+ @Test
+ public final void testIsValidParameterSet_String_WrongType() {
+ // public static final IStatus isValidParameterSet(ModelQuery query, Map<String, Object> parameters);
+ HashMap<String, Object> validParamSet = new HashMap<String, Object>();
+ validParamSet.put(BooleanTest_String_1_StringParamName, paramBooleanValue);
+ IStatus status = QueryUtil.isValidParameterSet(queryBooleanTest_String_1, validParamSet);
+ System.err.println("warning, no test is currently run for type: " + status);
+ // FIXME: warning, no test is currently run for type
+ // assertTrue("Status should be ERROR: " + status, status.getSeverity() == IStatus.ERROR);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidParameterSet(org.eclipse.emf.facet.infra.query.ModelQuery, java.util.Map)}.
+ */
+ @Test
+ public final void testIsValidParameterSet_BooleanInteger_WrongSize() {
+ // public static final IStatus isValidParameterSet(ModelQuery query, Map<String, Object> parameters);
+ HashMap<String, Object> validParamSet = new HashMap<String, Object>();
+ validParamSet.put(BooleanTest_String_1_StringParamName, paramStringValue);
+ IStatus status = QueryUtil.isValidParameterSet(queryBooleanTest_Boolean_1_Integer_1, validParamSet);
+
+ assertTrue("Status should be ERROR: " + status, status.getSeverity() == IStatus.ERROR);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil# evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, java.util.Map)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQuery_BooleanTest_String_1_Valid() {
+ // public static final IStatus isValidParameterSet(ModelQuery query, Map<String, Object> parameters);
+ HashMap<String, Object> validParamSet = new HashMap<String, Object>();
+ validParamSet.put(BooleanTest_String_1_StringParamName, paramStringValue);
+ boolean exceptionThrown = false;
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(queryBooleanTest_String_1, umlPackage, validParamSet);
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertTrue("result should be valid.", result);
+ assertFalse("No Exception should be thrown", exceptionThrown);
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil# evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, java.util.Map)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQuery_BooleanTest_String_1_NotValid() {
+ // public static final IStatus isValidParameterSet(ModelQuery query, Map<String, Object> parameters);
+ HashMap<String, Object> validParamSet = new HashMap<String, Object>();
+ validParamSet.put(BooleanTest_String_1_StringParamName, paramBooleanValue);
+ @SuppressWarnings("unused")
+ boolean exceptionThrown = false;
+ boolean result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(queryBooleanTest_String_1, umlPackage, validParamSet);
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("result should not be valid, as the value given is a boolean", result);
+ // assertTrue("An exception should be thrown", exceptionThrown);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/StringMultipleTest_NoParametersTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/StringMultipleTest_NoParametersTests.java new file mode 100644 index 00000000000..550373d19ba --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/StringMultipleTest_NoParametersTests.java @@ -0,0 +1,110 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.runtime.ModelQueryParameterValue;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests cases for {@link BooleanTest_NoParameters}
+ */
+public class StringMultipleTest_NoParametersTests extends AbstractQueryUtilTest {
+
+ /** query on which tests are based */
+ protected static ModelQuery stringsQuery;
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ stringsQuery = QueryUtil.retrieveModelQuery(Messages.QueryUtilTest_TestName_StringMultipleTest_NoParameters, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_StringMultipleTest_NoParameters + " was not found.", stringsQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#retrieveModelQuery(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public final void testRetrieveModelQuery_StringMultipleTest_NoParameters() {
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_StringMultipleTest_NoParameters + " was not found.", stringsQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidQuery(org.eclipse.emf.facet.infra.query.ModelQuery)}.
+ */
+ @Test
+ public final void testIsValidQuery_StringMultipleTest_NoParameters() {
+ IStatus status = QueryUtil.isValidBooleanQuery(stringsQuery);
+ assertFalse("Query " + Messages.QueryUtilTest_TestName_StringMultipleTest_NoParameters + " should not be a valid query, as it returns several Strings. Current Status: " + status.getMessage(), status.isOK());
+
+ status = QueryUtil.isValidQuery(stringsQuery);
+ assertTrue("Query should be a valid query. Current Status: " + status.getMessage(), status.isOK());
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, java.util.List)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQuery_StringMultipleTest_NoParameters() {
+ boolean exceptionThrown = false;
+ boolean result = false;
+
+
+ // test with null as parameter
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(stringsQuery, umlPackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("The query should not be true, as it returns a string, not a boolean", result);
+ assertFalse("No Exception should be thrown", exceptionThrown);
+
+ // test with an empty array list
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(stringsQuery, umlPackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("The query should not be true, as it returns a string, not a boolean", result);
+ assertFalse("No Exception should be thrown", exceptionThrown);
+
+ // test with not an element context
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(stringsQuery, ecorePackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("The query should not be true, as it returns a string, not a boolean", result);
+ // assertTrue("An exception should be thrown", exceptionThrown);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/StringTest_NoParametersTests.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/StringTest_NoParametersTests.java new file mode 100644 index 00000000000..cb0094e4d28 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/StringTest_NoParametersTests.java @@ -0,0 +1,112 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.runtime.ModelQueryParameterValue;
+import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests cases for {@link BooleanTest_NoParameters}
+ */
+public class StringTest_NoParametersTests extends AbstractQueryUtilTest {
+
+ /** query on which tests are based */
+ protected static ModelQuery stringQuery;
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ stringQuery = QueryUtil.retrieveModelQuery(Messages.QueryUtilTest_TestName_StringTest_NoParameters, Messages.QueryUtilTest_QuerySetName_CoreQueriesTest);
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_StringTest_NoParameters + " was not found.", stringQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#retrieveModelQuery(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public final void testRetrieveModelQuery_StringTest_NoParameters() {
+ assertNotNull("Query " + Messages.QueryUtilTest_TestName_StringTest_NoParameters + " was not found.", stringQuery);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#isValidQuery(org.eclipse.emf.facet.infra.query.ModelQuery)}.
+ */
+ @Test
+ public final void testIsValidQuery_StringTest_NoParameters() {
+ IStatus status = QueryUtil.isValidBooleanQuery(stringQuery);
+ assertFalse("Query " + Messages.QueryUtilTest_TestName_StringTest_NoParameters + " should not be a valid query, as it returns a String. Current Status: " + status.getMessage(), status.isOK());
+
+ status = QueryUtil.isValidQuery(stringQuery);
+ assertTrue("Query should be a valid query. Current Status: " + status.getMessage(), status.isOK());
+
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.papyrus.core.queries.modisco.QueryUtil#evaluateBooleanQuery(org.eclipse.emf.facet.infra.query.ModelQuery, org.eclipse.emf.ecore.EObject, java.util.List)}
+ * .
+ */
+ @Test
+ public final void testEvaluateBooleanQuery_StringTest_NoParameters() {
+ boolean exceptionThrown = false;
+ boolean result = false;
+
+
+ // test with null as parameter
+ exceptionThrown = false;
+ result = false;
+ try {
+ // test with null as parameter
+ result = QueryUtil.evaluateBooleanQuery(stringQuery, umlPackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("The query should not be true, as it returns a string, not a boolean", result);
+ assertFalse("No Exception should be thrown", exceptionThrown);
+
+ // test with an empty array list
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(stringQuery, umlPackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ assertFalse("No Exception should be thrown", exceptionThrown);
+ assertFalse("The query should not be true, as it returns a string, not a boolean", result);
+
+ // test with not an element context
+ exceptionThrown = false;
+ result = false;
+ try {
+ result = QueryUtil.evaluateBooleanQuery(stringQuery, ecorePackage, new ArrayList<ModelQueryParameterValue>());
+ } catch (Exception e) {
+ exceptionThrown = true;
+ }
+ // assertTrue("An exception should be thrown", exceptionThrown);
+ assertFalse("The query should not be true, as it returns a string, not a boolean", result);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/TestUtil.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/TestUtil.java new file mode 100644 index 00000000000..5f608e8ffcb --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/TestUtil.java @@ -0,0 +1,68 @@ +/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.core.queries.test.modisco;
+
+import java.io.IOException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.infra.queries.core.configuration.ModiscoQueryConfiguration;
+
+
+/**
+ * Utility class for tests
+ */
+public class TestUtil {
+
+ /**
+ * Loads a model and returns the main element
+ *
+ * @param pluginPath
+ * the identifier of the test plugin
+ * @param localPath
+ * the path to the file
+ * @return the model loaded
+ */
+ public static EObject loadModel(String pluginPath, String localPath) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = resourceSet.createResource(URI.createPlatformPluginURI("/" + pluginPath + localPath, true));
+ try {
+ resource.load(null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return resource.getContents().get(0);
+ }
+
+ /**
+ * Loads a model and returns the contained model configuration element
+ *
+ * @param pluginPath
+ * the identifier of the test plugin
+ * @param localPath
+ * the path to the file
+ * @return the model loaded
+ */
+ public static ModiscoQueryConfiguration loadQueryConfiguration(String pluginPath, String localPath) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = resourceSet.createResource(URI.createPlatformPluginURI("/" + pluginPath + localPath, true));
+ try {
+ resource.load(null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return (ModiscoQueryConfiguration)resource.getContents().get(0);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/messages.properties b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/messages.properties new file mode 100644 index 00000000000..839db70c4a9 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/messages.properties @@ -0,0 +1,18 @@ +# Query set Names
+QueryUtilTest_NotFoundQuerySet=NotFoundQuerySet
+QueryUtilTest_QuerySetName_CoreQueriesTest=CoreQueriesTest
+
+# Query Names
+QueryUtilTest_NotFoundQuery=NotFoundQuery
+QueryUtilTest_TestName_BooleanTest_NoParameters=BooleanTest_NoParameters
+QueryUtilTest_TestName_BooleanMultipleTest_NoParameters=BooleanMultipleTest_NoParameters
+QueryUtilTest_TestName_StringTest_NoParameters=StringTest_NoParameters
+QueryUtilTest_TestName_StringMultipleTest_NoParameters=StringMultipleTest_NoParameters
+
+# Errors
+QueryUtilTest_Error_CatalogIsNull=Catalog singleton should not be null
+QueryUtilTest_Error_Exceptionthrown_QueryShouldNotBeFound=Exception thrown whereas query should be found
+QueryUtilTest_Error_NoExceptionThrown_QuerySetNotFound=No Exception thrown whereas query Set was not found
+QueryUtilTest_Error_NoExceptionThrown_UnfoundableQuery=No Exception thrown whereas query was not found
+QueryUtilTest_Error_NotNull_UnfoundableQuery=Non existing Query should be null
+QueryUtilTest_Error_NotNull_UnfoundableQuerySet=Non existing QuerySet should be null
\ No newline at end of file diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/AND.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/AND.java new file mode 100644 index 00000000000..372ac3939db --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/AND.java @@ -0,0 +1,22 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.NamedElement; + +/** test - AND query */ +public class AND implements IJavaModelQuery<NamedElement, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final NamedElement context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + // retrieve operand left + boolean leftValue = (Boolean)parameterValues.getValueByParameterName("AND_leftOperand"); + // retrieve operand right + boolean rightValue = (Boolean)parameterValues.getValueByParameterName("AND_rightOperand"); + // return value + return (leftValue && rightValue); + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanMultipleTest_NoParameters.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanMultipleTest_NoParameters.java new file mode 100644 index 00000000000..2b453f63916 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanMultipleTest_NoParameters.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.core.queries.test.modisco.queries; + +import java.util.Arrays; +import java.util.Collection; + +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - boolean return multiple values - no parameters */ +public class BooleanMultipleTest_NoParameters implements IJavaModelQuery<Element, Collection<Boolean>> { + + /** + * {@inheritDoc} + */ + public Collection<Boolean> evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return Arrays.asList(true, false, true); + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_Boolean_1_Integer_1.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_Boolean_1_Integer_1.java new file mode 100644 index 00000000000..3a2fe753106 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_Boolean_1_Integer_1.java @@ -0,0 +1,17 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - boolean return value - Boolean[1], Integer[1] */ +public class BooleanTest_Boolean_1_Integer_1 implements IJavaModelQuery<Element, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return true; + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_Enum_1.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_Enum_1.java new file mode 100644 index 00000000000..546bb68085d --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_Enum_1.java @@ -0,0 +1,17 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - boolean return value - Enum[1] */ +public class BooleanTest_Enum_1 implements IJavaModelQuery<Element, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return true; + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_NoParameters.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_NoParameters.java new file mode 100644 index 00000000000..6b8d0062a0c --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_NoParameters.java @@ -0,0 +1,31 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.core.queries.test.modisco.queries; + +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - boolean return value - no parameters */ +public class BooleanTest_NoParameters implements IJavaModelQuery<Element, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return (context instanceof Element); + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_1.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_1.java new file mode 100644 index 00000000000..d4aaf417b0a --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_1.java @@ -0,0 +1,19 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; + +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.papyrus.core.queries.test.modisco.IQueryNames; +import org.eclipse.uml2.uml.Element; + +/** test - boolean return value - String[1] */ +public class BooleanTest_String_1 implements IJavaModelQuery<Element, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return (parameterValues.getValueByParameterName(IQueryNames.BooleanTest_String_1_StringParamName) instanceof String); + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_3.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_3.java new file mode 100644 index 00000000000..4de555ad4e6 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_3.java @@ -0,0 +1,17 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - boolean return value - String[3] */ +public class BooleanTest_String_3 implements IJavaModelQuery<Element, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return true; + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_Star.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_Star.java new file mode 100644 index 00000000000..12d1e0da49d --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/BooleanTest_String_Star.java @@ -0,0 +1,17 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - boolean return value - String[-1] */ +public class BooleanTest_String_Star implements IJavaModelQuery<Element, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return true; + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/CopyOfIsNamed.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/CopyOfIsNamed.java new file mode 100644 index 00000000000..900f94da7fb --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/CopyOfIsNamed.java @@ -0,0 +1,33 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; + +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.LiteralString; +import org.eclipse.uml2.uml.NamedElement; + +/** test - test if the name of the element is equal to the specified name */ +public class CopyOfIsNamed implements IJavaModelQuery<NamedElement, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final NamedElement context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + // retrieve the parameter name + Object value = parameterValues.getParameterValueByName("name"); + if(value == null) { + throw new ModelQueryExecutionException("The parameter name has no values"); + } + if(!(value instanceof LiteralString)) { + throw new ModelQueryExecutionException("The parameter name does not have a String value"); + } + + if(context == null) { + throw new ModelQueryExecutionException("The context is null, should be a NamedElement"); + } + + return ((LiteralString)value).stringValue().equalsIgnoreCase(context.getName()); + + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsNameLongerThan.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsNameLongerThan.java new file mode 100644 index 00000000000..75981cdc3e8 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsNameLongerThan.java @@ -0,0 +1,36 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.NamedElement; + +/** test - check if the element's name is longer than the specified number. The booelan indicates if it is tru when length is equal. */ +public class IsNameLongerThan implements IJavaModelQuery<NamedElement, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final NamedElement context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + // retrieve the 2 values for the query + boolean isTrueWhenEqual = (Boolean)parameterValues.getValueByParameterName("isTrueWhenEqual"); + int length = (Integer)parameterValues.getValueByParameterName("length"); + + if(!(context instanceof NamedElement)) { + throw new ModelQueryExecutionException("context is null or is not a Named Element"); + } + + String name = context.getName(); + if(name == null) { + return false; + } + + if(name.length() == length) { + return isTrueWhenEqual; + } else if(name.length() > length) { + return true; + } + return false; + + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsNamed.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsNamed.java new file mode 100644 index 00000000000..d3be1d98827 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsNamed.java @@ -0,0 +1,30 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.NamedElement; + +/** test - test if the name of the element is equal to the specified name */ +public class IsNamed implements IJavaModelQuery<NamedElement, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final NamedElement context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + // retrieve the parameter name + Object value = parameterValues.getValueByParameterName("name"); + if(value == null) { + throw new ModelQueryExecutionException("The parameter name has no values"); + } + if(!(value instanceof String)) { + throw new ModelQueryExecutionException("The parameter name does not have a String value"); + } + + if(context == null) { + throw new ModelQueryExecutionException("The context is null, should be a NamedElement"); + } + + return ((String)value).equalsIgnoreCase(context.getName()); + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsStrictInstanceOf.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsStrictInstanceOf.java new file mode 100644 index 00000000000..d48d4257d6e --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/IsStrictInstanceOf.java @@ -0,0 +1,21 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; + +/** test - test if an element is strict type of given value */ +public class IsStrictInstanceOf implements IJavaModelQuery<EObject, Boolean> { + + /** + * {@inheritDoc} + */ + public Boolean evaluate(final EObject context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + + String eObjectTypeName = context.eClass().getInstanceTypeName(); + String typeName = parameterValues.getValueByParameterName("typeName").toString(); + + return eObjectTypeName.equals(typeName); + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/ListElementsInstanceofClassifiers.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/ListElementsInstanceofClassifiers.java new file mode 100644 index 00000000000..b8a0e48eefe --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/ListElementsInstanceofClassifiers.java @@ -0,0 +1,34 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.NamedElement; + +/** test - list the elements given as parameters that are instanceof Classifiers */ +public class ListElementsInstanceofClassifiers implements IJavaModelQuery<EObject, Collection<Classifier>> { + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public Collection<Classifier> evaluate(final EObject context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + // retrieve the list of elements + List<NamedElement> elements = (List<NamedElement>)parameterValues.getValueByParameterName("elementList"); + + List<Classifier> classifiers = new ArrayList<Classifier>(); + for(NamedElement element : elements) { + if(element instanceof Classifier) { + classifiers.add((Classifier)element); + } + } + return classifiers; + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/ListElementsWithName.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/ListElementsWithName.java new file mode 100644 index 00000000000..9e08001426e --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/ListElementsWithName.java @@ -0,0 +1,47 @@ +package org.eclipse.papyrus.core.queries.test.modisco.queries; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.UMLPackage; + +/** test - return a list of named elements for whicv name contains basic */ +public class ListElementsWithName implements IJavaModelQuery<Package, Collection<NamedElement>> { + + /** + * {@inheritDoc} + */ + public Collection<NamedElement> evaluate(final Package context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + + String containedString = (String)parameterValues.getValueByParameterName("containedString"); + + Collection<Object> namedElements = EcoreUtil.getObjectsByType(context.allOwnedElements(), UMLPackage.eINSTANCE.getNamedElement()); + List<NamedElement> elements = new ArrayList<NamedElement>(); + + + // add the element itself if required + if(context instanceof NamedElement) { + String name = ((NamedElement)context).getName(); + if(name != null && name.indexOf(containedString) != -1) { + elements.add((NamedElement)context); + } + } + + // check all contained elements + for(Object namedElement : namedElements) { + String name = ((NamedElement)namedElement).getName(); + if(name != null && name.indexOf(containedString) != -1) { + elements.add((NamedElement)namedElement); + } + } + return elements; + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/StringMultipleTest_NoParameters.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/StringMultipleTest_NoParameters.java new file mode 100644 index 00000000000..a9f3a8f6f83 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/StringMultipleTest_NoParameters.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.core.queries.test.modisco.queries; + +import java.util.Arrays; +import java.util.Collection; + +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - string return multiple values - no parameters */ +public class StringMultipleTest_NoParameters implements IJavaModelQuery<Element, Collection<String>> { + + /** + * {@inheritDoc} + */ + public Collection<String> evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + // TODO Auto-generated method stub + return Arrays.asList("Test1", "Test2"); + } +} diff --git a/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/StringTest_NoParameters.java b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/StringTest_NoParameters.java new file mode 100644 index 00000000000..60e1dc0be08 --- /dev/null +++ b/deprecated/org.eclipse.papyrus.core.queries.test/src/org/eclipse/papyrus/core/queries/test/modisco/queries/StringTest_NoParameters.java @@ -0,0 +1,30 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.core.queries.test.modisco.queries; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.uml2.uml.Element; + +/** test - string return value - no parameters */ +public class StringTest_NoParameters implements IJavaModelQuery<Element, String> { + + /** + * {@inheritDoc} + */ + public String evaluate(final Element context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + return "Test"; + } +} |