Search in sources :

Example 16 with ResultSetExecution

use of org.teiid.translator.ResultSetExecution in project teiid by teiid.

the class TestODataQueryExecution method testReadComplexType.

@Test
public void testReadComplexType() throws Exception {
    String query = "select pa.People_UserName, pa.Address from People_AddressInfo pa ";
    String expectedURL = "People?$select=UserName,AddressInfo";
    FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("people.json"));
    ResultSetExecution excution = helpExecute(TestODataMetadataProcessor.tripPinMetadata(), query, ObjectConverterUtil.convertToString(reader), expectedURL);
    reader.close();
    assertArrayEquals(new Object[] { "russellwhyte", "187 Suffolk Ln." }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "scottketchum", "2817 Milton Dr." }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "javieralfred", "89 Jefferson Way Suite 2" }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "vincentcalabrese", "55 Grizzly Peak Rd." }, excution.next().toArray(new Object[2]));
    assertNull(excution.next());
}
Also used : ResultSetExecution(org.teiid.translator.ResultSetExecution) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 17 with ResultSetExecution

use of org.teiid.translator.ResultSetExecution in project teiid by teiid.

the class TestODataQueryExecution method testGeometry.

@Test
public void testGeometry() throws Exception {
    String query = "SELECT * FROM Airports_Location";
    String expectedURL = "Airports?$select=IcaoCode,Location";
    FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("airport-locations.json"));
    MetadataFactory mf = TestODataMetadataProcessor.tripPinMetadata();
    ResultSetExecution execution = helpExecute(TestODataMetadataProcessor.tripPinMetadata(), query, ObjectConverterUtil.convertToString(reader), expectedURL);
    List<?> row = execution.next();
    assertEquals("187 Suffolk Ln.", row.get(2));
    assertEquals("xyz", row.get(0));
    GeometryInputSource gis = (GeometryInputSource) row.get(1);
    assertEquals("<gml:Point><gml:pos>-48.23456 20.12345</gml:pos></gml:Point>", ObjectConverterUtil.convertToString(gis.getGml()));
    assertEquals(4326, gis.getSrid().intValue());
    row = execution.next();
    assertEquals("gso", row.get(0));
    gis = (GeometryInputSource) row.get(1);
    assertEquals("<gml:Point><gml:pos>1.0 2.0</gml:pos></gml:Point>", ObjectConverterUtil.convertToString(gis.getGml()));
    assertNull(execution.next());
    reader.close();
}
Also used : ResultSetExecution(org.teiid.translator.ResultSetExecution) MetadataFactory(org.teiid.metadata.MetadataFactory) GeometryInputSource(org.teiid.GeometryInputSource) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 18 with ResultSetExecution

use of org.teiid.translator.ResultSetExecution in project teiid by teiid.

the class TestODataQueryExecution method testComplexType_InnerJoin_3way_decendentChildren.

@Test
public void testComplexType_InnerJoin_3way_decendentChildren() throws Exception {
    String query = "select p.UserName, pa.Address, pc.Name from People p JOIN People_AddressInfo pa " + "ON p.UserName = pa.People_UserName JOIN People_AddressInfo_City pc " + "ON p.UserName = pc.People_UserName";
    String expectedURL = "People?$select=UserName,AddressInfo,AddressInfo/City";
    FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("people.json"));
    ResultSetExecution excution = helpExecute(TestODataMetadataProcessor.tripPinMetadata(), query, ObjectConverterUtil.convertToString(reader), expectedURL);
    reader.close();
    assertArrayEquals(new Object[] { "russellwhyte", "187 Suffolk Ln.", "Boise" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "scottketchum", "2817 Milton Dr.", "Albuquerque" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "javieralfred", "89 Jefferson Way Suite 2", "Portland" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "vincentcalabrese", "55 Grizzly Peak Rd.", "Butte" }, excution.next().toArray(new Object[3]));
    assertNull(excution.next());
}
Also used : ResultSetExecution(org.teiid.translator.ResultSetExecution) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 19 with ResultSetExecution

use of org.teiid.translator.ResultSetExecution in project teiid by teiid.

the class TestODataQueryExecution method testComplexType_LeftOuterJoin.

