|
22 | 22 | import org.eclipse.jnosql.communication.TypeReference; |
23 | 23 | import org.eclipse.jnosql.communication.keyvalue.BucketManager; |
24 | 24 | import org.eclipse.jnosql.communication.semistructured.CommunicationEntity; |
| 25 | +import org.eclipse.jnosql.communication.semistructured.CriteriaCondition; |
25 | 26 | import org.eclipse.jnosql.communication.semistructured.DeleteQuery; |
26 | 27 | import org.eclipse.jnosql.communication.semistructured.Element; |
27 | 28 | import org.eclipse.jnosql.communication.semistructured.Elements; |
28 | 29 | import org.eclipse.jnosql.communication.semistructured.SelectQuery; |
| 30 | +import org.eclipse.jnosql.mapping.semistructured.MappingQuery; |
29 | 31 | import org.junit.jupiter.api.AfterEach; |
30 | 32 | import org.junit.jupiter.api.BeforeEach; |
31 | 33 | import org.junit.jupiter.api.Test; |
32 | 34 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; |
33 | 35 |
|
34 | 36 | import java.util.ArrayList; |
| 37 | +import java.util.Collections; |
35 | 38 | import java.util.HashMap; |
36 | 39 | import java.util.HashSet; |
37 | 40 | import java.util.List; |
@@ -294,6 +297,51 @@ void shouldUpdateNull(){ |
294 | 297 | }); |
295 | 298 | } |
296 | 299 |
|
| 300 | + @Test |
| 301 | + void shouldFindContains() { |
| 302 | + var entity = getEntity(); |
| 303 | + |
| 304 | + entityManager.insert(entity); |
| 305 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.contains(Element.of("name", |
| 306 | + "lia")), COLLECTION_PERSON_NAME, Collections.emptyList()); |
| 307 | + |
| 308 | + var result = entityManager.select(query).toList(); |
| 309 | + SoftAssertions.assertSoftly(softly -> { |
| 310 | + softly.assertThat(result).hasSize(1); |
| 311 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 312 | + }); |
| 313 | + } |
| 314 | + |
| 315 | + @Test |
| 316 | + void shouldStartsWith() { |
| 317 | + var entity = getEntity(); |
| 318 | + |
| 319 | + entityManager.insert(entity); |
| 320 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.startsWith(Element.of("name", |
| 321 | + "Pol")), COLLECTION_PERSON_NAME, Collections.emptyList()); |
| 322 | + |
| 323 | + var result = entityManager.select(query).toList(); |
| 324 | + SoftAssertions.assertSoftly(softly -> { |
| 325 | + softly.assertThat(result).hasSize(1); |
| 326 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 327 | + }); |
| 328 | + } |
| 329 | + |
| 330 | + @Test |
| 331 | + void shouldEndsWith() { |
| 332 | + var entity = getEntity(); |
| 333 | + |
| 334 | + entityManager.insert(entity); |
| 335 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.endsWith(Element.of("name", |
| 336 | + "ana")), COLLECTION_PERSON_NAME, Collections.emptyList()); |
| 337 | + |
| 338 | + var result = entityManager.select(query).toList(); |
| 339 | + SoftAssertions.assertSoftly(softly -> { |
| 340 | + softly.assertThat(result).hasSize(1); |
| 341 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 342 | + }); |
| 343 | + } |
| 344 | + |
297 | 345 | private CommunicationEntity getEntity() { |
298 | 346 | CommunicationEntity entity = CommunicationEntity.of(COLLECTION_PERSON_NAME); |
299 | 347 | Map<String, Object> map = new HashMap<>(); |
|
0 commit comments