Search in sources :

Example 1 with Document

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLte.

@Test
public void shouldSelectWhereNameLte() {
    String documentCollection = "documentCollection";
    Number value = 10;
    DocumentDeleteQuery query = delete().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 : Document(org.jnosql.diana.api.document.Document) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 2 with Document

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLike.

@Test
public void shouldSelectWhereNameLike() {
    String documentCollection = "documentCollection";
    String name = "Ada Lovelace";
    DocumentDeleteQuery query = delete().from(documentCollection).where("name").like(name).build();
    DocumentCondition condition = query.getCondition().get();
    Document document = condition.getDocument();
    assertTrue(query.getDocuments().isEmpty());
    assertEquals(documentCollection, query.getDocumentCollection());
    assertEquals(Condition.LIKE, condition.getCondition());
    assertEquals("name", document.getName());
    assertEquals(name, document.get());
}
Also used : Document(org.jnosql.diana.api.document.Document) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 3 with Document

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLt.

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

Example 4 with Document

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameBetween.

@Test
public void shouldSelectWhereNameBetween() {
    String documentCollection = "documentCollection";
    Number valueA = 10;
    Number valueB = 20;
    DocumentDeleteQuery query = delete().from(documentCollection).where("name").between(valueA, valueB).build();
    DocumentCondition condition = query.getCondition().get();
    Document document = condition.getDocument();
    assertTrue(query.getDocuments().isEmpty());
    assertEquals(documentCollection, query.getDocumentCollection());
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals("name", document.getName());
    assertThat(document.get(new TypeReference<List<Number>>() {
    }), Matchers.contains(10, 20));
}
Also used : TypeReference(org.jnosql.diana.api.TypeReference) Document(org.jnosql.diana.api.document.Document) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 5 with Document

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameGte.

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

Aggregations

Document (org.jnosql.diana.api.document.Document)126 Test (org.junit.jupiter.api.Test)102 DocumentEntity (org.jnosql.diana.api.document.DocumentEntity)94 DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)71 List (java.util.List)41 DocumentDeleteQuery (org.jnosql.diana.api.document.DocumentDeleteQuery)37 ArrayList (java.util.ArrayList)25 DocumentCondition (org.jnosql.diana.api.document.DocumentCondition)25 Arrays.asList (java.util.Arrays.asList)23 HashMap (java.util.HashMap)18 AtomicReference (java.util.concurrent.atomic.AtomicReference)12 Map (java.util.Map)11 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)11 TypeReference (org.jnosql.diana.api.TypeReference)11 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 Matchers.contains (org.hamcrest.Matchers.contains)10 DocumentQueryBuilder.select (org.jnosql.diana.api.document.query.DocumentQueryBuilder.select)10 Arrays (java.util.Arrays)8 Optional (java.util.Optional)8 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)8