Search in sources :

Example 86 with ColumnQuery

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

the class ColumnQueryParserTest method shouldFindByNameAndAge.

@Test
public void shouldFindByNameAndAge() {
    ColumnQuery query = parser.parse("findByNameAndAge", new Object[] { "name", 10 }, classRepresentation, converters);
    ColumnCondition condition = query.getCondition().get();
    assertEquals("Person", query.getColumnFamily());
    assertEquals(Condition.AND, condition.getCondition());
    List<ColumnCondition> conditions = condition.getColumn().get(new TypeReference<List<ColumnCondition>>() {
    });
    ColumnCondition condition1 = conditions.get(0);
    assertEquals(Condition.EQUALS, condition1.getCondition());
    assertEquals(Column.of("name", "name"), condition1.getColumn());
    ColumnCondition condition2 = conditions.get(1);
    assertEquals(Condition.EQUALS, condition2.getCondition());
    assertEquals(Column.of("age", 10), condition2.getColumn());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) List(java.util.List) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 87 with ColumnQuery

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

the class ColumnQueryParserTest method shouldFindByNameLikeOrderByName.

@Test
public void shouldFindByNameLikeOrderByName() {
    ColumnQuery query = parser.parse("findByNameLikeOrderByName", 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)

Example 88 with ColumnQuery

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

the class ColumnQueryParserTest method shouldFindByNameLikeOrderByNameDesc.

@Test
public void shouldFindByNameLikeOrderByNameDesc() {
    ColumnQuery query = parser.parse("findByNameLikeOrderByNameDesc", 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.DESC), query.getSorts().get(0));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 89 with ColumnQuery

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

the class ColumnQueryParserTest method shouldFindByNameAndAAgeBetween.

@Test
public void shouldFindByNameAndAAgeBetween() {
    ColumnQuery query = parser.parse("findByNameAndAgeBetween", new Object[] { "name", 10, 11 }, classRepresentation, converters);
    assertEquals("Person", query.getColumnFamily());
    ColumnCondition condition = query.getCondition().get();
    assertEquals(Condition.AND, condition.getCondition());
    List<ColumnCondition> conditions = condition.getColumn().get(new TypeReference<List<ColumnCondition>>() {
    });
    ColumnCondition condition1 = conditions.get(0);
    assertEquals(Condition.EQUALS, condition1.getCondition());
    assertEquals(Column.of("name", "name"), condition1.getColumn());
    ColumnCondition condition2 = conditions.get(1);
    assertEquals(Condition.BETWEEN, condition2.getCondition());
    assertEquals(Column.of("age", Arrays.asList(10, 11)), condition2.getColumn());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) List(java.util.List) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 90 with ColumnQuery

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

the class ColumnQueryParserTest method shouldFindByName.

@Test
public void shouldFindByName() {
    ColumnQuery query = parser.parse("findByName", new Object[] { "name" }, classRepresentation, converters);
    assertEquals("Person", query.getColumnFamily());
    assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
    assertEquals(Column.of("name", "name"), query.getCondition().get().getColumn());
}
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