use of org.teiid.translator.ResultSetExecution in project teiid by teiid.
the class TestODataQueryExecution method testNoResults.
@Test
public void testNoResults() throws Exception {
String query = "SELECT * FROM Categories Where CategoryName = 'Beverages'";
String expectedURL = "Categories?$filter=CategoryName eq 'Beverages'&$select=CategoryID,CategoryName,Description,Picture";
FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("categories.xml"));
ResultSetExecution excution = helpExecute(query, ObjectConverterUtil.convertToString(reader), expectedURL, 404);
excution.execute();
assertNull(excution.next());
reader.close();
reader = new FileReader(UnitTestUtil.getTestDataFile("categories.xml"));
excution = helpExecute(query, ObjectConverterUtil.convertToString(reader), expectedURL, 204);
excution.execute();
assertNull(excution.next());
reader.close();
}
use of org.teiid.translator.ResultSetExecution in project teiid by teiid.
the class TestODataQueryExecution method testGeometryFilter.
@Test
public void testGeometryFilter() throws Exception {
String query = "SELECT Loc FROM Airports_Location where st_distance(Loc, st_geomfromtext('point(1 2)')) < 2";
String expectedURL = "Airports?$select=Location&$filter=geo.distance(Location/Loc,geometry'SRID=0;Point(1.0 2.0)') lt 2.0";
FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("airport-locations.json"));
ResultSetExecution execution = helpExecute(TestODataMetadataProcessor.tripPinMetadata(), query, ObjectConverterUtil.convertToString(reader), expectedURL);
// make sure the format is valid
EdmGeometryPoint.getInstance().valueOfString("geometry'SRID=0;Point(1.0 2.0)'", false, 4000, 0, 0, true, Point.class);
}
use of org.teiid.translator.ResultSetExecution in project teiid by teiid.
the class TestODataQueryExecution method testComplexType_InnerJoin.
@Test
public void testComplexType_InnerJoin() throws Exception {
String query = "select p.UserName, pa.Address from People p 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[] { "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 testComplexType_3Way_LeftOuterJoin.
@Test
public void testComplexType_3Way_LeftOuterJoin() 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 " + "LEFT OUTER 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]));
// extra row from test from above
assertArrayEquals(new Object[] { "vincentcalabrese", "55 Grizzly Peak Rd.", null }, 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());
}
use of org.teiid.translator.ResultSetExecution in project teiid by teiid.
the class TestODataQueryExecution method testComplexType_InnerJoin_3way_Sibiling.
@Test
public void testComplexType_InnerJoin_3way_Sibiling() throws Exception {
String query = "select p.UserName, pa.Address, pf.UserName from People p JOIN People_AddressInfo pa " + "ON p.UserName = pa.People_UserName 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[] { "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]));
assertNull(excution.next());
}
Aggregations