Search in sources :

Example 61 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectOrderDesc.

@Test
public void shouldSelectOrderDesc() {
    String columnFamily = "columnFamily";
    ColumnQuery query = select().from(columnFamily).orderBy("name").desc().build();
    assertTrue(query.getColumns().isEmpty());
    assertFalse(query.getCondition().isPresent());
    assertEquals(columnFamily, query.getColumnFamily());
    assertThat(query.getSorts(), contains(Sort.of("name", DESC)));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 62 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameNot.

@Test
public void shouldSelectWhereNameNot() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnQuery query = select().from(columnFamily).where("name").not().eq(name).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    ColumnCondition negate = column.get(ColumnCondition.class);
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.NOT, condition.getCondition());
    assertEquals(Condition.EQUALS, negate.getCondition());
    assertEquals("name", negate.getColumn().getName());
    assertEquals(name, negate.getColumn().get());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 63 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectStart.

@Test
public void shouldSelectStart() {
    String columnFamily = "columnFamily";
    ColumnQuery query = select().from(columnFamily).start(10).build();
    assertTrue(query.getColumns().isEmpty());
    assertFalse(query.getCondition().isPresent());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(10L, query.getFirstResult());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 64 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLike.

@Test
public void shouldSelectWhereNameLike() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnQuery query = select().from(columnFamily).where("name").like(name).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LIKE, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(name, column.get());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 65 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLt.

@Test
public void shouldSelectWhereNameLt() {
    String columnFamily = "columnFamily";
    Number value = 10;
    ColumnQuery query = select().from(columnFamily).where("name").lt(value).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LESSER_THAN, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(value, column.get());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) 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