Search in sources :

Example 1 with NestedBar

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar in project pulsar by apache.

the class JSONSchemaTest method testNotAllowNullNestedClasses.

@Test
public void testNotAllowNullNestedClasses() {
    JSONSchema<NestedBar> jsonSchema = JSONSchema.of(SchemaDefinition.<NestedBar>builder().withPojo(NestedBar.class).withAlwaysAllowNull(false).build());
    JSONSchema<NestedBarList> listJsonSchema = JSONSchema.of(SchemaDefinition.<NestedBarList>builder().withPojo(NestedBarList.class).withAlwaysAllowNull(false).build());
    Bar bar = new Bar();
    bar.setField1(true);
    NestedBar nested = new NestedBar();
    nested.setField1(true);
    nested.setNested(bar);
    byte[] bytes = jsonSchema.encode(nested);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(jsonSchema.decode(bytes), nested);
    List<Bar> list = Collections.singletonList(bar);
    NestedBarList nestedList = new NestedBarList();
    nestedList.setField1(true);
    nestedList.setList(list);
    bytes = listJsonSchema.encode(nestedList);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(listJsonSchema.decode(bytes), nestedList);
}
Also used : NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) Bar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.Bar) NestedBarList(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBarList) Test(org.testng.annotations.Test)

Example 2 with NestedBar

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar in project pulsar by yahoo.

the class JSONSchemaTest method testNotAllowNullNestedClasses.

@Test
public void testNotAllowNullNestedClasses() {
    JSONSchema<NestedBar> jsonSchema = JSONSchema.of(SchemaDefinition.<NestedBar>builder().withPojo(NestedBar.class).withAlwaysAllowNull(false).build());
    JSONSchema<NestedBarList> listJsonSchema = JSONSchema.of(SchemaDefinition.<NestedBarList>builder().withPojo(NestedBarList.class).withAlwaysAllowNull(false).build());
    Bar bar = new Bar();
    bar.setField1(true);
    NestedBar nested = new NestedBar();
    nested.setField1(true);
    nested.setNested(bar);
    byte[] bytes = jsonSchema.encode(nested);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(jsonSchema.decode(bytes), nested);
    List<Bar> list = Collections.singletonList(bar);
    NestedBarList nestedList = new NestedBarList();
    nestedList.setField1(true);
    nestedList.setList(list);
    bytes = listJsonSchema.encode(nestedList);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(listJsonSchema.decode(bytes), nestedList);
}
Also used : NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) Bar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.Bar) NestedBarList(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBarList) Test(org.testng.annotations.Test)

Example 3 with NestedBar

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar in project incubator-pulsar by apache.

the class JSONSchemaTest method testNotAllowNullNestedClasses.

@Test
public void testNotAllowNullNestedClasses() {
    JSONSchema<NestedBar> jsonSchema = JSONSchema.of(SchemaDefinition.<NestedBar>builder().withPojo(NestedBar.class).withAlwaysAllowNull(false).build());
    JSONSchema<NestedBarList> listJsonSchema = JSONSchema.of(SchemaDefinition.<NestedBarList>builder().withPojo(NestedBarList.class).withAlwaysAllowNull(false).build());
    Bar bar = new Bar();
    bar.setField1(true);
    NestedBar nested = new NestedBar();
    nested.setField1(true);
    nested.setNested(bar);
    byte[] bytes = jsonSchema.encode(nested);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(jsonSchema.decode(bytes), nested);
    List<Bar> list = Collections.singletonList(bar);
    NestedBarList nestedList = new NestedBarList();
    nestedList.setField1(true);
    nestedList.setList(list);
    bytes = listJsonSchema.encode(nestedList);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(listJsonSchema.decode(bytes), nestedList);
}
Also used : NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) Bar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.Bar) NestedBarList(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBarList) Test(org.testng.annotations.Test)

Example 4 with NestedBar

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar in project incubator-pulsar by apache.

the class JSONSchemaTest method testAllowNullNestedClasses.

@Test
public void testAllowNullNestedClasses() {
    JSONSchema<NestedBar> jsonSchema = JSONSchema.of(SchemaDefinition.<NestedBar>builder().withPojo(NestedBar.class).build());
    JSONSchema<NestedBarList> listJsonSchema = JSONSchema.of(SchemaDefinition.<NestedBarList>builder().withPojo(NestedBarList.class).build());
    Bar bar = new Bar();
    bar.setField1(true);
    NestedBar nested = new NestedBar();
    nested.setField1(true);
    nested.setNested(bar);
    byte[] bytes = jsonSchema.encode(nested);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(jsonSchema.decode(bytes), nested);
    List<Bar> list = Collections.singletonList(bar);
    NestedBarList nestedList = new NestedBarList();
    nestedList.setField1(true);
    nestedList.setList(list);
    bytes = listJsonSchema.encode(nestedList);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(listJsonSchema.decode(bytes), nestedList);
}
Also used : NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) Bar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.Bar) NestedBarList(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBarList) Test(org.testng.annotations.Test)

Example 5 with NestedBar

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar in project pulsar by apache.

the class JSONSchemaTest method testAllowNullNestedClasses.

@Test
public void testAllowNullNestedClasses() {
    JSONSchema<NestedBar> jsonSchema = JSONSchema.of(SchemaDefinition.<NestedBar>builder().withPojo(NestedBar.class).build());
    JSONSchema<NestedBarList> listJsonSchema = JSONSchema.of(SchemaDefinition.<NestedBarList>builder().withPojo(NestedBarList.class).build());
    Bar bar = new Bar();
    bar.setField1(true);
    NestedBar nested = new NestedBar();
    nested.setField1(true);
    nested.setNested(bar);
    byte[] bytes = jsonSchema.encode(nested);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(jsonSchema.decode(bytes), nested);
    List<Bar> list = Collections.singletonList(bar);
    NestedBarList nestedList = new NestedBarList();
    nestedList.setField1(true);
    nestedList.setList(list);
    bytes = listJsonSchema.encode(nestedList);
    Assert.assertTrue(bytes.length > 0);
    Assert.assertEquals(listJsonSchema.decode(bytes), nestedList);
}
Also used : NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) NestedBar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar) Bar(org.apache.pulsar.client.impl.schema.SchemaTestUtils.Bar) NestedBarList(org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBarList) Test(org.testng.annotations.Test)

Aggregations

Bar (org.apache.pulsar.client.impl.schema.SchemaTestUtils.Bar)6 NestedBar (org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBar)6 NestedBarList (org.apache.pulsar.client.impl.schema.SchemaTestUtils.NestedBarList)6 Test (org.testng.annotations.Test)6