Search in sources :

Example 76 with DocumentDeleteQuery

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

the class DocumentQueryDeleteParserTest method shouldDeleteByNameLike.

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

Example 77 with DocumentDeleteQuery

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

the class DocumentQueryDeleteParserTest method shouldDeleteByNameOrAge.

@Test
public void shouldDeleteByNameOrAge() {
    DocumentDeleteQuery query = parser.parse("deleteByNameOrAge", new Object[] { "name", 10 }, classRepresentation, converters);
    DocumentCondition condition = query.getCondition().get();
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(Condition.OR, condition.getCondition());
    List<DocumentCondition> conditions = condition.getDocument().get(new TypeReference<List<DocumentCondition>>() {
    });
    DocumentCondition condition1 = conditions.get(0);
    assertEquals(Condition.EQUALS, condition1.getCondition());
    assertEquals(Document.of("name", "name"), condition1.getDocument());
    DocumentCondition condition2 = conditions.get(1);
    assertEquals(Condition.EQUALS, condition2.getCondition());
    assertEquals(Document.of("age", 10), condition2.getDocument());
}
Also used : List(java.util.List) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 78 with DocumentDeleteQuery

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

the class DocumentQueryDeleteParserTest method shouldDeleteByAgeGreaterThanEqual.

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

Example 79 with DocumentDeleteQuery

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

the class DocumentQueryDeleteParserTest method shouldDeleteByNameAndAAgeBetween.

@Test
public void shouldDeleteByNameAndAAgeBetween() {
    DocumentDeleteQuery query = parser.parse("deleteByNameAndAgeBetween", new Object[] { "name", 10, 11 }, classRepresentation, converters);
    assertEquals("Person", query.getDocumentCollection());
    DocumentCondition condition = query.getCondition().get();
    assertEquals(Condition.AND, condition.getCondition());
    List<DocumentCondition> conditions = condition.getDocument().get(new TypeReference<List<DocumentCondition>>() {
    });
    DocumentCondition condition1 = conditions.get(0);
    assertEquals(Condition.EQUALS, condition1.getCondition());
    assertEquals(Document.of("name", "name"), condition1.getDocument());
    DocumentCondition condition2 = conditions.get(1);
    assertEquals(Condition.BETWEEN, condition2.getCondition());
    assertEquals(Document.of("age", Arrays.asList(10, 11)), condition2.getDocument());
}
Also used : List(java.util.List) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 80 with DocumentDeleteQuery

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

the class DocumentQueryDeleteParserTest method shouldDeleteByName.

@Test
public void shouldDeleteByName() {
    DocumentDeleteQuery query = parser.parse("deleteByName", 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 : DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentDeleteQuery (org.jnosql.diana.api.document.DocumentDeleteQuery)86 Test (org.junit.jupiter.api.Test)74 Document (org.jnosql.diana.api.document.Document)35 DocumentEntity (org.jnosql.diana.api.document.DocumentEntity)31 DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)31 DocumentCondition (org.jnosql.diana.api.document.DocumentCondition)20 List (java.util.List)15 Person (org.jnosql.artemis.model.Person)13 Duration (java.time.Duration)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 Optional (java.util.Optional)4 Consumer (java.util.function.Consumer)4 Collectors (java.util.stream.Collectors)4 DocumentQueryBuilder.delete (org.jnosql.diana.api.document.query.DocumentQueryBuilder.delete)4 DocumentQueryBuilder.select (org.jnosql.diana.api.document.query.DocumentQueryBuilder.select)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)4 Arrays (java.util.Arrays)3