Java Code Examples for org.apache.olingo.commons.api.edm.Edm#getUnboundFunction()
The following examples show how to use
org.apache.olingo.commons.api.edm.Edm#getUnboundFunction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EdmProviderImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void nothingSpecifiedMustNotResultInExceptions() throws Exception { CsdlEdmProvider localProvider = mock(CsdlEdmProvider.class); when(localProvider.getActions(FQN)).thenReturn(null); when(localProvider.getFunctions(FQN)).thenReturn(null); Edm localEdm = new EdmProviderImpl(localProvider); localEdm.getUnboundAction(FQN); localEdm.getUnboundFunction(FQN, null); localEdm.getBoundAction(FQN, FQN, true); localEdm.getBoundFunction(FQN, FQN, true, null); localEdm.getComplexType(FQN); localEdm.getEntityContainer(FQN); localEdm.getEntityType(FQN); localEdm.getEnumType(FQN); localEdm.getTypeDefinition(FQN); }
Example 2
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
/** * Tests Example 85 from CSDL specification. */ @Test public void fromdoc1() { final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML). toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml")); assertNotNull(metadata); assertFalse(metadata.getReferences().isEmpty()); assertEquals("Org.OData.Measures.V1", metadata.getReferences().get(1).getIncludes().get(0).getNamespace()); final CsdlEntityType product = metadata.getSchema(0).getEntityType("Product"); assertTrue(product.hasStream()); assertEquals("UoM.ISOCurrency", product.getProperty("Price").getAnnotations().get(0).getTerm()); assertEquals("Products", product.getNavigationProperty("Supplier").getPartner()); final CsdlEntityType category = metadata.getSchema(0).getEntityType("Category"); assertNotNull(category); final CsdlComplexType address = metadata.getSchema(0).getComplexType("Address"); assertFalse(address.getNavigationProperty("Country").getReferentialConstraints().isEmpty()); assertEquals("Name", address.getNavigationProperty("Country").getReferentialConstraints().get(0).getReferencedProperty()); final CsdlFunction productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0); assertNotNull(productsByRating.getParameter("Rating")); assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType()); assertEquals("ODataDemo.Product", productsByRating.getReturnType().getType()); assertTrue(productsByRating.getReturnType().isCollection()); final CsdlSingleton contoso = metadata.getSchema(0).getEntityContainer().getSingleton("Contoso"); assertNotNull(contoso); assertFalse(contoso.getNavigationPropertyBindings().isEmpty()); assertEquals("Products", contoso.getNavigationPropertyBindings().get(0).getPath()); final CsdlFunctionImport functionImport = metadata.getSchema(0).getEntityContainer(). getFunctionImport("ProductsByRating"); assertNotNull(functionImport); assertEquals(metadata.getSchema(0).getNamespace() + "." + productsByRating.getName(), functionImport.getFunction()); // Now let's go high-level final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml")); assertNotNull(edm); List<EdmSchema> schemaList = edm.getSchemas(); assertNotNull(schemaList); assertEquals(1, schemaList.size()); EdmSchema schema = schemaList.get(0); EdmEntityContainer demoService = schema.getEntityContainer(); assertNotNull(demoService); EdmFunction function = schema.getFunctions().get(0); final EdmFunctionImport fi = demoService.getFunctionImport(function.getName()); assertNotNull(fi); assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet()); final EdmFunction edmFunction = edm.getUnboundFunction( new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), function .getParameterNames()); assertNotNull(edmFunction); assertEquals(edmFunction.getName(), fi.getUnboundFunction(function.getParameterNames()).getName()); assertEquals(edmFunction.getNamespace(), fi.getUnboundFunction(function.getParameterNames()).getNamespace()); assertEquals(edmFunction.getParameterNames(), fi.getUnboundFunction(function.getParameterNames()) .getParameterNames()); assertEquals(edmFunction.getReturnType().getType().getName(), fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getName()); assertEquals(edmFunction.getReturnType().getType().getNamespace(), fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getNamespace()); final EdmTypeDefinition weight = edm.getTypeDefinition(new FullQualifiedName("ODataDemo", "Weight")); assertNotNull(weight); assertEquals(EdmInt32.getInstance(), weight.getUnderlyingType()); assertFalse(weight.getAnnotations().isEmpty()); assertEquals("Kilograms", weight.getAnnotations().get(0).getExpression().asConstant().getValueAsString()); }