private String buildProcedureOptions(Procedure procedure) { StringBuilder options = new StringBuilder(); addCommonOptions(options, procedure); if (procedure.getUpdateCount() != Procedure.AUTO_UPDATECOUNT) { addOption(options, UPDATECOUNT, procedure.getUpdateCount()); } if (!procedure.getProperties().isEmpty()) { for (String key : procedure.getProperties().keySet()) { addOption(options, key, procedure.getProperty(key, false)); } } return options.toString(); }
@Test public void testAction() throws Exception { CsdlReturnType returnType = new CsdlReturnType(); returnType.setType("Edm.String"); MetadataFactory mf = actionMetadata("invoke", returnType, null); Procedure p = mf.getSchema().getProcedure("invoke"); assertNotNull(p); assertEquals(3, p.getParameters().size()); assertNull(p.getResultSet()); assertNotNull(getReturnParameter(p)); ProcedureParameter pp = getReturnParameter(p); assertEquals("string", pp.getRuntimeType()); ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false)); assertEquals(ODataType.ACTION, type); }
@Test public void testFunctionReturnComplex() throws Exception { CsdlComplexType complex = complexType("Address"); CsdlReturnType returnType = new CsdlReturnType(); returnType.setType("namespace.Address"); MetadataFactory mf = functionMetadata("invoke", returnType, complex); Procedure p = mf.getSchema().getProcedure("invoke"); assertNotNull(p); assertEquals(2, p.getParameters().size()); assertNotNull(p.getResultSet()); assertNull(getReturnParameter(p)); ColumnSet<Procedure> table = p.getResultSet(); ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false)); assertEquals(ODataType.FUNCTION, type); type = ODataType.valueOf(table.getProperty(ODataMetadataProcessor.ODATA_TYPE, false)); assertEquals(ODataType.COMPLEX, type); }