@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()); }
@Override public List<?> next() throws TranslatorException, DataNotAvailableException { if (isCount && this.countResponse != -1) { int count = this.countResponse; this.countResponse = -1; return Arrays.asList(count); } if (this.response != null) { Map<String, Object> row = this.response.getNext(); if (row != null) { return buildRow(visitor.getODataQuery().getRootDocument().getTable(), visitor.getProjectedColumns(), this.expectedColumnTypes, row); } } return null; }
ODataQueryExecution extends BaseQueryExecution implements ResultSetExecution { @Override public List<?> next() throws TranslatorException, DataNotAvailableException { if (isCount && this.countResponse != -1) { int count = this.countResponse; this.countResponse = -1; return Arrays.asList(count); } if (this.response != null) { Map<String, Object> row = this.response.getNext(); if (row != null) { return buildRow(visitor.getODataQuery().getRootDocument().getTable(), visitor.getProjectedColumns(), this.expectedColumnTypes, row); } } return null; } }
ODataQueryExecution extends BaseQueryExecution implements ResultSetExecution { @Override public List<?> next() throws TranslatorException, DataNotAvailableException { if (isCount && this.countResponse != -1) { int count = this.countResponse; this.countResponse = -1; return Arrays.asList(count); } if (this.response != null) { Map<String, Object> row = this.response.getNext(); if (row != null) { return buildRow(visitor.getODataQuery().getRootDocument().getTable(), visitor.getProjectedColumns(), this.expectedColumnTypes, row); } } return null; } ODataQueryExecution(ODataExecutionFactory translator,
            QueryExpression command, ExecutionContext executionContext,
            RuntimeMetadata metadata, WSConnection connection); }
ODataQueryExecution extends BaseQueryExecution implements ResultSetExecution { @Override public List<?> next() throws TranslatorException, DataNotAvailableException { if (isCount && this.countResponse != -1) { int count = this.countResponse; this.countResponse = -1; return Arrays.asList(count); } if (this.response != null) { Map<String, Object> row = this.response.getNext(); if (row != null) { return buildRow(visitor.getODataQuery().getRootDocument().getTable(), visitor.getProjectedColumns(), this.expectedColumnTypes, row); } } return null; } ODataQueryExecution(ODataExecutionFactory translator,
            QueryExpression command, ExecutionContext executionContext,
            RuntimeMetadata metadata, WSConnection connection); @Override void execute(); @Override List<?> next(); @Override void close(); @Override void cancel(); }
ODataQueryExecution extends BaseQueryExecution implements ResultSetExecution { @Override public List<?> next() throws TranslatorException, DataNotAvailableException { if (isCount && this.countResponse != -1) { int count = this.countResponse; this.countResponse = -1; return Arrays.asList(count); } if (this.response != null) { Map<String, Object> row = this.response.getNext(); if (row != null) { return buildRow(visitor.getODataQuery().getRootDocument().getTable(), visitor.getProjectedColumns(), this.expectedColumnTypes, row); } } return null; } ODataQueryExecution(ODataExecutionFactory translator,
            QueryExpression command, ExecutionContext executionContext,
            RuntimeMetadata metadata, WSConnection connection); @Override void execute(); @Override List<?> next(); @Override void close(); @Override void cancel();  }