Search in sources :

Example 1 with CsdlComplexType

use of org.apache.olingo.commons.api.edm.provider.CsdlComplexType in project teiid by teiid.

the class TestODataQueryExecution method testActionReturnsComplexCollection.

@Test
public void testActionReturnsComplexCollection() throws Exception {
    String query = "exec invoke(1, 'foo')";
    String expectedURL = "invoke";
    String response = "{\"value\":[{\n" + "            \"street\":\"United States\",\n" + "            \"city\":\"Boise\",\n" + "            \"state\":\"ID\"\n" + "           }," + "           {" + "            \"street\":\"China\",\n" + "            \"city\":\"Newyork\",\n" + "            \"state\":\"NY\"\n" + "         }]}";
    CsdlComplexType complex = TestODataMetadataProcessor.complexType("Address");
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("namespace.Address");
    MetadataFactory mf = TestODataMetadataProcessor.actionMetadata("invoke", returnType, complex);
    ProcedureExecution excution = helpProcedureExecute(mf, query, response, expectedURL, 200);
    assertArrayEquals(new Object[] { "United States", "Boise", "ID" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "China", "Newyork", "NY" }, excution.next().toArray(new Object[3]));
    assertNull(excution.next());
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) ProcedureExecution(org.teiid.translator.ProcedureExecution) CsdlComplexType(org.apache.olingo.commons.api.edm.provider.CsdlComplexType) CsdlReturnType(org.apache.olingo.commons.api.edm.provider.CsdlReturnType) Test(org.junit.Test)

Example 2 with CsdlComplexType

use of org.apache.olingo.commons.api.edm.provider.CsdlComplexType in project teiid by teiid.

the class TestODataQueryExecution method testFunctionReturnsComplex.

@Test
public void testFunctionReturnsComplex() throws Exception {
    String query = "exec invoke(1, 'foo')";
    String expectedURL = "invoke?e1=1&e2='foo'";
    String response = "{\"value\":{\n" + "            \"street\":\"United States\",\n" + "            \"city\":\"Boise\",\n" + "            \"state\":\"ID\"\n" + "         }}";
    CsdlComplexType complex = TestODataMetadataProcessor.complexType("Address");
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("namespace.Address");
    MetadataFactory mf = TestODataMetadataProcessor.functionMetadata("invoke", returnType, complex);
    ProcedureExecution excution = helpProcedureExecute(mf, query, response, expectedURL, 200);
    assertArrayEquals(new Object[] { "United States", "Boise", "ID" }, excution.next().toArray(new Object[3]));
    assertNull(excution.next());
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) ProcedureExecution(org.teiid.translator.ProcedureExecution) CsdlComplexType(org.apache.olingo.commons.api.edm.provider.CsdlComplexType) CsdlReturnType(org.apache.olingo.commons.api.edm.provider.CsdlReturnType) Test(org.junit.Test)

Example 3 with CsdlComplexType

use of org.apache.olingo.commons.api.edm.provider.CsdlComplexType in project teiid by teiid.

the class TestODataQueryExecution method testFunctionReturnsComplexCollection.

@Test
public void testFunctionReturnsComplexCollection() throws Exception {
    String query = "exec invoke(1, 'foo')";
    String expectedURL = "invoke?e1=1&e2='foo'";
    String response = "{\"value\":[{\n" + "            \"street\":\"United States\",\n" + "            \"city\":\"Boise\",\n" + "            \"state\":\"ID\"\n" + "           }," + "           {" + "            \"street\":\"China\",\n" + "            \"city\":\"Newyork\",\n" + "            \"state\":\"NY\"\n" + "         }]}";
    CsdlComplexType complex = TestODataMetadataProcessor.complexType("Address");
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("namespace.Address");
    MetadataFactory mf = TestODataMetadataProcessor.functionMetadata("invoke", returnType, complex);
    ProcedureExecution excution = helpProcedureExecute(mf, query, response, expectedURL, 200);
    assertArrayEquals(new Object[] { "United States", "Boise", "ID" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "China", "Newyork", "NY" }, excution.next().toArray(new Object[3]));
    assertNull(excution.next());
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) ProcedureExecution(org.teiid.translator.ProcedureExecution) CsdlComplexType(org.apache.olingo.commons.api.edm.provider.CsdlComplexType) CsdlReturnType(org.apache.olingo.commons.api.edm.provider.CsdlReturnType) Test(org.junit.Test)

Aggregations

CsdlComplexType (org.apache.olingo.commons.api.edm.provider.CsdlComplexType)3 CsdlReturnType (org.apache.olingo.commons.api.edm.provider.CsdlReturnType)3 Test (org.junit.Test)3 MetadataFactory (org.teiid.metadata.MetadataFactory)3 ProcedureExecution (org.teiid.translator.ProcedureExecution)3