1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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);
}
}
|