Java Code Examples for org.apache.olingo.odata2.api.edm.provider.Schema#getEntityContainers()
The following examples show how to use
org.apache.olingo.odata2.api.edm.provider.Schema#getEntityContainers() .
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: AnnotationEdmProviderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void schemaBasic() throws Exception { assertNotNull(aep); List<Schema> schemas = aep.getSchemas(); assertEquals(1, schemas.size()); Schema schema = schemas.get(0); List<EntityContainer> containers = schema.getEntityContainers(); assertEquals(1, containers.size()); EntityContainer container = containers.get(0); assertEquals(ModelSharedConstants.CONTAINER_1, container.getName()); final List<EntitySet> entitySets = container.getEntitySets(); assertEquals(6, entitySets.size()); List<Association> associations = schema.getAssociations(); assertEquals(5, associations.size()); for (Association association : associations) { assertNotNull(association.getName()); validateAssociation(association); } }
Example 2
Source File: EdmEntityContainerImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public String getNamespace() throws EdmException{ try { if (namespace == null) { List<Schema> schemas; schemas = edm.edmProvider.getSchemas(); for (Schema schema : schemas) { List<EntityContainer> containers = schema.getEntityContainers(); for (EntityContainer container : containers) { if (container.getName().equals(entityContainerInfo.getName())) { this.namespace = schema.getNamespace(); break; } } if (namespace != null) { break; } } } } catch (ODataException e) { throw new EdmException(EdmException.PROVIDERPROBLEM, e); } return namespace; }
Example 3
Source File: EdmxProvider.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { for (Schema schema : dataServices.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { if (container.getName().equals(entityContainer)) { for (AssociationSet associationSet : container.getAssociationSets()) { if (associationSet.getAssociation().equals(association) && ((associationSet.getEnd1().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd1() .getRole().equals(sourceEntitySetRole)) || (associationSet.getEnd2().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd2() .getRole().equals(sourceEntitySetRole)))) { return associationSet; } } } } } return null; }
Example 4
Source File: EdmImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override protected List<EdmEntitySet> createEntitySets() throws ODataException { List<EdmEntitySet> edmEntitySets = new ArrayList<EdmEntitySet>(); if (schemas == null) { schemas = edmProvider.getSchemas(); } for (Schema schema : schemas) { for (EntityContainer entityContainer : schema.getEntityContainers()) { for (EntitySet entitySet : entityContainer.getEntitySets()) { EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName()); edmEntitySets.add(new EdmEntitySetImplProv(this, entitySet, edmEntityContainer)); } } } return edmEntitySets; }
Example 5
Source File: EdmImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override protected List<EdmFunctionImport> createFunctionImports() throws ODataException { List<EdmFunctionImport> edmFunctionImports = new ArrayList<EdmFunctionImport>(); if (schemas == null) { schemas = edmProvider.getSchemas(); } for (Schema schema : schemas) { for (EntityContainer entityContainer : schema.getEntityContainers()) { for (FunctionImport functionImport : entityContainer.getFunctionImports()) { EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName()); edmFunctionImports.add(new EdmFunctionImportImplProv(this, functionImport, edmEntityContainer)); } } } return edmFunctionImports; }
Example 6
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void testAssociationSet() throws XMLStreamException, EntityProviderException { XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmlWithAssociation); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals(NAMESPACE2, schema.getNamespace()); assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); for (AssociationSet assocSet : container.getAssociationSets()) { assertEquals(ASSOCIATION, assocSet.getName()); assertEquals(ASSOCIATION, assocSet.getAssociation().getName()); assertEquals(NAMESPACE, assocSet.getAssociation().getNamespace()); AssociationSetEnd end; if ("Employees".equals(assocSet.getEnd1().getEntitySet())) { end = assocSet.getEnd1(); } else { end = assocSet.getEnd2(); } assertEquals("r_Employees", end.getRole()); } } } }
Example 7
Source File: EdmEntityContainerImplProv.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Map<String, EntityContainer> getEntityContainerMap() throws ODataException { Map<String, EntityContainer> name2Container = new HashMap<String, EntityContainer>(); List<Schema> schemas = edm.edmProvider.getSchemas(); for (Schema schema : schemas) { List<EntityContainer> containers = schema.getEntityContainers(); for (EntityContainer container : containers) { name2Container.put(container.getName(), container); } } return name2Container; }
Example 8
Source File: EdmxProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataException { for (Schema schema : dataServices.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { if (container.getName().equals(entityContainer)) { for (EntitySet entitySet : container.getEntitySets()) { if (entitySet.getName().equals(name)) { return entitySet; } } } } } return null; }
Example 9
Source File: EdmxProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException { for (Schema schema : dataServices.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { if (container.getName().equals(entityContainer)) { for (FunctionImport function : container.getFunctionImports()) { if (function.getName().equals(name)) { return function; } } } } } return null; }
Example 10
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testEntitySet() throws XMLStreamException, EntityProviderException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmWithEntityContainer); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); for (EntitySet entitySet : container.getEntitySets()) { assertEquals("Employees", entitySet.getName()); assertEquals("Employee", entitySet.getEntityType().getName()); assertEquals(NAMESPACE, entitySet.getEntityType().getNamespace()); } } } }
Example 11
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testEntityTypeInOtherSchema() throws XMLStreamException, EntityProviderException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Photos\" EntityType=\"" + NAMESPACE2 + ".Photo\"/>" + "</EntityContainer>" + "</Schema>" + "<Schema Namespace=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Photo\">" + "<Key><PropertyRef Name=\"Id\"/></Key>" + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\"/>" + "</EntityType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmWithEntityContainer); DataServices result = parser.readMetadata(reader, true); assertEquals("2.0", result.getDataServiceVersion()); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); for (EntitySet entitySet : container.getEntitySets()) { assertEquals(NAMESPACE2, entitySet.getEntityType().getNamespace()); assertEquals("Photo", entitySet.getEntityType().getName()); } } } }
Example 12
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void testFunctionImportEntity() throws XMLStreamException, EntityProviderException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<FunctionImport Name=\"EmployeeSearch\" ReturnType=\"RefScenario.Employee\" " + "EntitySet=\"Employees\" m:HttpMethod=\"GET\">" + "<Parameter Name=\"q1\" Type=\"Edm.String\" Nullable=\"true\" />" + "<Parameter Name=\"q2\" Type=\"Edm.Int32\" Nullable=\"false\" />" + "</FunctionImport>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmWithEntityContainer); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); FunctionImport functionImport1 = container.getFunctionImports().get(0); assertEquals("EmployeeSearch", functionImport1.getName()); assertEquals("Employees", functionImport1.getEntitySet()); assertEquals(NAMESPACE, functionImport1.getReturnType().getTypeName().getNamespace()); assertEquals("Employee", functionImport1.getReturnType().getTypeName().getName()); assertEquals(EdmMultiplicity.ONE, functionImport1.getReturnType().getMultiplicity()); assertEquals("GET", functionImport1.getHttpMethod()); assertEquals(2, functionImport1.getParameters().size()); assertEquals("q1", functionImport1.getParameters().get(0).getName()); assertEquals(EdmSimpleTypeKind.String, functionImport1.getParameters().get(0).getType()); assertEquals(Boolean.TRUE, functionImport1.getParameters().get(0).getFacets().isNullable()); assertEquals("q2", functionImport1.getParameters().get(1).getName()); assertEquals(EdmSimpleTypeKind.Int32, functionImport1.getParameters().get(1).getType()); assertEquals(Boolean.FALSE, functionImport1.getParameters().get(1).getFacets().isNullable()); } } }
Example 13
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void testFunctionImportEntityOrderChange() throws XMLStreamException, EntityProviderException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<FunctionImport Name=\"EmployeeSearch\" ReturnType=\"RefScenario.Employee\" " + "EntitySet=\"Employees\" m:HttpMethod=\"GET\">" + "<Parameter Name=\"q1\" Type=\"Edm.String\" Nullable=\"true\" />" + "<Parameter Name=\"q2\" Type=\"Edm.Int32\" Nullable=\"false\" />" + "</FunctionImport>" + "</EntityContainer>" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmWithEntityContainer); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); FunctionImport functionImport1 = container.getFunctionImports().get(0); assertEquals("EmployeeSearch", functionImport1.getName()); assertEquals("Employees", functionImport1.getEntitySet()); assertEquals(NAMESPACE, functionImport1.getReturnType().getTypeName().getNamespace()); assertEquals("Employee", functionImport1.getReturnType().getTypeName().getName()); assertEquals(EdmMultiplicity.ONE, functionImport1.getReturnType().getMultiplicity()); assertEquals("GET", functionImport1.getHttpMethod()); assertEquals(2, functionImport1.getParameters().size()); assertEquals("q1", functionImport1.getParameters().get(0).getName()); assertEquals(EdmSimpleTypeKind.String, functionImport1.getParameters().get(0).getType()); assertEquals(Boolean.TRUE, functionImport1.getParameters().get(0).getFacets().isNullable()); assertEquals("q2", functionImport1.getParameters().get(1).getName()); assertEquals(EdmSimpleTypeKind.Int32, functionImport1.getParameters().get(1).getType()); assertEquals(Boolean.FALSE, functionImport1.getParameters().get(1).getFacets().isNullable()); } } }
Example 14
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void testFunctionImportEntityWithoutEntitySet() throws XMLStreamException, EntityProviderException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<FunctionImport Name=\"EmployeeSearch\" ReturnType=\"RefScenario.Employee\" " + " m:HttpMethod=\"GET\">" + "<Parameter Name=\"q1\" Type=\"Edm.String\" Nullable=\"true\" />" + "<Parameter Name=\"q2\" Type=\"Edm.Int32\" Nullable=\"false\" />" + "</FunctionImport>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmWithEntityContainer); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); FunctionImport functionImport1 = container.getFunctionImports().get(0); assertEquals("EmployeeSearch", functionImport1.getName()); assertEquals(null, functionImport1.getEntitySet()); assertEquals(NAMESPACE, functionImport1.getReturnType().getTypeName().getNamespace()); assertEquals("Employee", functionImport1.getReturnType().getTypeName().getName()); assertEquals(EdmMultiplicity.ONE, functionImport1.getReturnType().getMultiplicity()); assertEquals("GET", functionImport1.getHttpMethod()); assertEquals(2, functionImport1.getParameters().size()); assertEquals("q1", functionImport1.getParameters().get(0).getName()); assertEquals(EdmSimpleTypeKind.String, functionImport1.getParameters().get(0).getType()); assertEquals(Boolean.TRUE, functionImport1.getParameters().get(0).getFacets().isNullable()); assertEquals("q2", functionImport1.getParameters().get(1).getName()); assertEquals(EdmSimpleTypeKind.Int32, functionImport1.getParameters().get(1).getType()); assertEquals(Boolean.FALSE, functionImport1.getParameters().get(1).getFacets().isNullable()); } } }
Example 15
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void testFunctionImportCollection() throws XMLStreamException, EntityProviderException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Room\" >" + "<Key><PropertyRef Name=\"RoomId\"/></Key>" + "<Property Name=\"" + "RoomId" + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"Edm.String\" />" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Rooms\" EntityType=\"RefScenario.Room\"/>" + "<FunctionImport Name=\"LocationSearch\" ReturnType=\"Collection(RefScenario.Location)\" " + " m:HttpMethod=\"GET\">" + "<Parameter Name=\"q1\" Type=\"Edm.String\" Nullable=\"true\" Mode=\"In\"/>" + "<Parameter Name=\"q2\" Type=\"Edm.Int32\" Nullable=\"false\" />" + "</FunctionImport>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmWithEntityContainer); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); FunctionImport functionImport2 = container.getFunctionImports().get(0); assertEquals("LocationSearch", functionImport2.getName()); assertEquals(null, functionImport2.getEntitySet()); assertEquals(NAMESPACE, functionImport2.getReturnType().getTypeName().getNamespace()); assertEquals("Location", functionImport2.getReturnType().getTypeName().getName()); assertEquals(EdmMultiplicity.MANY, functionImport2.getReturnType().getMultiplicity()); assertEquals("GET", functionImport2.getHttpMethod()); assertEquals(2, functionImport2.getParameters().size()); assertEquals(new FullQualifiedName("RefScenario", "Location"), functionImport2.getReturnType().getTypeName()); assertEquals(EdmMultiplicity.MANY, functionImport2.getReturnType().getMultiplicity()); FunctionImportParameter functionImportParameter = functionImport2.getParameters().get(0); assertEquals("q1", functionImportParameter.getName()); assertEquals(EdmSimpleTypeKind.String, functionImport2.getParameters().get(0).getType()); assertEquals(Boolean.TRUE, functionImport2.getParameters().get(0).getFacets().isNullable()); assertEquals("In", functionImportParameter.getMode()); assertEquals("q2", functionImport2.getParameters().get(1).getName()); assertEquals(EdmSimpleTypeKind.Int32, functionImport2.getParameters().get(1).getType()); assertEquals(Boolean.FALSE, functionImport2.getParameters().get(1).getFacets().isNullable()); assertEquals(null, functionImport2.getParameters().get(1).getMode()); } } }
Example 16
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void testFunctionImportProperty() throws XMLStreamException, EntityProviderException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<FunctionImport Name=\"GetId\" ReturnType=\"Edm.String\"" + " m:HttpMethod=\"GET\"/>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmWithEntityContainer); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { FunctionImport functionImport4 = container.getFunctionImports().get(0); assertEquals("GetId", functionImport4.getName()); List<FunctionImportParameter> parameters4 = functionImport4.getParameters(); assertNotNull(parameters4); assertEquals(0, parameters4.size()); assertEquals("String", functionImport4.getReturnType().getTypeName().getName()); } } }