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 |
|
package info.magnolia.rest.delivery.jcr; |
35 |
|
|
36 |
|
import static info.magnolia.rest.delivery.jcr.FilteringCondition.*; |
37 |
|
import static info.magnolia.test.hamcrest.ExceptionMatcher.instanceOf; |
38 |
|
import static info.magnolia.test.hamcrest.ExecutionMatcher.throwsAnException; |
39 |
|
import static org.hamcrest.CoreMatchers.*; |
40 |
|
import static org.junit.Assert.assertThat; |
41 |
|
|
42 |
|
import info.magnolia.context.MgnlContext; |
43 |
|
import info.magnolia.jcr.RuntimeRepositoryException; |
44 |
|
import info.magnolia.jcr.util.NodeTypes; |
45 |
|
import info.magnolia.jcr.util.PropertiesImportExport; |
46 |
|
import info.magnolia.repository.RepositoryConstants; |
47 |
|
import info.magnolia.test.RepositoryTestCase; |
48 |
|
|
49 |
|
import java.time.LocalDate; |
50 |
|
import java.time.LocalTime; |
51 |
|
import java.time.ZoneId; |
52 |
|
import java.time.ZonedDateTime; |
53 |
|
import java.util.Arrays; |
54 |
|
import java.util.HashMap; |
55 |
|
import java.util.List; |
56 |
|
import java.util.Map; |
57 |
|
|
58 |
|
import javax.jcr.Session; |
59 |
|
import javax.jcr.Workspace; |
60 |
|
import javax.jcr.query.Query; |
61 |
|
|
62 |
|
import org.junit.Before; |
63 |
|
import org.junit.Test; |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (115) |
Complexity: 28 |
Complexity Density: 0.32 |
|
65 |
|
public class QueryBuilderTest extends RepositoryTestCase { |
66 |
|
|
67 |
|
private Session session; |
68 |
|
private Workspace workspace; |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
70 |
27 |
@Before... |
71 |
|
public void setUp() throws Exception { |
72 |
27 |
super.setUp(); |
73 |
27 |
session = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE); |
74 |
27 |
new PropertiesImportExport().createNodes(session.getRootNode(), getClass().getClassLoader().getResourceAsStream("travel-test-data.properties")); |
75 |
27 |
session.save(); |
76 |
|
|
77 |
27 |
workspace = session.getWorkspace(); |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
80 |
1 |
@Test... |
81 |
|
public void listNodes() throws Exception { |
82 |
|
|
83 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
84 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
85 |
|
.build(); |
86 |
|
|
87 |
|
|
88 |
1 |
assertThat(query.getStatement(), equalTo("SELECT t.* FROM [nt:base] AS t WHERE t.[jcr:primaryType] = 'mgnl:page'")); |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
91 |
1 |
@Test... |
92 |
|
public void orderByOneProperty() throws Exception { |
93 |
|
|
94 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
95 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
96 |
|
.orderBy(Arrays.asList("@name desc")) |
97 |
|
.build(); |
98 |
|
|
99 |
|
|
100 |
1 |
assertThat(query.getStatement(), endsWith("ORDER BY LOWER(NAME(t)) DESC")); |
101 |
|
} |
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
103 |
1 |
@Test... |
104 |
|
public void orderByOnePropertyWithDefaultDirection() throws Exception { |
105 |
|
|
106 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
107 |
|
.orderBy(Arrays.asList("title")) |
108 |
|
.build(); |
109 |
|
|
110 |
|
|
111 |
1 |
assertThat(query.getStatement(), endsWith("ORDER BY t.title")); |
112 |
|
} |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
114 |
1 |
@Test... |
115 |
|
public void orderByTwoProperties() throws Exception { |
116 |
|
|
117 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
118 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
119 |
|
.orderBy(Arrays.asList("mgnl:lastModified desc", "@name desc")) |
120 |
|
.build(); |
121 |
|
|
122 |
|
|
123 |
1 |
assertThat(query.getStatement(), endsWith("ORDER BY t.[mgnl:lastModified] DESC, LOWER(NAME(t)) DESC")); |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
126 |
1 |
@Test... |
127 |
|
public void orderByTwoPropertiesWithDefaultDirections() throws Exception { |
128 |
|
|
129 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
130 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
131 |
|
.orderBy(Arrays.asList("mgnl:lastModified", "@name asc")) |
132 |
|
.build(); |
133 |
|
|
134 |
|
|
135 |
1 |
assertThat(query.getStatement(), endsWith("ORDER BY t.[mgnl:lastModified], LOWER(NAME(t))")); |
136 |
|
} |
137 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
138 |
1 |
@Test... |
139 |
|
public void listNodesWithRootPath() throws Exception { |
140 |
|
|
141 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
142 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
143 |
|
.rootPath("/travel") |
144 |
|
.build(); |
145 |
|
|
146 |
|
|
147 |
1 |
assertThat(query.getStatement(), containsString("AND ISDESCENDANTNODE(t, [/travel])")); |
148 |
|
} |
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
150 |
1 |
@Test... |
151 |
|
public void foldersShouldNotIncludedInQuery() throws Exception { |
152 |
|
|
153 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
154 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME, NodeTypes.Folder.NAME)) |
155 |
|
.build(); |
156 |
|
|
157 |
|
|
158 |
1 |
assertThat(query.getStatement(), equalTo("SELECT t.* FROM [nt:base] AS t WHERE t.[jcr:primaryType] = 'mgnl:page'")); |
159 |
|
} |
160 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
161 |
1 |
@Test... |
162 |
|
public void searchForNode() throws Exception { |
163 |
|
|
164 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
165 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
166 |
|
.keyword("travel") |
167 |
|
.build(); |
168 |
|
|
169 |
|
|
170 |
1 |
assertThat(query.getStatement(), containsString("AND (LOWER(LOCALNAME(t)) LIKE 'travel%' OR CONTAINS(t.*, 'travel'))")); |
171 |
|
} |
172 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
173 |
1 |
@Test... |
174 |
|
public void searchForNodeByAbsolutePath() throws Exception { |
175 |
|
|
176 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
177 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME, NodeTypes.Component.NAME)) |
178 |
|
.keyword("/travel/about/company") |
179 |
|
.build(); |
180 |
|
|
181 |
|
|
182 |
1 |
assertThat(query.getStatement(), containsString("AND ISSAMENODE(t, [/travel/about/company])")); |
183 |
|
} |
184 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
185 |
1 |
@Test... |
186 |
|
public void searchForAPageContainingUnicode() throws Exception { |
187 |
|
|
188 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
189 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
190 |
|
.keyword("sà i-gòn") |
191 |
|
.build(); |
192 |
|
|
193 |
|
|
194 |
1 |
assertThat(query.getStatement(), containsString("(LOWER(LOCALNAME(t)) LIKE 'sà i-gòn%' OR CONTAINS(t.*, 'sà i-gòn'))")); |
195 |
|
} |
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
197 |
1 |
@Test... |
198 |
|
public void searchForQuotedTextToMakeSureItIsEscapedProperly() throws Exception { |
199 |
|
|
200 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
201 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
202 |
|
.keyword("'text between quotes'") |
203 |
|
.build(); |
204 |
|
|
205 |
|
|
206 |
1 |
assertThat(query.getStatement(), containsString("(LOWER(LOCALNAME(t)) LIKE '''text between quotes''%' OR CONTAINS(t.*, '''text between quotes'''))")); |
207 |
|
} |
208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
209 |
1 |
@Test... |
210 |
|
public void filterWithEqualBoolean() throws Exception { |
211 |
|
|
212 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
213 |
1 |
filteringConditions.put("available", Arrays.asList("true")); |
214 |
|
|
215 |
|
|
216 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
217 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
218 |
|
.conditions(filteringConditions) |
219 |
|
.build(); |
220 |
|
|
221 |
|
|
222 |
1 |
assertThat(query.getStatement(), containsString("AND t.available = 'true'")); |
223 |
|
} |
224 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
225 |
1 |
@Test... |
226 |
|
public void filterWithEqualNumber() throws Exception { |
227 |
|
|
228 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
229 |
1 |
filteringConditions.put("tourists", Arrays.asList("20")); |
230 |
|
|
231 |
|
|
232 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
233 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
234 |
|
.conditions(filteringConditions) |
235 |
|
.build(); |
236 |
|
|
237 |
|
|
238 |
1 |
assertThat(query.getStatement(), containsString("AND t.tourists = CAST('20' AS LONG)")); |
239 |
|
} |
240 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
241 |
1 |
@Test... |
242 |
|
public void filterWithEqualString() throws Exception { |
243 |
|
|
244 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
245 |
1 |
filteringConditions.put("motto", Arrays.asList("If you believe, you can achieve.")); |
246 |
|
|
247 |
|
|
248 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
249 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
250 |
|
.conditions(filteringConditions) |
251 |
|
.build(); |
252 |
|
|
253 |
|
|
254 |
1 |
assertThat(query.getStatement(), containsString("AND t.motto = 'If you believe, you can achieve.'")); |
255 |
|
} |
256 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
257 |
1 |
@Test... |
258 |
|
public void filterWithParamWhoseNameContainsColon() throws Exception { |
259 |
|
|
260 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
261 |
1 |
filteringConditions.put(NodeTypes.Created.CREATED_BY, Arrays.asList("superuser")); |
262 |
|
|
263 |
|
|
264 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
265 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
266 |
|
.conditions(filteringConditions) |
267 |
|
.build(); |
268 |
|
|
269 |
|
|
270 |
1 |
assertThat(query.getStatement(), containsString("AND t.[mgnl:createdBy] = 'superuser'")); |
271 |
|
} |
272 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
273 |
1 |
@Test... |
274 |
|
public void filterByIsoDateTime() throws Exception { |
275 |
|
|
276 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
277 |
1 |
filteringConditions.put(NodeTypes.LastModified.NAME, Arrays.asList("2015-01-26T23:17:02.000+07:00")); |
278 |
|
|
279 |
|
|
280 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
281 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
282 |
|
.conditions(filteringConditions) |
283 |
|
.build(); |
284 |
|
|
285 |
|
|
286 |
1 |
assertThat(query.getStatement(), containsString("AND t.[mgnl:lastModified] = CAST('2015-01-26T23:17:02.000+07:00' AS DATE)")); |
287 |
|
} |
288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
289 |
1 |
@Test... |
290 |
|
public void filterByIsoLocalDate() throws Exception { |
291 |
|
|
292 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
293 |
1 |
filteringConditions.put(NodeTypes.LastModified.NAME, Arrays.asList("2015-01-26")); |
294 |
|
|
295 |
1 |
ZonedDateTime expectedStartDate = ZonedDateTime.of(2015, 1, 26, 0, 0, 0, 0, ZoneId.systemDefault()); |
296 |
1 |
String expectedStartDateString = DATE_TIME_FORMATTER.format(expectedStartDate); |
297 |
|
|
298 |
1 |
LocalDate localDate = LocalDate.parse("2015-01-26", DATE_FORMATTER); |
299 |
1 |
ZonedDateTime zonedDateTime = localDate.atTime(LocalTime.MAX).atZone(ZoneId.systemDefault()); |
300 |
1 |
String expectedEndDateString = zonedDateTime.format(DATE_TIME_FORMATTER); |
301 |
|
|
302 |
|
|
303 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
304 |
|
.nodeTypes(Arrays.asList(NodeTypes.Page.NAME)) |
305 |
|
.conditions(filteringConditions) |
306 |
|
.build(); |
307 |
|
|
308 |
|
|
309 |
1 |
assertThat(query.getStatement(), containsString("AND t.[mgnl:lastModified] >= CAST('" + expectedStartDateString + "' AS DATE)" + |
310 |
|
" AND t.[mgnl:lastModified] <= CAST('" + expectedEndDateString + "' AS DATE)")); |
311 |
|
} |
312 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
313 |
1 |
@Test... |
314 |
|
public void fullTextExpressionContainingJcrIllegalCharsShouldBeEscapedForLikeOperator() throws Exception { |
315 |
|
|
316 |
1 |
String keyword = "test%/:[]*|\t\n"; |
317 |
|
|
318 |
|
|
319 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
320 |
|
.keyword(keyword) |
321 |
|
.build(); |
322 |
|
|
323 |
|
|
324 |
1 |
assertThat(query.getStatement(), endsWith("LOWER(LOCALNAME(t)) LIKE 'test%25%2F%3A%5B%5D%2A%7C%09%0A%' OR CONTAINS(t.*, 'test%/:\\[\\]*|')")); |
325 |
|
} |
326 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
327 |
1 |
@Test... |
328 |
|
public void fullTextExpressionContainingSingleQuoteShouldBeEscaped() throws Exception { |
329 |
|
|
330 |
1 |
String keyword = "'text'"; |
331 |
|
|
332 |
|
|
333 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
334 |
|
.keyword(keyword) |
335 |
|
.build(); |
336 |
|
|
337 |
|
|
338 |
1 |
assertThat(query.getStatement(), endsWith("LOWER(LOCALNAME(t)) LIKE '''text''%' OR CONTAINS(t.*, '''text''')")); |
339 |
|
} |
340 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
341 |
1 |
@Test... |
342 |
|
public void filterValueContainingSingleQuoteShouldBeEscaped() throws Exception { |
343 |
|
|
344 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
345 |
1 |
filteringConditions.put("property", Arrays.asList("value'")); |
346 |
|
|
347 |
|
|
348 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
349 |
|
.conditions(filteringConditions) |
350 |
|
.build(); |
351 |
|
|
352 |
|
|
353 |
1 |
assertThat(query.getStatement(), containsString("t.property = 'value'''")); |
354 |
|
} |
355 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
356 |
1 |
@Test... |
357 |
|
public void filterPropertyContainingSingleQuoteShouldBeEscaped() throws Exception { |
358 |
|
|
359 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
360 |
1 |
filteringConditions.put("property'", Arrays.asList("value")); |
361 |
|
|
362 |
|
|
363 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
364 |
|
.conditions(filteringConditions) |
365 |
|
.build(); |
366 |
|
|
367 |
|
|
368 |
1 |
assertThat(query.getStatement(), containsString("t.property = 'value'")); |
369 |
|
} |
370 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
371 |
1 |
@Test... |
372 |
|
public void filterPropertyContainingBracketThrowsException() throws Exception { |
373 |
|
|
374 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
375 |
1 |
filteringConditions.put("property]", Arrays.asList("value")); |
376 |
|
|
377 |
|
|
378 |
1 |
assertThat(() -> QueryBuilder.inWorkspace(workspace).conditions(filteringConditions).build(), |
379 |
|
throwsAnException(instanceOf(IllegalArgumentException.class) |
380 |
|
.withMessage(containsString("Operator is invalid.")))); |
381 |
|
} |
382 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
383 |
1 |
@Test... |
384 |
|
public void orderByClauseContainingBracketThrowsException() throws Exception { |
385 |
1 |
assertThat(() -> QueryBuilder.inWorkspace(workspace).orderBy(Arrays.asList("test] desc")).build(), |
386 |
|
throwsAnException(instanceOf(RuntimeRepositoryException.class) |
387 |
|
.withMessage(containsString("javax.jcr.query.InvalidQueryException")))); |
388 |
|
} |
389 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
390 |
1 |
@Test... |
391 |
|
public void orderByClauseContainsASingleQuoteThrowsException() throws Exception { |
392 |
1 |
assertThat(() -> QueryBuilder.inWorkspace(workspace).orderBy(Arrays.asList("test' desc")).build(), |
393 |
|
throwsAnException(instanceOf(RuntimeRepositoryException.class) |
394 |
|
.withMessage(containsString("javax.jcr.query.InvalidQueryException")))); |
395 |
|
} |
396 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
397 |
1 |
@Test... |
398 |
|
public void filterByMultiValueProperty() throws Exception { |
399 |
|
|
400 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
401 |
1 |
filteringConditions.put("title", Arrays.asList("first", "second")); |
402 |
|
|
403 |
|
|
404 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
405 |
|
.conditions(filteringConditions) |
406 |
|
.build(); |
407 |
|
|
408 |
|
|
409 |
1 |
assertThat(query.getStatement(), containsString("SELECT t.* FROM [nt:base] AS t WHERE t.title = 'first' AND t.title = 'second'")); |
410 |
|
} |
411 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
412 |
1 |
@Test... |
413 |
|
public void filterByPropertyHavingOrOperator() throws Exception { |
414 |
|
|
415 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
416 |
1 |
filteringConditions.put("title", Arrays.asList("this|that")); |
417 |
|
|
418 |
|
|
419 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
420 |
|
.conditions(filteringConditions) |
421 |
|
.build(); |
422 |
|
|
423 |
|
|
424 |
1 |
assertThat(query.getStatement(), containsString("SELECT t.* FROM [nt:base] AS t WHERE t.title = 'this' OR t.title = 'that'")); |
425 |
|
} |
426 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
427 |
1 |
@Test... |
428 |
|
public void filterByMultipleNames() throws Exception { |
429 |
|
|
430 |
1 |
Map<String, List<String>> filteringConditions = new HashMap<>(); |
431 |
1 |
filteringConditions.put("@name", Arrays.asList("this|that")); |
432 |
|
|
433 |
|
|
434 |
1 |
Query query = QueryBuilder.inWorkspace(workspace) |
435 |
|
.conditions(filteringConditions) |
436 |
|
.build(); |
437 |
|
|
438 |
|
|
439 |
1 |
assertThat(query.getStatement(), containsString("SELECT t.* FROM [nt:base] AS t WHERE LOWER(LOCALNAME(t)) LIKE 'this' OR LOWER(LOCALNAME(t)) LIKE 'that'")); |
440 |
|
} |
441 |
|
} |