Search in sources :

Example 1 with TypeReference

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

the class DocumentTest method shouldReturnGetType.

@Test
public void shouldReturnGetType() {
    Value value = Value.of("text");
    Document document = Document.of("name", value);
    TypeReference<List<String>> typeReference = new TypeReference<List<String>>() {
    };
    assertEquals(value.get(typeReference), document.get(typeReference));
}
Also used : Value(org.jnosql.diana.api.Value) List(java.util.List) TypeReference(org.jnosql.diana.api.TypeReference) Test(org.junit.jupiter.api.Test)

Example 2 with TypeReference

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameBetween.

@Test
public void shouldSelectWhereNameBetween() {
    String documentCollection = "documentCollection";
    Number valueA = 10;
    Number valueB = 20;
    DocumentDeleteQuery query = delete().from(documentCollection).where("name").between(valueA, valueB).build();
    DocumentCondition condition = query.getCondition().get();
    Document document = condition.getDocument();
    assertTrue(query.getDocuments().isEmpty());
    assertEquals(documentCollection, query.getDocumentCollection());
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals("name", document.getName());
    assertThat(document.get(new TypeReference<List<Number>>() {
    }), Matchers.contains(10, 20));
}
Also used : TypeReference(org.jnosql.diana.api.TypeReference) Document(org.jnosql.diana.api.document.Document) DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 3 with TypeReference

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameBetween.

@Test
public void shouldSelectWhereNameBetween() {
    String columnFamily = "columnFamily";
    Number valueA = 10;
    Number valueB = 20;
    ColumnDeleteQuery query = delete().from(columnFamily).where("name").between(valueA, valueB).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals("name", column.getName());
    assertThat(column.get(new TypeReference<List<Number>>() {
    }), Matchers.contains(10, 20));
}
Also used : Column(org.jnosql.diana.api.column.Column) TypeReference(org.jnosql.diana.api.TypeReference) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) ColumnDeleteQuery(org.jnosql.diana.api.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 4 with TypeReference

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameBetween.

@Test
public void shouldSelectWhereNameBetween() {
    String columnFamily = "columnFamily";
    Number valueA = 10;
    Number valueB = 20;
    ColumnQuery query = select().from(columnFamily).where("name").between(valueA, valueB).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals("name", column.getName());
    assertThat(column.get(new TypeReference<List<Number>>() {
    }), Matchers.contains(10, 20));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) TypeReference(org.jnosql.diana.api.TypeReference) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 5 with TypeReference

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

the class ColumnTest method shouldReturnGetType.

@Test
public void shouldReturnGetType() {
    Value value = Value.of("text");
    Column column = Column.of("name", value);
    TypeReference<List<String>> typeReference = new TypeReference<List<String>>() {
    };
    assertEquals(value.get(typeReference), column.get(typeReference));
}
Also used : Value(org.jnosql.diana.api.Value) List(java.util.List) TypeReference(org.jnosql.diana.api.TypeReference) Test(org.junit.jupiter.api.Test)

Aggregations

TypeReference (org.jnosql.diana.api.TypeReference)7 Test (org.junit.jupiter.api.Test)7 List (java.util.List)3 Value (org.jnosql.diana.api.Value)3 Document (org.jnosql.diana.api.document.Document)3 Column (org.jnosql.diana.api.column.Column)2 ColumnCondition (org.jnosql.diana.api.column.ColumnCondition)2 DocumentCondition (org.jnosql.diana.api.document.DocumentCondition)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.singleton (java.util.Collections.singleton)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Stream (java.util.stream.Stream)1 Inject (javax.inject.Inject)1