use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameGt.
@Test
public void shouldSelectWhereNameGt() {
String documentCollection = "documentCollection";
Number value = 10;
DocumentDeleteQuery query = delete().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());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameEq.
@Test
public void shouldSelectWhereNameEq() {
String documentCollection = "documentCollection";
String name = "Ada Lovelace";
DocumentDeleteQuery query = delete().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());
}
use of jakarta.nosql.document.DocumentDeleteQuery 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());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery15.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God where age between 10 and 30" })
public void shouldReturnParserQuery15(String query) {
ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).delete(captor.capture());
DocumentDeleteQuery documentQuery = captor.getValue();
checkBaseQuery(documentQuery);
assertTrue(documentQuery.getCondition().isPresent());
DocumentCondition condition = documentQuery.getCondition().get();
assertEquals(Condition.BETWEEN, condition.getCondition());
assertEquals(Document.of("age", Arrays.asList(10L, 30L)), condition.getDocument());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParserTest method shouldReturnParserQuery.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete from God" })
public void shouldReturnParserQuery(String query) {
ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
parser.query(query, documentCollection, observer);
Mockito.verify(documentCollection).delete(captor.capture());
DocumentDeleteQuery documentQuery = captor.getValue();
assertTrue(documentQuery.getDocuments().isEmpty());
assertEquals("God", documentQuery.getDocumentCollection());
assertFalse(documentQuery.getCondition().isPresent());
}
Aggregations