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());
}
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();
}
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());
}
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());
}
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());
}
Aggregations