|
19 | 19 | import net.datafaker.Faker; |
20 | 20 | import org.assertj.core.api.SoftAssertions; |
21 | 21 | import org.eclipse.jnosql.communication.semistructured.CommunicationEntity; |
| 22 | +import org.eclipse.jnosql.communication.semistructured.CriteriaCondition; |
22 | 23 | import org.eclipse.jnosql.communication.semistructured.Element; |
23 | 24 | import org.eclipse.jnosql.communication.semistructured.Elements; |
| 25 | +import org.eclipse.jnosql.mapping.semistructured.MappingQuery; |
24 | 26 | import org.junit.jupiter.api.BeforeAll; |
25 | 27 | import org.junit.jupiter.api.BeforeEach; |
26 | 28 | import org.junit.jupiter.api.Test; |
27 | 29 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; |
28 | 30 |
|
| 31 | +import java.util.Collections; |
29 | 32 | import java.util.HashMap; |
30 | 33 | import java.util.List; |
31 | 34 | import java.util.Map; |
@@ -607,6 +610,51 @@ void shouldCreateEdgeWithProperties() { |
607 | 610 | }); |
608 | 611 | } |
609 | 612 |
|
| 613 | + @Test |
| 614 | + void shouldFindContains() { |
| 615 | + var entity = getEntity(); |
| 616 | + |
| 617 | + entityManager.insert(entity); |
| 618 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.contains(Element.of("name", |
| 619 | + "lia")), COLLECTION_NAME, Collections.emptyList()); |
| 620 | + |
| 621 | + var result = entityManager.select(query).toList(); |
| 622 | + SoftAssertions.assertSoftly(softly -> { |
| 623 | + softly.assertThat(result).hasSize(1); |
| 624 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 625 | + }); |
| 626 | + } |
| 627 | + |
| 628 | + @Test |
| 629 | + void shouldStartsWith() { |
| 630 | + var entity = getEntity(); |
| 631 | + |
| 632 | + entityManager.insert(entity); |
| 633 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.startsWith(Element.of("name", |
| 634 | + "Pol")), COLLECTION_NAME, Collections.emptyList()); |
| 635 | + |
| 636 | + var result = entityManager.select(query).toList(); |
| 637 | + SoftAssertions.assertSoftly(softly -> { |
| 638 | + softly.assertThat(result).hasSize(1); |
| 639 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 640 | + }); |
| 641 | + } |
| 642 | + |
| 643 | + @Test |
| 644 | + void shouldEndsWith() { |
| 645 | + var entity = getEntity(); |
| 646 | + |
| 647 | + entityManager.insert(entity); |
| 648 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.endsWith(Element.of("name", |
| 649 | + "ana")), COLLECTION_NAME, Collections.emptyList()); |
| 650 | + |
| 651 | + var result = entityManager.select(query).toList(); |
| 652 | + SoftAssertions.assertSoftly(softly -> { |
| 653 | + softly.assertThat(result).hasSize(1); |
| 654 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 655 | + }); |
| 656 | + } |
| 657 | + |
610 | 658 | private CommunicationEntity getEntity() { |
611 | 659 | Faker faker = new Faker(); |
612 | 660 |
|
|
0 commit comments