Search in sources :

Example 1 with ColumnQuery.select

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

the class CassandraColumnFamilyManagerTest method shouldCreateUDTWithSet.

@Test
public void shouldCreateUDTWithSet() {
    ColumnEntity entity = createEntityWithIterableSet();
    entityManager.insert(entity);
    ColumnQuery query = ColumnQuery.select().from("agenda").build();
    final ColumnEntity result = entityManager.singleResult(query).get();
    Assert.assertEquals(Column.of("user", "otaviojava"), result.find("user").get());
    Assert.assertEquals(2, result.size());
    List<List<Column>> names = (List<List<Column>>) result.find("names").get().get();
    assertEquals(3, names.size());
    assertTrue(names.stream().allMatch(n -> n.size() == 2));
}
Also used : NonUniqueResultException(jakarta.nosql.NonUniqueResultException) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) ColumnDeleteQuery.delete(jakarta.nosql.column.ColumnDeleteQuery.delete) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Arrays.asList(java.util.Arrays.asList) Duration(java.time.Duration) Map(java.util.Map) ConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel) Thread.sleep(java.lang.Thread.sleep) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Columns(jakarta.nosql.column.Columns) ColumnEntity(jakarta.nosql.column.ColumnEntity) Month(java.time.Month) Matchers(org.hamcrest.Matchers) ColumnQuery.select(jakarta.nosql.column.ColumnQuery.select) Instant(java.time.Instant) ZoneId(java.time.ZoneId) Test(org.junit.jupiter.api.Test) Value(jakarta.nosql.Value) AfterEach(org.junit.jupiter.api.AfterEach) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Column(jakarta.nosql.column.Column) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) LocalDate(java.time.LocalDate) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) ColumnQuery(jakarta.nosql.column.ColumnQuery) Assert(org.junit.Assert) ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Test(org.junit.jupiter.api.Test)

Aggregations

ConsistencyLevel (com.datastax.oss.driver.api.core.ConsistencyLevel)1 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 NonUniqueResultException (jakarta.nosql.NonUniqueResultException)1 Value (jakarta.nosql.Value)1 Column (jakarta.nosql.column.Column)1 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)1 ColumnDeleteQuery.delete (jakarta.nosql.column.ColumnDeleteQuery.delete)1 ColumnEntity (jakarta.nosql.column.ColumnEntity)1 ColumnQuery (jakarta.nosql.column.ColumnQuery)1 ColumnQuery.select (jakarta.nosql.column.ColumnQuery.select)1 Columns (jakarta.nosql.column.Columns)1 Thread.sleep (java.lang.Thread.sleep)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Month (java.time.Month)1 ZoneId (java.time.ZoneId)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1