Search in sources :

Example 16 with ColumnEntity

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

the class InsertQueryParserTest method shouldReturnParserQuery6.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\") 10 millisecond" })
public void shouldReturnParserQuery6(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.ofMillis(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 17 with ColumnEntity

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

the class UpdateQueryParser method prepare.

ColumnPreparedStatement prepare(String query, ColumnFamilyManager manager, ColumnObserverParser observer) {
    Params params = Params.newParams();
    UpdateQuery updateQuery = updateQueryProvider.apply(query);
    ColumnEntity entity = getEntity(params, updateQuery, observer);
    return DefaultColumnPreparedStatement.update(entity, params, query, manager);
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Params(jakarta.nosql.Params) UpdateQuery(jakarta.nosql.query.UpdateQuery)

Example 18 with ColumnEntity

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

the class ColumnEntityTest method shouldCreateANewInstance.

@Test
public void shouldCreateANewInstance() {
    String name = "name";
    ColumnEntity entity = new DefaultColumnEntity(name);
    assertEquals(name, entity.getName());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 19 with ColumnEntity

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

the class ColumnEntityTest method shouldRemoveAllElementsWhenUseClearMethod.

@Test
public void shouldRemoveAllElementsWhenUseClearMethod() {
    List<Column> columns = asList(Column.of("name", 10), Column.of("name2", 11), Column.of("name3", 12), Column.of("name4", 13), Column.of("name5", 14), Column.of("name5", 16));
    ColumnEntity columnFamily = ColumnEntity.of("columnFamily", columns);
    assertFalse(columnFamily.isEmpty());
    columnFamily.clear();
    assertTrue(columnFamily.isEmpty());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 20 with ColumnEntity

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

the class InsertQueryParser method prepare.

ColumnPreparedStatement prepare(String query, ColumnFamilyManager manager, ColumnObserverParser observer) {
    InsertQuery insertQuery = insertQueryProvider.apply(query);
    String columnFamily = observer.fireEntity(insertQuery.getEntity());
    Params params = Params.newParams();
    Optional<Duration> ttl = insertQuery.getTtl();
    ColumnEntity entity = getEntity(insertQuery, columnFamily, params, observer);
    return DefaultColumnPreparedStatement.insert(entity, params, query, ttl.orElse(null), manager);
}
Also used : InsertQuery(jakarta.nosql.query.InsertQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Params(jakarta.nosql.Params) Duration(java.time.Duration)

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