Search in sources :

Example 1 with TestObjectWithPrivateConstructor

use of org.apache.ignite.internal.schema.testobjects.TestObjectWithPrivateConstructor in project ignite-3 by apache.

the class RecordMarshallerTest method classWithPrivateConstructor.

@ParameterizedTest
@MethodSource("marshallerFactoryProvider")
public void classWithPrivateConstructor(MarshallerFactory factory) throws MarshallerException, IllegalAccessException {
    SchemaDescriptor schema = new SchemaDescriptor(1, new Column[] { new Column("primLongCol".toUpperCase(), INT64, false) }, new Column[] { new Column("primIntCol".toUpperCase(), INT32, false) });
    RecordMarshaller<TestObjectWithPrivateConstructor> marshaller = factory.create(schema, TestObjectWithPrivateConstructor.class);
    final TestObjectWithPrivateConstructor rec = TestObjectWithPrivateConstructor.randomObject(rnd);
    BinaryRow row = marshaller.marshal(rec);
    TestObjectWithPrivateConstructor restoredRec = marshaller.unmarshal(new Row(schema, row));
    assertDeepEquals(TestObjectWithPrivateConstructor.class, rec, restoredRec);
}
Also used : SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) Column(org.apache.ignite.internal.schema.Column) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) Row(org.apache.ignite.internal.schema.row.Row) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) TestObjectWithPrivateConstructor(org.apache.ignite.internal.schema.testobjects.TestObjectWithPrivateConstructor) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with TestObjectWithPrivateConstructor

use of org.apache.ignite.internal.schema.testobjects.TestObjectWithPrivateConstructor in project ignite-3 by apache.

the class KvMarshallerTest method classWithPrivateConstructor.

@ParameterizedTest
@MethodSource("marshallerFactoryProvider")
public void classWithPrivateConstructor(MarshallerFactory factory) throws MarshallerException {
    Column[] cols = new Column[] { new Column("primLongCol".toUpperCase(), INT64, false), new Column("primIntCol".toUpperCase(), INT32, false) };
    SchemaDescriptor schema = new SchemaDescriptor(1, cols, cols);
    KvMarshaller<TestObjectWithPrivateConstructor, TestObjectWithPrivateConstructor> marshaller = factory.create(schema, TestObjectWithPrivateConstructor.class, TestObjectWithPrivateConstructor.class);
    final TestObjectWithPrivateConstructor key = TestObjectWithPrivateConstructor.randomObject(rnd);
    final TestObjectWithPrivateConstructor val = TestObjectWithPrivateConstructor.randomObject(rnd);
    BinaryRow row = marshaller.marshal(key, val);
    Object key1 = marshaller.unmarshalKey(new Row(schema, row));
    Object val1 = marshaller.unmarshalValue(new Row(schema, row));
    assertTrue(key.getClass().isInstance(key1));
    assertTrue(val.getClass().isInstance(val1));
    assertEquals(key, key);
    assertEquals(val, val1);
}
Also used : SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) Column(org.apache.ignite.internal.schema.Column) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) Row(org.apache.ignite.internal.schema.row.Row) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) TestObjectWithPrivateConstructor(org.apache.ignite.internal.schema.testobjects.TestObjectWithPrivateConstructor) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

BinaryRow (org.apache.ignite.internal.schema.BinaryRow)2 Column (org.apache.ignite.internal.schema.Column)2 SchemaDescriptor (org.apache.ignite.internal.schema.SchemaDescriptor)2 Row (org.apache.ignite.internal.schema.row.Row)2 TestObjectWithPrivateConstructor (org.apache.ignite.internal.schema.testobjects.TestObjectWithPrivateConstructor)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2