Search in sources :

Example 71 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class DefaultSelectQueryBuilderTest method shouldExecuteManager.

@Test
public void shouldExecuteManager() {
    ColumnFamilyManager manager = Mockito.mock(ColumnFamilyManager.class);
    ArgumentCaptor<ColumnQuery> queryCaptor = ArgumentCaptor.forClass(ColumnQuery.class);
    String columnFamily = "columnFamily";
    Stream<ColumnEntity> entities = select().from(columnFamily).getResult(manager);
    entities.collect(Collectors.toList());
    Mockito.verify(manager).select(queryCaptor.capture());
    checkQuery(queryCaptor, columnFamily);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Test(org.junit.jupiter.api.Test)

Example 72 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class InsertQueryParserTest method shouldReturnParserQuery4.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\") 10 minute" })
public void shouldReturnParserQuery4(String query) {
    ArgumentCaptor<ColumnEntity> captor = ArgumentCaptor.forClass(ColumnEntity.class);
    ArgumentCaptor<Duration> durationCaptor = ArgumentCaptor.forClass(Duration.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).insert(captor.capture(), durationCaptor.capture());
    ColumnEntity entity = captor.getValue();
    Duration duration = durationCaptor.getValue();
    assertEquals("God", entity.getName());
    assertEquals(Column.of("name", "Diana"), entity.find("name").get());
    assertEquals(Duration.ofMinutes(10L), duration);
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Duration(java.time.Duration) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class InsertQueryParserTest method shouldReturnParserQuery2.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\") 10 day" })
public void shouldReturnParserQuery2(String query) {
    ArgumentCaptor<ColumnEntity> captor = ArgumentCaptor.forClass(ColumnEntity.class);
    ArgumentCaptor<Duration> durationCaptor = ArgumentCaptor.forClass(Duration.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).insert(captor.capture(), durationCaptor.capture());
    ColumnEntity entity = captor.getValue();
    Duration duration = durationCaptor.getValue();
    assertEquals("God", entity.getName());
    assertEquals(Column.of("name", "Diana"), entity.find("name").get());
    assertEquals(Duration.ofDays(10L), duration);
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Duration(java.time.Duration) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 74 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class InsertQueryParserTest method shouldReturnParserQuery.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\")" })
public void shouldReturnParserQuery(String query) {
    ArgumentCaptor<ColumnEntity> captor = ArgumentCaptor.forClass(ColumnEntity.class);
    parser.query(query, manager, observer);
    Mockito.verify(manager).insert(captor.capture());
    ColumnEntity entity = captor.getValue();
    assertEquals("God", entity.getName());
    assertEquals(Column.of("name", "Diana"), entity.find("name").get());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 75 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class ColumnEntityTest method shouldFindColumn.

@Test
public void shouldFindColumn() {
    Column column = Column.of("name", "name");
    ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
    Optional<Column> name = entity.find("name");
    Optional<Column> notfound = entity.find("not_found");
    assertTrue(name.isPresent());
    assertFalse(notfound.isPresent());
    assertEquals(column, name.get());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnEntity (jakarta.nosql.column.ColumnEntity)146 Test (org.junit.jupiter.api.Test)103 Column (jakarta.nosql.column.Column)39 ColumnQuery (jakarta.nosql.column.ColumnQuery)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 ValueSource (org.junit.jupiter.params.provider.ValueSource)23 Duration (java.time.Duration)13 ArrayList (java.util.ArrayList)13 List (java.util.List)13 Arrays.asList (java.util.Arrays.asList)11 Person (jakarta.nosql.tck.entities.Person)9 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 Value (jakarta.nosql.Value)6 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)6 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)5 Actor (jakarta.nosql.tck.entities.Actor)5 Director (jakarta.nosql.tck.entities.Director)5 Movie (jakarta.nosql.tck.entities.Movie)5