use of org.apache.ignite.internal.schema.testobjects.TestSimpleObject in project ignite-3 by apache.
the class ColumnBindingTest method nullableFieldsBinding.
/**
* Nullable fields binding.
*
* @throws Exception If failed.
*/
@Test
public void nullableFieldsBinding() throws Exception {
Column[] cols = new Column[] { new Column("intCol", INT32, true), new Column("longCol", INT64, true), new Column("stringCol", STRING, true), new Column("bytesCol", BYTES, true) };
final Pair<RowAssembler, Row> mocks = createMocks();
final RowAssembler rowAssembler = mocks.getFirst();
final Row row = mocks.getSecond();
final TestSimpleObject obj = TestSimpleObject.randomObject(rnd);
for (int i = 0; i < cols.length; i++) {
ColumnBinding.createFieldBinding(cols[i].copy(i), TestSimpleObject.class, cols[i].name(), null).write(rowAssembler, obj);
}
final TestSimpleObject restoredObj = new TestSimpleObject();
for (int i = 0; i < cols.length; i++) {
ColumnBinding.createFieldBinding(cols[i].copy(i), TestSimpleObject.class, cols[i].name(), null).read(row, restoredObj);
}
assertEquals(obj, restoredObj);
}
use of org.apache.ignite.internal.schema.testobjects.TestSimpleObject in project ignite-3 by apache.
the class ColumnBindingTest method identityBindingWithConverter.
/**
* Identity binding with converter.
*
* @throws Exception If failed.
*/
@Test
public void identityBindingWithConverter() throws Exception {
final ColumnBinding binding = ColumnBinding.createIdentityBinding(new Column("val", BYTES, true).copy(0), TestSimpleObject.class, new SerializingConverter());
final Pair<RowAssembler, Row> mocks = createMocks();
final RowAssembler rowAssembler = mocks.getFirst();
final Row row = mocks.getSecond();
final TestSimpleObject obj = TestSimpleObject.randomObject(rnd);
binding.write(rowAssembler, obj);
Object restoredObj = binding.columnValue(row);
assertEquals(obj, restoredObj);
}
Aggregations