Search in sources :

Example 91 with DocumentQuery

use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-artemis by eclipse.

the class DocumentQueryParserTest method shouldFindByName.

@Test
public void shouldFindByName() {
    DocumentQuery query = parser.parse("findByName", new Object[] { "name" }, classRepresentation, converters);
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
    assertEquals(Document.of("name", "name"), query.getCondition().get().getDocument());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 92 with DocumentQuery

use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-artemis by eclipse.

the class DocumentQueryParserTest method shouldFindByNameWithPageSortArgument.

@Test
public void shouldFindByNameWithPageSortArgument() {
    Pagination pagination = Pagination.of(2L, 10);
    Sort sort = Sort.of("age", Sort.SortType.ASC);
    DocumentQuery query = parser.parse("findByName", new Object[] { "name", pagination, sort }, classRepresentation, converters);
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
    assertEquals(Document.of("name", "name"), query.getCondition().get().getDocument());
    assertEquals(pagination.getMaxResults(), query.getMaxResults());
    assertEquals(pagination.getFirstResult(), query.getFirstResult());
    assertEquals(sort, query.getSorts().get(0));
}
Also used : Pagination(org.jnosql.artemis.Pagination) DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Sort(org.jnosql.diana.api.Sort) Test(org.junit.jupiter.api.Test)

Example 93 with DocumentQuery

use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-artemis by eclipse.

the class DocumentQueryParserTest method shouldFindByAgeLessThanEqual.

@Test
public void shouldFindByAgeLessThanEqual() {
    DocumentQuery query = parser.parse("findByAgeLessThanEqual", new Object[] { 10 }, classRepresentation, converters);
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(Condition.LESSER_EQUALS_THAN, query.getCondition().get().getCondition());
    assertEquals(Document.of("age", 10), query.getCondition().get().getDocument());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 94 with DocumentQuery

use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-artemis by eclipse.

the class DocumentQueryParserTest method shouldFindByAgeLessThan.

@Test
public void shouldFindByAgeLessThan() {
    DocumentQuery query = parser.parse("findByAgeLessThan", new Object[] { 10 }, classRepresentation, converters);
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(Condition.LESSER_THAN, query.getCondition().get().getCondition());
    assertEquals(Document.of("age", 10), query.getCondition().get().getDocument());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 95 with DocumentQuery

use of org.jnosql.diana.api.document.DocumentQuery in project jnosql-artemis by eclipse.

the class DocumentQueryParserTest method shouldFindByNameWithPageSortArgumentAndIgnore.

@Test
public void shouldFindByNameWithPageSortArgumentAndIgnore() {
    Pagination pagination = Pagination.of(2L, 10);
    Sort sort = Sort.of("age", Sort.SortType.ASC);
    DocumentQuery query = parser.parse("findByName", new Object[] { "name", pagination, sort, "ignore" }, classRepresentation, converters);
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
    assertEquals(Document.of("name", "name"), query.getCondition().get().getDocument());
    assertEquals(pagination.getMaxResults(), query.getMaxResults());
    assertEquals(pagination.getFirstResult(), query.getFirstResult());
    assertEquals(sort, query.getSorts().get(0));
}
Also used : Pagination(org.jnosql.artemis.Pagination) DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Sort(org.jnosql.diana.api.Sort) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)201 Test (org.junit.jupiter.api.Test)186 DocumentEntity (org.jnosql.diana.api.document.DocumentEntity)95 Document (org.jnosql.diana.api.document.Document)84 List (java.util.List)50 DocumentDeleteQuery (org.jnosql.diana.api.document.DocumentDeleteQuery)46 Person (org.jnosql.artemis.model.Person)37 DocumentCondition (org.jnosql.diana.api.document.DocumentCondition)35 Arrays.asList (java.util.Arrays.asList)27 ArrayList (java.util.ArrayList)21 Duration (java.time.Duration)20 DocumentQueryBuilder.select (org.jnosql.diana.api.document.query.DocumentQueryBuilder.select)20 Optional (java.util.Optional)18 AtomicReference (java.util.concurrent.atomic.AtomicReference)18 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)18 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)17 DocumentQueryBuilder.delete (org.jnosql.diana.api.document.query.DocumentQueryBuilder.delete)17 BeforeEach (org.junit.jupiter.api.BeforeEach)17 Consumer (java.util.function.Consumer)16 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)16