use of org.teiid.infinispan.api.InfinispanConnection in project teiid by teiid.
the class TestSchemaToProtobufProcessor method testSimpleNoMetadataConversion.
@Test
public void testSimpleNoMetadataConversion() throws Exception {
Properties props = new Properties();
MetadataFactory mf = new MetadataFactory("proto", 1, "model", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
mf.setParser(new QueryParser());
mf.parse(new FileReader(UnitTestUtil.getTestDataFile("tables_no_metadata.ddl")));
SchemaToProtobufProcessor tool = new SchemaToProtobufProcessor();
tool.setIndexMessages(true);
InfinispanConnection conn = Mockito.mock(InfinispanConnection.class);
BasicCache cache = Mockito.mock(BasicCache.class);
Mockito.stub(cache.getName()).toReturn("default");
Mockito.stub(conn.getCache()).toReturn(cache);
ProtobufResource resource = tool.process(mf, conn);
String expected = "package model;\n" + "\n" + "/* @Indexed */\n" + "message G1 {\n" + " /* @Id */\n" + " required int32 e1 = 1;\n" + " required string e2 = 2;\n" + " optional float e3 = 3;\n" + " repeated string e4 = 4;\n" + " repeated string e5 = 5;\n" + "}\n" + "\n" + "/* @Indexed */\n" + "message G2 {\n" + " /* @Id */\n" + " required int32 e1 = 1;\n" + " optional string e2 = 2;\n" + " optional bytes e5 = 3;\n" + " optional int64 e6 = 4;\n" + " repeated G4 g4 = 5;\n" + "}\n" + "\n" + "/* @Indexed */\n" + "message G4 {\n" + " required int32 e1 = 1;\n" + " required string e2 = 2;\n" + " optional double e3 = 3;\n" + " optional float e4 = 4;\n" + " /* @Teiid(type=short) */\n" + " optional int32 e5 = 5;\n" + " /* @Teiid(type=byte) */\n" + " optional int32 e6 = 6;\n" + " /* @Teiid(type=char, length=1) */\n" + " optional string e7 = 7;\n" + " optional int64 e8 = 8;\n" + " /* @Teiid(type=bigdecimal) */\n" + " optional string e9 = 9;\n" + " /* @Teiid(type=biginteger) */\n" + " optional string e10 = 10;\n" + " /* @Teiid(type=time) */\n" + " optional int64 e11 = 11;\n" + " /* @Teiid(type=timestamp) */\n" + " optional int64 e12 = 12;\n" + " /* @Teiid(type=date) */\n" + " optional int64 e13 = 13;\n" + " /* @Teiid(type=object) */\n" + " optional bytes e14 = 14;\n" + " /* @Teiid(type=blob) */\n" + " optional bytes e15 = 15;\n" + " /* @Teiid(type=clob) */\n" + " optional bytes e16 = 16;\n" + " /* @Teiid(type=xml) */\n" + " optional bytes e17 = 17;\n" + " /* @Teiid(type=geometry) */\n" + " optional bytes e18 = 18;\n" + "}\n\n";
assertEquals(expected, resource.getContents());
}
Aggregations