Search in sources :

Example 6 with InfinispanConnection

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());
}
Also used : QueryParser(org.teiid.query.parser.QueryParser) MetadataFactory(org.teiid.metadata.MetadataFactory) BasicCache(org.infinispan.commons.api.BasicCache) InfinispanConnection(org.teiid.infinispan.api.InfinispanConnection) FileReader(java.io.FileReader) ProtobufResource(org.teiid.infinispan.api.ProtobufResource) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

InfinispanConnection (org.teiid.infinispan.api.InfinispanConnection)6 Test (org.junit.Test)5 ProtobufResource (org.teiid.infinispan.api.ProtobufResource)4 MetadataFactory (org.teiid.metadata.MetadataFactory)4 BasicCache (org.infinispan.commons.api.BasicCache)3 BigInteger (java.math.BigInteger)2 Command (org.teiid.language.Command)2 QueryExpression (org.teiid.language.QueryExpression)2 ResultSetExecution (org.teiid.translator.ResultSetExecution)2 UpdateExecution (org.teiid.translator.UpdateExecution)2 FileReader (java.io.FileReader)1 BigDecimal (java.math.BigDecimal)1 Clob (java.sql.Clob)1 Date (java.sql.Date)1 SQLXML (java.sql.SQLXML)1 Time (java.sql.Time)1 Timestamp (java.sql.Timestamp)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Properties (java.util.Properties)1 BeforeClass (org.junit.BeforeClass)1