org.apache.olingo.odata2.api.edm.provider.EntitySet Java Examples
The following examples show how to use
org.apache.olingo.odata2.api.edm.provider.EntitySet.
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: EdmAssociationSetEndImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@BeforeClass public static void getEdmEntityContainerImpl() throws Exception { edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); EntityContainerInfo entityContainer = new EntityContainerInfo().setName("Container"); EdmEntityContainer edmEntityContainer = new EdmEntityContainerImplProv(edmImplProv, entityContainer); AssociationSetEnd associationSetEnd = new AssociationSetEnd().setRole("end1Role").setEntitySet("entitySetRole1"); EntitySet entitySet = new EntitySet().setName("entitySetRole1"); when(edmProvider.getEntitySet("Container", "entitySetRole1")).thenReturn(entitySet); edmAssociationSetEnd = new EdmAssociationSetEndImplProv(associationSetEnd, edmEntityContainer.getEntitySet("entitySetRole1")); }
Example #2
Source File: AtomServiceDocumentProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void writeServiceDocumentWithOneEnitySetOneContainerOneSchema() throws Exception { List<EntitySet> entitySets = new ArrayList<EntitySet>(); entitySets.add(new EntitySet().setName("Employees")); List<EntityContainer> entityContainers = new ArrayList<EntityContainer>(); entityContainers.add(new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets( entitySets)); schemas.add(new Schema().setEntityContainers(entityContainers)); ODataResponse response = new AtomEntityProvider().writeServiceDocument(edm, "http://localhost"); String xmlString = verifyResponse(response); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); }
Example #3
Source File: AtomServiceDocumentProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void writeServiceDocumentWithOneEnitySetTwoContainersOneSchema() throws Exception { List<EntitySet> entitySets = new ArrayList<EntitySet>(); entitySets.add(new EntitySet().setName("Employees")); List<EntityContainer> entityContainers = new ArrayList<EntityContainer>(); entityContainers.add(new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets( entitySets)); entityContainers.add(new EntityContainer().setDefaultEntityContainer(false).setName("Container2").setEntitySets( entitySets)); schemas.add(new Schema().setEntityContainers(entityContainers)); ODataResponse response = new AtomEntityProvider().writeServiceDocument(edm, "http://localhost"); String xmlString = verifyResponse(response); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString); assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString); assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Container2.Employees']/atom:title", xmlString); }
Example #4
Source File: EdmEntitySetInfoImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void checkValidUTF8Name() throws Exception { String entitySetNameOriginal = "Содержание"; String entitySetNameEscaped = "%D0%A1%D0%BE%D0%B4%D0%B5%D1%80%D0%B6%D0%B0%D0%BD%D0%B8%D0%B5"; // Write EntitySet entitySetRead = new EntitySet(); entitySetRead.setName(entitySetNameOriginal); EntityContainerInfo entityContainerInfo = new EntityContainerInfo().setDefaultEntityContainer(true); EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySetRead, entityContainerInfo); assertEquals("Содержание", info.getEntitySetName()); assertEquals(entitySetNameEscaped, info.getEntitySetUri().toASCIIString()); // Read EntitySet entitySetWrite = new EntitySet().setName(Decoder.decode(entitySetNameEscaped)); EdmEntitySetInfo infoRead = new EdmEntitySetInfoImplProv(entitySetWrite, entityContainerInfo); assertEquals(entitySetNameOriginal, infoRead.getEntitySetName()); assertEquals(entitySetNameEscaped, infoRead.getEntitySetUri().toASCIIString()); }
Example #5
Source File: EdmEntitySetInfoImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void checkValidNameWithoutDefaultContainer() throws Exception { String entitySetName = "::Name"; String entityContainerName = "Container"; EntitySet entitySet = new EntitySet(); entitySet.setName(entitySetName); EntityContainerInfo entityContainerInfo = new EntityContainerInfo(); entityContainerInfo.setName(entityContainerName).setDefaultEntityContainer(false); EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySet, entityContainerInfo); assertEquals(entitySetName, info.getEntitySetName()); assertEquals("Container.%3A%3AName", info.getEntitySetUri().toASCIIString()); assertEquals(entityContainerName, info.getEntityContainerName()); assertFalse(info.isDefaultEntityContainer()); }
Example #6
Source File: ScenarioEdmProvider.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataException { if (ENTITY_CONTAINER_1.equals(entityContainer)) { if (ENTITY_SET_1_1.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_1); } else if (ENTITY_SET_1_2.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_2); } else if (ENTITY_SET_1_3.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_3); } else if (ENTITY_SET_1_4.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_4); } else if (ENTITY_SET_1_5.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_5); } } else if (ENTITY_CONTAINER_2.equals(entityContainer)) { if (ENTITY_SET_2_1.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_2_1); } } return null; }
Example #7
Source File: TechnicalScenarioEdmProvider.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataMessageException { if (ENTITY_CONTAINER_1.equals(entityContainer)) { if (ES_KEY_IS_STRING.equals(name)) { return new EntitySet().setName(name).setEntityType(ET_KEY_IS_STRING); } else if (ES_KEY_IS_INTEGER.equals(name)) { return new EntitySet().setName(name).setEntityType(ET_KEY_IS_INTEGER); } else if (ES_COMPLEX_KEY.equals(name)) { return new EntitySet().setName(name).setEntityType(ET_COMPLEX_KEY); } else if (ES_ALL_TYPES.equals(name)) { return new EntitySet().setName(name).setEntityType(ET_ALL_TYPES); } else if (ES_STRING_FACETS.equals(name)) { return new EntitySet().setName(name).setEntityType(ET_STRING_FACETS); } } return null; }
Example #8
Source File: EdmTestProvider.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataException { if (ENTITY_CONTAINER_1.equals(entityContainer)) { if (ENTITY_SET_1_1.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_1); } else if (ENTITY_SET_1_2.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_2); } else if (ENTITY_SET_1_3.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_3); } else if (ENTITY_SET_1_4.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_4); } else if (ENTITY_SET_1_5.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_5); } } else if (ENTITY_CONTAINER_2.equals(entityContainer)) { if (ENTITY_SET_2_1.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_2_1); } } return null; }
Example #9
Source File: EdmEntitySetInfoImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void entityWithoutDefaultContainer() throws Exception { String entitySetName = "Employees"; String entityContainerName = "Container"; URI entitySetUri = new URI(entityContainerName + "." + entitySetName); EntitySet entitySet = new EntitySet(); entitySet.setName(entitySetName); EntityContainerInfo entityContainerInfo = new EntityContainerInfo(); entityContainerInfo.setName(entityContainerName).setDefaultEntityContainer(false); EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySet, entityContainerInfo); assertEquals(entitySetName, info.getEntitySetName()); assertEquals(entitySetUri.toASCIIString(), info.getEntitySetUri().toASCIIString()); assertEquals(entityContainerName, info.getEntityContainerName()); assertFalse(info.isDefaultEntityContainer()); }
Example #10
Source File: EdmEntityContainerImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public EdmEntitySet getEntitySet(final String name) throws EdmException { EdmEntitySet edmEntitySet = edmEntitySets.get(name); if (edmEntitySet != null) { return edmEntitySet; } EntitySet entitySet; try { entitySet = edm.edmProvider.getEntitySet(entityContainerInfo.getName(), name); } catch (ODataException e) { throw new EdmException(EdmException.PROVIDERPROBLEM, e); } if (entitySet != null) { edmEntitySet = createEntitySet(entitySet); } else if (edmExtendedEntityContainer != null) { edmEntitySet = edmExtendedEntityContainer.getEntitySet(name); if (edmEntitySet != null) { edmEntitySets.put(name, edmEntitySet); } } return edmEntitySet; }
Example #11
Source File: EdmEntitySetInfoImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void checkValidColonName() throws Exception { String entitySetNameOriginal = "::Name"; String entitySetNameEscaped = "%3A%3AName"; // Write EntitySet entitySetRead = new EntitySet().setName(entitySetNameOriginal); EntityContainerInfo entityContainerInfo = new EntityContainerInfo().setDefaultEntityContainer(true); EdmEntitySetInfo infoWrite = new EdmEntitySetInfoImplProv(entitySetRead, entityContainerInfo); assertEquals(entitySetNameOriginal, infoWrite.getEntitySetName()); assertEquals(entitySetNameEscaped, infoWrite.getEntitySetUri().toASCIIString()); // Read EntitySet entitySetWrite = new EntitySet().setName(Decoder.decode(entitySetNameEscaped)); EdmEntitySetInfo infoRead = new EdmEntitySetInfoImplProv(entitySetWrite, entityContainerInfo); assertEquals(entitySetNameOriginal, infoRead.getEntitySetName()); assertEquals(entitySetNameEscaped, infoRead.getEntitySetUri().toASCIIString()); }
Example #12
Source File: EdmEntityContainerImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public List<EdmEntitySet> getEntitySets() throws EdmException { try { List<EdmEntitySet> edmEntitySetsList = new ArrayList<EdmEntitySet>(); List<EntityContainer> entityContainerHierachyList = getEntityContainerHierachy(); for (EntityContainer entityContainer : entityContainerHierachyList) { List<EntitySet> entitySets = entityContainer.getEntitySets(); for (EntitySet entitySet : entitySets) { EdmEntitySet ees = createEntitySet(entitySet); edmEntitySetsList.add(ees); } } return edmEntitySetsList; } catch (ODataException e) { throw new EdmException(EdmException.PROVIDERPROBLEM, e); } }
Example #13
Source File: EdmEntitySetInfoImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void entityWithDefaultContainer() throws Exception { String entitySetName = "Employees"; URI entitySetUri = new URI(entitySetName); String entityContainerName = "Container"; EntitySet entitySet = new EntitySet(); entitySet.setName(entitySetName); EntityContainerInfo entityContainerInfo = new EntityContainerInfo(); entityContainerInfo.setName(entityContainerName).setDefaultEntityContainer(true); EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySet, entityContainerInfo); assertEquals(entitySetName, info.getEntitySetName()); assertEquals(entitySetUri.toASCIIString(), info.getEntitySetUri().toASCIIString()); assertEquals(entityContainerName, info.getEntityContainerName()); assertTrue(info.isDefaultEntityContainer()); }
Example #14
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 #15
Source File: EdmServiceMetadataImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public List<EdmEntitySetInfo> getEntitySetInfos() throws ODataException { if(edmProvider == null){ throw new ODataException(EDM_PROVIDER_EXEPTION); } if (entitySetInfos == null) { entitySetInfos = new ArrayList<EdmEntitySetInfo>(); if (schemas == null) { schemas = edmProvider.getSchemas(); } for (Schema schema : schemas) { for (EntityContainer entityContainer : listOrEmptyList(schema.getEntityContainers())) { for (EntitySet entitySet : listOrEmptyList(entityContainer.getEntitySets())) { EdmEntitySetInfo entitySetInfo = new EdmEntitySetInfoImplProv(entitySet, entityContainer); entitySetInfos.add(entitySetInfo); } } } } return entitySetInfos; }
Example #16
Source File: EdmServiceMetadataImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void twoEntitySetsOneContainerForInfo() throws Exception { List<EntitySet> entitySets = new ArrayList<EntitySet>(); EntitySet entitySet = new EntitySet().setName("Employees"); entitySets.add(entitySet); entitySets.add(entitySet); List<EntityContainer> entityContainers = new ArrayList<EntityContainer>(); EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets); entityContainers.add(container); List<Schema> schemas = new ArrayList<Schema>(); schemas.add(new Schema().setEntityContainers(entityContainers)); EdmProvider edmProvider = mock(EdmProvider.class); when(edmProvider.getSchemas()).thenReturn(schemas); EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider); List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos(); assertNotNull(infos); assertEquals(2, infos.size()); }
Example #17
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 #18
Source File: EdmServiceMetadataImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void oneEntitySetsOneContainerTwoSchemadForInfo() throws Exception { List<EntitySet> entitySets = new ArrayList<EntitySet>(); EntitySet entitySet = new EntitySet().setName("Employees"); entitySets.add(entitySet); List<EntityContainer> entityContainers = new ArrayList<EntityContainer>(); EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets); entityContainers.add(container); List<Schema> schemas = new ArrayList<Schema>(); schemas.add(new Schema().setEntityContainers(entityContainers)); schemas.add(new Schema().setEntityContainers(entityContainers)); EdmProvider edmProvider = mock(EdmProvider.class); when(edmProvider.getSchemas()).thenReturn(schemas); EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider); List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos(); assertNotNull(infos); assertEquals(2, infos.size()); }
Example #19
Source File: Model.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
@Override public EntitySet getEntitySet(String entity_container, String name) throws ODataException { if (name == null) { return null; } if (entity_container == null || entity_container.equals(ENTITY_CONTAINER)) { AbstractEntitySet aes = ENTITYSETS.get(name); if (aes == null) { return null; } return aes.getEntitySet(); } return null; }
Example #20
Source File: AnnotationsInMemoryDsTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private EdmEntitySet createMockedEdmEntitySet(final AnnotationEdmProvider edmProvider, final String entitySetName) throws ODataException { EntitySet entitySet = edmProvider.getEntitySet(DEFAULT_CONTAINER, entitySetName); FullQualifiedName entityType = entitySet.getEntityType(); EdmEntitySet edmEntitySet = Mockito.mock(EdmEntitySet.class); Mockito.when(edmEntitySet.getName()).thenReturn(entitySetName); EdmEntityType edmEntityType = Mockito.mock(EdmEntityType.class); Mockito.when(edmEntitySet.getEntityType()).thenReturn(edmEntityType); Mockito.when(edmEntityType.getName()).thenReturn(entityType.getName()); return edmEntitySet; }
Example #21
Source File: AnnotationEdmProviderTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void entitySetTeams() throws Exception { // validate teams EntitySet teams = aep.getEntitySet(ModelSharedConstants.CONTAINER_1, "Teams"); assertEquals(ModelSharedConstants.NAMESPACE_1, teams.getEntityType().getNamespace()); assertEquals("Team", teams.getEntityType().getName()); }
Example #22
Source File: MyEdmProvider.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Override public EntitySet getEntitySet(String entityContainer, String name) throws ODataException { if (ENTITY_CONTAINER.equals(entityContainer)) { if (ENTITY_SET_NAME_CARS.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_1); } else if (ENTITY_SET_NAME_MANUFACTURERS.equals(name)) { return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_2); } } return null; }
Example #23
Source File: AbstractEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * @return Olingo ES object for this ES. */ public EntitySet getEntitySet() { EntitySet res = new EntitySet().setName(getName()); res.setEntityType(getFullQualifiedName()); return res; }
Example #24
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 #25
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 #26
Source File: EdmAssociationSetImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@BeforeClass public static void getEdmEntityContainerImpl() throws Exception { edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); EntityContainerInfo entityContainer = new EntityContainerInfo().setName("Container"); EdmEntityContainer edmEntityContainer = new EdmEntityContainerImplProv(edmImplProv, entityContainer); AssociationEnd end1 = new AssociationEnd().setRole("end1Role").setMultiplicity(EdmMultiplicity.ONE).setType( EdmSimpleTypeKind.String.getFullQualifiedName()); AssociationEnd end2 = new AssociationEnd().setRole("end2Role").setMultiplicity(EdmMultiplicity.ONE).setType( EdmSimpleTypeKind.String.getFullQualifiedName()); Association association = new Association().setName("association").setEnd1(end1).setEnd2(end2); FullQualifiedName assocName = new FullQualifiedName("namespace", "association"); when(edmProvider.getAssociation(assocName)).thenReturn(association); AssociationSetEnd endSet1 = new AssociationSetEnd().setRole("end1Role").setEntitySet("entitySetRole1"); when(edmProvider.getEntitySet("Container", "entitySetRole1")).thenReturn(new EntitySet().setName("entitySetRole1")); AssociationSetEnd endSet2 = new AssociationSetEnd().setRole("end2Role"); AssociationSet associationSet = new AssociationSet().setName("associationSetName").setAssociation(assocName).setEnd1(endSet1).setEnd2(endSet2); edmAssociationSet = new EdmAssociationSetImplProv(edmImplProv, associationSet, edmEntityContainer); }
Example #27
Source File: EdmServiceMetadataImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void oneEntitySetOneContainerForInfo() throws Exception { String entitySetUriString = new URI("Employees").toASCIIString(); List<EntitySet> entitySets = new ArrayList<EntitySet>(); EntitySet entitySet = new EntitySet().setName("Employees"); entitySets.add(entitySet); List<EntityContainer> entityContainers = new ArrayList<EntityContainer>(); EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets); entityContainers.add(container); List<Schema> schemas = new ArrayList<Schema>(); schemas.add(new Schema().setEntityContainers(entityContainers)); EdmProvider edmProvider = mock(EdmProvider.class); when(edmProvider.getSchemas()).thenReturn(schemas); EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider); List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos(); assertNotNull(infos); assertEquals(1, infos.size()); assertEquals(infos.get(0).getEntitySetName(), "Employees"); assertEquals(infos.get(0).getEntityContainerName(), "Container"); assertEquals(infos.get(0).getEntitySetUri().toASCIIString(), entitySetUriString); assertTrue(infos.get(0).isDefaultEntityContainer()); }
Example #28
Source File: EdmServiceMetadataImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void twoContainersWithOneEntitySetEachForInfo() throws Exception { String entitySetUriString = new URI("Employees").toASCIIString(); String entitySetUriString2 = new URI("Container2.Employees").toASCIIString(); List<EntitySet> entitySets = new ArrayList<EntitySet>(); EntitySet entitySet = new EntitySet().setName("Employees"); entitySets.add(entitySet); List<EntityContainer> entityContainers = new ArrayList<EntityContainer>(); EntityContainer container = new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets); entityContainers.add(container); EntityContainer container2 = new EntityContainer().setDefaultEntityContainer(false).setName("Container2").setEntitySets(entitySets); entityContainers.add(container2); List<Schema> schemas = new ArrayList<Schema>(); schemas.add(new Schema().setEntityContainers(entityContainers)); EdmProvider edmProvider = mock(EdmProvider.class); when(edmProvider.getSchemas()).thenReturn(schemas); EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider); List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos(); assertNotNull(infos); assertEquals(2, infos.size()); assertEquals(infos.get(0).getEntitySetName(), "Employees"); assertEquals(infos.get(0).getEntityContainerName(), "Container"); assertEquals(infos.get(0).getEntitySetUri().toASCIIString(), entitySetUriString); assertTrue(infos.get(0).isDefaultEntityContainer()); assertEquals(infos.get(1).getEntitySetName(), "Employees"); assertEquals(infos.get(1).getEntityContainerName(), "Container2"); assertEquals(infos.get(1).getEntitySetUri().toASCIIString(), entitySetUriString2); assertFalse(infos.get(1).isDefaultEntityContainer()); }
Example #29
Source File: EdmFunctionImportImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@BeforeClass public static void getEdmEntityContainerImpl() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); EntityContainerInfo containerInfo = new EntityContainerInfo().setName("Container"); when(edmProvider.getEntityContainerInfo("Container")).thenReturn(containerInfo); edmEntityContainer = new EdmEntityContainerImplProv(edmImplProv, containerInfo); EntitySet fooEntitySet = new EntitySet().setName("fooEntitySet"); when(edmProvider.getEntitySet("Container", "fooEntitySet")).thenReturn(fooEntitySet); ReturnType fooReturnType = new ReturnType().setTypeName(EdmSimpleTypeKind.String.getFullQualifiedName()).setMultiplicity( EdmMultiplicity.ONE); List<FunctionImportParameter> parameters = new ArrayList<FunctionImportParameter>(); FunctionImportParameter parameter = new FunctionImportParameter().setName("fooParameter1").setType(EdmSimpleTypeKind.String); parameters.add(parameter); parameter = new FunctionImportParameter().setName("fooParameter2").setType(EdmSimpleTypeKind.String); parameters.add(parameter); parameter = new FunctionImportParameter().setName("fooParameter3").setType(EdmSimpleTypeKind.String); parameters.add(parameter); FunctionImport functionImportFoo = new FunctionImport().setName("foo").setHttpMethod("GET").setReturnType(fooReturnType).setEntitySet( "fooEntitySet").setParameters(parameters); when(edmProvider.getFunctionImport("Container", "foo")).thenReturn(functionImportFoo); edmFunctionImport = new EdmFunctionImportImplProv(edmImplProv, functionImportFoo, edmEntityContainer); FunctionImport functionImportBar = new FunctionImport().setName("bar").setHttpMethod("GET"); when(edmProvider.getFunctionImport("Container", "bar")).thenReturn(functionImportBar); edmFunctionImportWithoutParameters = new EdmFunctionImportImplProv(edmImplProv, functionImportBar, edmEntityContainer); }
Example #30
Source File: EdmEntitySetProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void checkValidNameWithUnderscore() throws Exception { EntitySet provES = new EntitySet().setName("_Name"); EdmEntitySet entitySet = new EdmEntitySetImplProv(null, provES , null); assertEquals("_Name", entitySet.getName()); provES = new EntitySet().setName("N_ame_"); entitySet = new EdmEntitySetImplProv(null, provES , null); assertEquals("N_ame_", entitySet.getName()); }