|
18 | 18 | import org.assertj.core.api.SoftAssertions; |
19 | 19 | import org.eclipse.jnosql.communication.TypeReference; |
20 | 20 | import org.eclipse.jnosql.communication.semistructured.CommunicationEntity; |
| 21 | +import org.eclipse.jnosql.communication.semistructured.CriteriaCondition; |
21 | 22 | import org.eclipse.jnosql.communication.semistructured.DatabaseManager; |
22 | 23 | import org.eclipse.jnosql.communication.semistructured.DeleteQuery; |
23 | 24 | import org.eclipse.jnosql.communication.semistructured.Element; |
24 | 25 | import org.eclipse.jnosql.communication.semistructured.Elements; |
25 | 26 | import org.eclipse.jnosql.communication.semistructured.SelectQuery; |
26 | 27 | import org.eclipse.jnosql.databases.mongodb.communication.type.Money; |
| 28 | +import org.eclipse.jnosql.mapping.semistructured.MappingQuery; |
27 | 29 | import org.junit.jupiter.api.Assertions; |
28 | 30 | import org.junit.jupiter.api.BeforeAll; |
29 | 31 | import org.junit.jupiter.api.BeforeEach; |
@@ -627,6 +629,51 @@ void shouldInsertUUID() { |
627 | 629 |
|
628 | 630 | } |
629 | 631 |
|
| 632 | + @Test |
| 633 | + void shouldFindContains() { |
| 634 | + var entity = getEntity(); |
| 635 | + |
| 636 | + entityManager.insert(entity); |
| 637 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.contains(Element.of("name", |
| 638 | + "lia")), COLLECTION_NAME, Collections.emptyList()); |
| 639 | + |
| 640 | + var result = entityManager.select(query).toList(); |
| 641 | + SoftAssertions.assertSoftly(softly -> { |
| 642 | + softly.assertThat(result).hasSize(1); |
| 643 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 644 | + }); |
| 645 | + } |
| 646 | + |
| 647 | + @Test |
| 648 | + void shouldStartsWith() { |
| 649 | + var entity = getEntity(); |
| 650 | + |
| 651 | + entityManager.insert(entity); |
| 652 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.startsWith(Element.of("name", |
| 653 | + "Pol")), COLLECTION_NAME, Collections.emptyList()); |
| 654 | + |
| 655 | + var result = entityManager.select(query).toList(); |
| 656 | + SoftAssertions.assertSoftly(softly -> { |
| 657 | + softly.assertThat(result).hasSize(1); |
| 658 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 659 | + }); |
| 660 | + } |
| 661 | + |
| 662 | + @Test |
| 663 | + void shouldEndsWith() { |
| 664 | + var entity = getEntity(); |
| 665 | + |
| 666 | + entityManager.insert(entity); |
| 667 | + var query = new MappingQuery(Collections.emptyList(), 0L, 0L, CriteriaCondition.endsWith(Element.of("name", |
| 668 | + "ana")), COLLECTION_NAME, Collections.emptyList()); |
| 669 | + |
| 670 | + var result = entityManager.select(query).toList(); |
| 671 | + SoftAssertions.assertSoftly(softly -> { |
| 672 | + softly.assertThat(result).hasSize(1); |
| 673 | + softly.assertThat(result.get(0).find("name").orElseThrow().get(String.class)).isEqualTo("Poliana"); |
| 674 | + }); |
| 675 | + } |
| 676 | + |
630 | 677 |
|
631 | 678 | private CommunicationEntity createDocumentList() { |
632 | 679 | CommunicationEntity entity = CommunicationEntity.of("AppointmentBook"); |
|
0 commit comments