@Test
public void testComplexType_LeftOuterJoin() throws Exception {
    String query = "select p.UserName, pa.Address from People p LEFT JOIN People_AddressInfo pa " + "ON p.UserName = pa.People_UserName";
    String expectedURL = "People?$select=UserName,AddressInfo";
    FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("people.json"));
    ResultSetExecution excution = helpExecute(TestODataMetadataProcessor.tripPinMetadata(), query, ObjectConverterUtil.convertToString(reader), expectedURL);
    reader.close();
    assertArrayEquals(new Object[] { "russellwhyte", "187 Suffolk Ln." }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "scottketchum", "2817 Milton Dr." }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "ronaldmundy", null }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "javieralfred", "89 Jefferson Way Suite 2" }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "willieashmore", null }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "vincentcalabrese", "55 Grizzly Peak Rd." }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "clydeguess", null }, excution.next().toArray(new Object[2]));
    assertArrayEquals(new Object[] { "keithpinckney", null }, excution.next().toArray(new Object[2]));
    assertNull(excution.next());
}
Also used : ResultSetExecution(org.teiid.translator.ResultSetExecution) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 20 with ResultSetExecution

use of org.teiid.translator.ResultSetExecution in project teiid by teiid.

the class TestODataQueryExecution method testComplexType_3Way_MIXEDJoin_Sibiling.

@Test
public void testComplexType_3Way_MIXEDJoin_Sibiling() throws Exception {
    String query = "select p.UserName, pa.Address, pf.UserName from People p " + "LEFT OUTER JOIN People_AddressInfo pa " + "ON p.UserName = pa.People_UserName " + "INNER JOIN People_Friends pf " + "ON p.UserName = pf.People_UserName";
    String expectedURL = "People?$select=UserName,AddressInfo&$expand=Friends($select=UserName)";
    FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("people-friends.json"));
    ResultSetExecution excution = helpExecute(TestODataMetadataProcessor.tripPinMetadata(), query, ObjectConverterUtil.convertToString(reader), expectedURL);
    reader.close();
    assertArrayEquals(new Object[] { "russellwhyte", "187 Suffolk Ln.", "scottketchum" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "russellwhyte", "187 Suffolk Ln.", "ronaldmundy" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "russellwhyte", "187 Suffolk Ln.", "javieralfred" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "russellwhyte", "187 Suffolk Ln.", "angelhuffman" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "scottketchum", "2817 Milton Dr.", "russellwhyte" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "scottketchum", "2817 Milton Dr.", "ronaldmundy" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "ronaldmundy", null, "russellwhyte" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "ronaldmundy", null, "scottketchum" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "javieralfred", "89 Jefferson Way Suite 2", "willieashmore" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "javieralfred", "89 Jefferson Way Suite 2", "vincentcalabrese" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "javieralfred", "89 Jefferson Way Suite 2", "georginabarlow" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "willieashmore", null, "javieralfred" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "willieashmore", null, "vincentcalabrese" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "clydeguess", null, "keithpinckney" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "clydeguess", null, "ursulabright" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "keithpinckney", null, "clydeguess" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "keithpinckney", null, "marshallgaray" }, excution.next().toArray(new Object[3]));
    assertNull(excution.next());
    assertNull(excution.next());
}
Also used : ResultSetExecution(org.teiid.translator.ResultSetExecution) FileReader(java.io.FileReader) Test(org.junit.Test)

Aggregations

ResultSetExecution (org.teiid.translator.ResultSetExecution)50 Test (org.junit.Test)41 ExecutionContext (org.teiid.translator.ExecutionContext)22 FileReader (java.io.FileReader)19 Command (org.teiid.language.Command)17 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)15 QueryExpression (org.teiid.language.QueryExpression)12 List (java.util.List)11 ArrayList (java.util.ArrayList)10 TranslatorException (org.teiid.translator.TranslatorException)10 ExecutionFactory (org.teiid.translator.ExecutionFactory)8 TranslationUtility (org.teiid.cdk.api.TranslationUtility)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Connection (java.sql.Connection)4 ResultSet (java.sql.ResultSet)4 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)4 MongoDBConnection (org.teiid.mongodb.MongoDBConnection)4 DataNotAvailableException (org.teiid.translator.DataNotAvailableException)4 UpdateExecution (org.teiid.translator.UpdateExecution)4 DatabaseMetaData (java.sql.DatabaseMetaData)3