Search in sources :

Example 16 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.

the class ColumnQueryParserTest method shouldFindByAgeLessThan.

@Test
public void shouldFindByAgeLessThan() {
    ColumnQuery query = parser.parse("findByAgeLessThan", new Object[] { 10 }, classRepresentation, converters);
    assertEquals("Person", query.getColumnFamily());
    assertEquals(Condition.LESSER_THAN, query.getCondition().get().getCondition());
    assertEquals(Column.of("age", 10), query.getCondition().get().getColumn());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 17 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.

the class ColumnQueryParserTest method shouldFindByNameWithPageSortArgument.

@Test
public void shouldFindByNameWithPageSortArgument() {
    Pagination pagination = Pagination.of(2L, 10);
    Sort sort = Sort.of("age", Sort.SortType.ASC);
    ColumnQuery query = parser.parse("findByName", new Object[] { "name", pagination, sort }, classRepresentation, converters);
    assertEquals("Person", query.getColumnFamily());
    assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
    assertEquals(Column.of("name", "name"), query.getCondition().get().getColumn());
    assertEquals(pagination.getMaxResults(), query.getMaxResults());
    assertEquals(pagination.getFirstResult(), query.getFirstResult());
    assertEquals(sort, query.getSorts().get(0));
}
Also used : Pagination(org.jnosql.artemis.Pagination) ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Sort(org.jnosql.diana.api.Sort) Test(org.junit.jupiter.api.Test)

Example 18 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.

the class ColumnQueryParserTest method shouldFindByNameWithPageArgument.

@Test
public void shouldFindByNameWithPageArgument() {
    Pagination pagination = Pagination.of(2L, 10);
    ColumnQuery query = parser.parse("findByName", new Object[] { "name", pagination }, classRepresentation, converters);
    assertEquals("Person", query.getColumnFamily());
    assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
    assertEquals(Column.of("name", "name"), query.getCondition().get().getColumn());
    assertEquals(pagination.getMaxResults(), query.getMaxResults());
    assertEquals(pagination.getFirstResult(), query.getFirstResult());
}
Also used : Pagination(org.jnosql.artemis.Pagination) ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 19 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.

the class ColumnQueryParserTest method shouldFindByAgeGreaterThanEqual.

@Test
public void shouldFindByAgeGreaterThanEqual() {
    ColumnQuery query = parser.parse("findByAgeGreaterThanEqual", new Object[] { 10 }, classRepresentation, converters);
    assertEquals("Person", query.getColumnFamily());
    assertEquals(Condition.GREATER_EQUALS_THAN, query.getCondition().get().getCondition());
    assertEquals(Column.of("age", 10), query.getCondition().get().getColumn());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 20 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.

the class ColumnQueryParserTest method shouldFindByNameLikeOrderByNameAsc.

@Test
public void shouldFindByNameLikeOrderByNameAsc() {
    ColumnQuery query = parser.parse("findByNameLikeOrderByNameAsc", new Object[] { "name" }, classRepresentation, converters);
    assertEquals("Person", query.getColumnFamily());
    assertEquals(Condition.LIKE, query.getCondition().get().getCondition());
    assertEquals(Column.of("name", "name"), query.getCondition().get().getColumn());
    assertEquals(Sort.of("name", Sort.SortType.ASC), query.getSorts().get(0));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnQuery (org.jnosql.diana.api.column.ColumnQuery)117 Test (org.junit.jupiter.api.Test)113 Person (org.jnosql.artemis.model.Person)37 ColumnCondition (org.jnosql.diana.api.column.ColumnCondition)35 Column (org.jnosql.diana.api.column.Column)29 List (java.util.List)26 ColumnEntity (org.jnosql.diana.api.column.ColumnEntity)26 Collections.singletonList (java.util.Collections.singletonList)20 ColumnDeleteQuery (org.jnosql.diana.api.column.ColumnDeleteQuery)19 Arrays.asList (java.util.Arrays.asList)15 Duration (java.time.Duration)14 ColumnQueryBuilder.delete (org.jnosql.diana.api.column.query.ColumnQueryBuilder.delete)14 ColumnQueryBuilder.select (org.jnosql.diana.api.column.query.ColumnQueryBuilder.select)14 BeforeEach (org.junit.jupiter.api.BeforeEach)14 Optional (java.util.Optional)13 Consumer (java.util.function.Consumer)13 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)13 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)13 Inject (javax.inject.Inject)12 CDIExtension (org.jnosql.artemis.CDIExtension)12