Search in sources :

Example 51 with ColumnQuery

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

the class SelectQueryParserTest method shouldReturnParserQuery13.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "select  * from God where stamina <= -10.23" })
public void shouldReturnParserQuery13(String query) {
    ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).select(captor.capture());
    ColumnQuery columnQuery = captor.getValue();
    checkBaseQuery(columnQuery, 0L, 0L);
    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 : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnCondition(jakarta.nosql.column.ColumnCondition) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 52 with ColumnQuery

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

the class DefaultColumnTemplateTest method shouldSelect.

@Test
public void shouldSelect() {
    ColumnQuery query = select().from("person").build();
    subject.select(query);
    verify(managerMock).select(query);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 53 with ColumnQuery

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

the class DefaultColumnTemplateTest method shouldReturnSingleResult.

@Test
public void shouldReturnSingleResult() {
    ColumnEntity columnEntity = ColumnEntity.of("Person");
    columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
    Mockito.when(managerMock.select(any(ColumnQuery.class))).thenReturn(Stream.of(columnEntity));
    ColumnQuery query = select().from("person").build();
    Optional<Person> result = subject.singleResult(query);
    assertTrue(result.isPresent());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 54 with ColumnQuery

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

the class DefaultColumnTemplateTest method shouldConvertEntity.

@Test
public void shouldConvertEntity() {
    Stream<Movie> movies = subject.query("select * from Movie");
    ArgumentCaptor<ColumnQuery> queryCaptor = ArgumentCaptor.forClass(ColumnQuery.class);
    verify(managerMock).select(queryCaptor.capture());
    ColumnQuery query = queryCaptor.getValue();
    assertEquals("movie", query.getColumnFamily());
}
Also used : Movie(jakarta.nosql.tck.entities.Movie) ColumnQuery(jakarta.nosql.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 55 with ColumnQuery

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

the class DefaultColumnTemplateTest method shouldReturnFind.

@Test
public void shouldReturnFind() {
    subject.find(Person.class, "10");
    ArgumentCaptor<ColumnQuery> queryCaptor = ArgumentCaptor.forClass(ColumnQuery.class);
    verify(managerMock).select(queryCaptor.capture());
    ColumnQuery query = queryCaptor.getValue();
    ColumnCondition condition = query.getCondition().get();
    assertEquals("Person", query.getColumnFamily());
    assertEquals(ColumnCondition.eq(Column.of("_id", 10L)), condition);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnQuery (jakarta.nosql.column.ColumnQuery)160 Test (org.junit.jupiter.api.Test)120 ColumnCondition (jakarta.nosql.column.ColumnCondition)64 Person (jakarta.nosql.tck.entities.Person)50 Column (jakarta.nosql.column.Column)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)30 ValueSource (org.junit.jupiter.params.provider.ValueSource)30 Pagination (jakarta.nosql.mapping.Pagination)27 ColumnEntity (jakarta.nosql.column.ColumnEntity)26 List (java.util.List)26 Collections.singletonList (java.util.Collections.singletonList)10 Value (jakarta.nosql.Value)8 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)8 Arrays.asList (java.util.Arrays.asList)8 Params (jakarta.nosql.Params)7 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)7 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)7 ColumnQueryParams (jakarta.nosql.column.ColumnQueryParams)7 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)6 SelectQuery (jakarta.nosql.query.SelectQuery)6