Search in sources :

Example 11 with DocumentQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLte.

@Test
public void shouldSelectWhereNameLte() {
    String documentCollection = "documentCollection";
    Number value = 10;
    DocumentQuery query = select().from(documentCollection).where("name").lte(value).build();
    DocumentCondition condition = query.getCondition().get();
    Document document = condition.getDocument();
    assertTrue(query.getDocuments().isEmpty());
    assertEquals(documentCollection, query.getDocumentCollection());
    assertEquals(Condition.LESSER_EQUALS_THAN, condition.getCondition());
    assertEquals("name", document.getName());
    assertEquals(value, document.get());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Document(org.jnosql.diana.api.document.Document) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) Test(org.junit.jupiter.api.Test)

Example 12 with DocumentQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectOrderDesc.

@Test
public void shouldSelectOrderDesc() {
    String documentCollection = "documentCollection";
    DocumentQuery query = select().from(documentCollection).orderBy("name").desc().build();
    assertTrue(query.getDocuments().isEmpty());
    assertFalse(query.getCondition().isPresent());
    assertEquals(documentCollection, query.getDocumentCollection());
    assertThat(query.getSorts(), contains(Sort.of("name", DESC)));
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 13 with DocumentQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectDocument.

@Test
public void shouldSelectDocument() {
    String documentCollection = "documentCollection";
    DocumentQuery query = select("document", "document2").from(documentCollection).build();
    assertThat(query.getDocuments(), containsInAnyOrder("document", "document2"));
    assertFalse(query.getCondition().isPresent());
    assertEquals(documentCollection, query.getDocumentCollection());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 14 with DocumentQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameGt.

@Test
public void shouldSelectWhereNameGt() {
    String documentCollection = "documentCollection";
    Number value = 10;
    DocumentQuery query = select().from(documentCollection).where("name").gt(value).build();
    DocumentCondition condition = query.getCondition().get();
    Document document = condition.getDocument();
    assertTrue(query.getDocuments().isEmpty());
    assertEquals(documentCollection, query.getDocumentCollection());
    assertEquals(Condition.GREATER_THAN, condition.getCondition());
    assertEquals("name", document.getName());
    assertEquals(value, document.get());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Document(org.jnosql.diana.api.document.Document) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) Test(org.junit.jupiter.api.Test)

Example 15 with DocumentQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameEq.

@Test
public void shouldSelectWhereNameEq() {
    String documentCollection = "documentCollection";
    String name = "Ada Lovelace";
    DocumentQuery query = select().from(documentCollection).where("name").eq(name).build();
    DocumentCondition condition = query.getCondition().get();
    Document document = condition.getDocument();
    assertTrue(query.getDocuments().isEmpty());
    assertEquals(documentCollection, query.getDocumentCollection());
    assertEquals(Condition.EQUALS, condition.getCondition());
    assertEquals("name", document.getName());
    assertEquals(name, document.get());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Document(org.jnosql.diana.api.document.Document) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) 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