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);
}
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);
}
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());
}
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());
}
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);
}
Aggregations