Search in sources :

Example 1 with HasTyperefInfo

use of com.linkedin.data.template.HasTyperefInfo in project rest.li by linkedin.

the class TestTyperefUnion method testNonTyperefUnion.

@Test
public void testNonTyperefUnion() {
    TyperefInfo typerefInfo = DataTemplateUtil.getTyperefInfo(TestRecordAndUnionTemplate.Foo.Union.class);
    assertNull(typerefInfo);
    TestRecordAndUnionTemplate.Foo.Union union = new TestRecordAndUnionTemplate.Foo.Union();
    assertFalse(union instanceof HasTyperefInfo);
}
Also used : HasTyperefInfo(com.linkedin.data.template.HasTyperefInfo) TestRecordAndUnionTemplate(com.linkedin.data.template.TestRecordAndUnionTemplate) TyperefInfo(com.linkedin.data.template.TyperefInfo) HasTyperefInfo(com.linkedin.data.template.HasTyperefInfo) Test(org.testng.annotations.Test)

Example 2 with HasTyperefInfo

use of com.linkedin.data.template.HasTyperefInfo in project rest.li by linkedin.

the class TestTyperefUnion method testTyperefUnion.

@Test
public void testTyperefUnion() {
    TyperefInfo typerefInfo = DataTemplateUtil.getTyperefInfo(Union.class);
    assertNotNull(typerefInfo);
    TyperefDataSchema typerefDataSchema = typerefInfo.getSchema();
    Union union = new Union();
    assertTrue(union instanceof HasTyperefInfo);
    TyperefInfo typerefInfoFromInstance = union.typerefInfo();
    assertNotNull(typerefInfoFromInstance);
    TyperefDataSchema typerefDataSchemaFromInstance = typerefInfo.getSchema();
    assertSame(typerefDataSchemaFromInstance, typerefDataSchema);
    assertSame(typerefInfoFromInstance, typerefInfo);
    assertEquals(typerefDataSchema.getFullName(), Union.class.getName());
    assertEquals(typerefDataSchema.getRef(), DataTemplateUtil.getSchema(Union.class));
}
Also used : TyperefDataSchema(com.linkedin.data.schema.TyperefDataSchema) HasTyperefInfo(com.linkedin.data.template.HasTyperefInfo) TyperefInfo(com.linkedin.data.template.TyperefInfo) HasTyperefInfo(com.linkedin.data.template.HasTyperefInfo) Test(org.testng.annotations.Test)

Aggregations

HasTyperefInfo (com.linkedin.data.template.HasTyperefInfo)2 TyperefInfo (com.linkedin.data.template.TyperefInfo)2 Test (org.testng.annotations.Test)2 TyperefDataSchema (com.linkedin.data.schema.TyperefDataSchema)1 TestRecordAndUnionTemplate (com.linkedin.data.template.TestRecordAndUnionTemplate)1