Search in sources :

Example 21 with ColumnDeleteQuery

use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.

the class DeleteQueryParserTest method shouldReturnParserQuery14.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete  from God where stamina < -10.23" })
public void shouldReturnParserQuery14(String query) {
    ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).delete(captor.capture());
    ColumnDeleteQuery columnQuery = captor.getValue();
    checkBaseQuery(columnQuery);
    assertTrue(columnQuery.getCondition().isPresent());
    ColumnCondition condition = columnQuery.getCondition().get();
    assertEquals(Condition.LESSER_THAN, condition.getCondition());
    assertEquals(Column.of("stamina", -10.23), condition.getColumn());
}
Also used : ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with ColumnDeleteQuery

use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.

the class DeleteQueryParserTest method shouldReturnParserQuery13.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete  from God where stamina <= -10.23" })
public void shouldReturnParserQuery13(String query) {
    ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).delete(captor.capture());
    ColumnDeleteQuery columnQuery = captor.getValue();
    checkBaseQuery(columnQuery);
    assertTrue(columnQuery.getCondition().isPresent());
    ColumnCondition condition = columnQuery.getCondition().get();
    assertEquals(Condition.LESSER_EQUALS_THAN, condition.getCondition());
    assertEquals(Column.of("stamina", -10.23), condition.getColumn());
}
Also used : ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with ColumnDeleteQuery

use of jakarta.nosql.column.ColumnDeleteQuery in project jnosql-diana by eclipse.

the class DeleteQueryParserTest method shouldReturnParserQuery26.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "delete  from God where name = \"Ada\" and age = 20 or" + " siblings = {\"apollo\": \"Brother\", \"Zeus\": \"Father\"} and birthday =" + " convert(\"2007-12-03\", java.time.LocalDate)" })
public void shouldReturnParserQuery26(String query) {
    ArgumentCaptor<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).delete(captor.capture());
    ColumnDeleteQuery columnQuery = captor.getValue();
    checkBaseQuery(columnQuery);
    assertTrue(columnQuery.getCondition().isPresent());
    ColumnCondition condition = columnQuery.getCondition().get();
    Column column = condition.getColumn();
    assertEquals(Condition.AND, condition.getCondition());
    List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
    });
    assertEquals(Condition.EQUALS, conditions.get(0).getCondition());
    assertEquals(Condition.EQUALS, conditions.get(1).getCondition());
    assertEquals(Condition.OR, conditions.get(2).getCondition());
    assertEquals(Condition.EQUALS, conditions.get(3).getCondition());
}
Also used : Column(jakarta.nosql.column.Column) List(java.util.List) ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with ColumnDeleteQuery

use of jakarta.nosql.column.ColumnDeleteQuery 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<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).delete(captor.capture());
    ColumnDeleteQuery columnQuery = captor.getValue();
    checkBaseQuery(columnQuery);
    assertTrue(columnQuery.getCondition().isPresent());
    ColumnCondition condition = columnQuery.getCondition().get();
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals(Column.of("age", Arrays.asList(10L, 30L)), condition.getColumn());
}
Also used : ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with ColumnDeleteQuery

use of jakarta.nosql.column.ColumnDeleteQuery 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<ColumnDeleteQuery> captor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).delete(captor.capture());
    ColumnDeleteQuery columnQuery = captor.getValue();
    assertTrue(columnQuery.getColumns().isEmpty());
    assertEquals("God", columnQuery.getColumnFamily());
    assertFalse(columnQuery.getCondition().isPresent());
}
Also used : ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)70 Test (org.junit.jupiter.api.Test)41 ColumnCondition (jakarta.nosql.column.ColumnCondition)33 Column (jakarta.nosql.column.Column)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ValueSource (org.junit.jupiter.params.provider.ValueSource)20 Person (jakarta.nosql.tck.entities.Person)12 List (java.util.List)12 ColumnEntity (jakarta.nosql.column.ColumnEntity)6 Params (jakarta.nosql.Params)5 ColumnDeleteQueryParams (jakarta.nosql.column.ColumnDeleteQueryParams)5 ColumnQuery (jakarta.nosql.column.ColumnQuery)5 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)4 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)3 DeleteQuery (jakarta.nosql.query.DeleteQuery)3 Optional (java.util.Optional)3 QueryException (jakarta.nosql.QueryException)2 ServiceLoaderProvider (jakarta.nosql.ServiceLoaderProvider)2 ColumnObserverParser (jakarta.nosql.column.ColumnObserverParser)2 DeleteQueryConverter (jakarta.nosql.column.DeleteQueryConverter)2