org.apache.olingo.odata2.api.edm.provider.EdmProvider Java Examples
The following examples show how to use
org.apache.olingo.odata2.api.edm.provider.EdmProvider.
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: ServiceFactory.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
@Override public ODataService createService(ODataContext ctx) throws ODataException { ODataService res = null; // Gets the last `root` segment of the URL // Stores this value in the `serviceName` variable // if the URL is http://dhus.gael.fr/odata/v1/Products/... // \__________________________/\_________... // ROOT ODATA // serviceName:="v1" // The length of the `root` part of the URL can be extended with the servlet's split parameter. // see http://http://olingo.apache.org/doc/odata2/index.html List<PathSegment> pathSegs = ctx.getPathInfo().getPrecedingSegments(); String serviceName = pathSegs.get(pathSegs.size() - 1).getPath(); if (serviceName.equals(SERVICE_NAME)) { EdmProvider edmProvider = new Model(); ODataSingleProcessor oDataProcessor = new Processor(); res = createODataSingleProcessorService(edmProvider, oDataProcessor); } return res; }
Example #2
Source File: ServiceDocumentProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Before public void before() throws ODataException { EdmProvider edmProvider = mock(EdmProvider.class); EntityType entityType = new EntityType().setName("EntityType1"); when(edmProvider.getEntityType(new FullQualifiedName("EntityType1Ns", "EntityType1"))).thenReturn(entityType); ComplexType complexType = new ComplexType().setName("ComplexType1"); when(edmProvider.getComplexType(new FullQualifiedName("ComplexType1Ns", "ComplexType1"))).thenReturn(complexType); Association association = new Association().setName("Association1"); when(edmProvider.getAssociation(new FullQualifiedName("Association1Ns", "Association1"))).thenReturn(association); EntityContainerInfo defaultEntityContainer = new EntityContainerInfo().setName("Container1"); when(edmProvider.getEntityContainerInfo(null)).thenReturn(defaultEntityContainer); when(edmProvider.getEntityContainerInfo("Container1")).thenReturn(defaultEntityContainer); edm = new EdmImplProv(edmProvider); }
Example #3
Source File: AtomServiceDocumentProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Before public void before() throws ODataException { Map<String, String> prefixMap = new HashMap<String, String>(); prefixMap.put("atom", Edm.NAMESPACE_ATOM_2005); prefixMap.put("a", Edm.NAMESPACE_APP_2007); prefixMap.put("xml", Edm.NAMESPACE_XML_1998); prefixMap.put("custom", "http://localhost"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap)); schemas = new ArrayList<Schema>(); EdmProvider edmProvider = mock(EdmProvider.class); when(edmProvider.getSchemas()).thenReturn(schemas); EdmServiceMetadata edmServiceMetadata = new EdmServiceMetadataImplProv(edmProvider); edm = mock(Edm.class); when(edm.getServiceMetadata()).thenReturn(edmServiceMetadata); }
Example #4
Source File: EdmNavigationPropertyImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws Exception { edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); FullQualifiedName relationship = new FullQualifiedName("namespace", "associationName"); Association association = new Association().setName("associationName"); when(edmProvider.getAssociation(relationship)).thenReturn(association); AssociationEnd end1 = new AssociationEnd().setRole("fromRole"); FullQualifiedName entityName = new FullQualifiedName("namespace", "entityName"); AssociationEnd end2 = new AssociationEnd().setRole("toRole").setMultiplicity(EdmMultiplicity.ONE).setType(entityName); association.setEnd1(end1).setEnd2(end2); EntityType entityType = new EntityType().setName("entityName"); when(edmProvider.getEntityType(entityName)).thenReturn(entityType); NavigationProperty navProperty = new NavigationProperty().setName("navProperty").setFromRole("fromRole").setToRole("toRole").setRelationship( relationship); navPropertyProvider = new EdmNavigationPropertyImplProv(edmImplProv, navProperty); }
Example #5
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 #6
Source File: EdmMappingTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); mappedObject = new EdmMappingTest(); Mapping propertySimpleMapping = new Mapping().setInternalName("value").setObject(mappedObject); CustomizableFeedMappings propertySimpleFeedMappings = new CustomizableFeedMappings().setFcKeepInContent(true); SimpleProperty propertySimple = new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String) .setMimeType("mimeType").setMapping(propertySimpleMapping).setCustomizableFeedMappings( propertySimpleFeedMappings); propertySimpleProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimple); NavigationProperty navProperty = new NavigationProperty().setName("navProperty").setFromRole("fromRole").setToRole("toRole").setMapping( propertySimpleMapping); navPropertyProvider = new EdmNavigationPropertyImplProv(edmImplProv, navProperty); }
Example #7
Source File: JPAServiceFactory.java From lemonaid with MIT License | 6 votes |
/** * Creates an OData Service based on the values set in * {@link org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext} and * {@link org.apache.olingo.odata2.api.processor.ODataContext}. */ @Override public final ODataService createService(final ODataContext ctx) throws ODataException { oDataContext = ctx; // Initialize OData JPA Context oDataJPAContext = initializeODataJPAContext(); validatePreConditions(); ODataJPAFactory factory = ODataJPAFactory.createFactory(); ODataJPAAccessFactory accessFactory = factory.getODataJPAAccessFactory(); // OData JPA Processor if (oDataJPAContext.getODataContext() == null) { oDataJPAContext.setODataContext(ctx); } ODataSingleProcessor odataJPAProcessor = new ODataJPAProcessor(oDataJPAContext); // OData Entity Data Model Provider based on JPA EdmProvider edmProvider = accessFactory.createJPAEdmProvider(oDataJPAContext); return createODataSingleProcessorService(edmProvider, odataJPAProcessor); }
Example #8
Source File: EdmxProviderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void testEntityType() throws Exception { Edm edm = createEdm(); assertNotNull(edm); FullQualifiedName fqNameEmployee = new FullQualifiedName("RefScenario", "Employee"); EdmProvider testProvider = new EdmTestProvider(); EdmImplProv edmImpl = (EdmImplProv) edm; EntityType employee = edmImpl.getEdmProvider().getEntityType(fqNameEmployee); EntityType testEmployee = testProvider.getEntityType(fqNameEmployee); assertEquals(testEmployee.getName(), employee.getName()); assertEquals(testEmployee.isHasStream(), employee.isHasStream()); assertEquals(testEmployee.getProperties().size(), employee.getProperties().size()); assertEquals(testEmployee.getNavigationProperties().size(), employee.getNavigationProperties().size()); }
Example #9
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 #10
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 #11
Source File: EdmPropertyImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws Exception { edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); Mapping propertySimpleMapping = new Mapping().setInternalName("value"); CustomizableFeedMappings propertySimpleFeedMappings = new CustomizableFeedMappings().setFcKeepInContent(true); SimpleProperty propertySimple = new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String) .setMimeType("mimeType").setMapping(propertySimpleMapping).setCustomizableFeedMappings( propertySimpleFeedMappings); propertySimpleProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimple); Facets facets = new Facets().setNullable(false); SimpleProperty propertySimpleWithFacets = new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String).setFacets(facets); propertySimpleWithFacetsProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimpleWithFacets); Facets facets2 = new Facets().setNullable(true); SimpleProperty propertySimpleWithFacets2 = new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String).setFacets(facets2); propertySimpleWithFacetsProvider2 = new EdmSimplePropertyImplProv(edmImplProv, propertySimpleWithFacets2); ComplexType complexType = new ComplexType().setName("complexType"); FullQualifiedName complexName = new FullQualifiedName("namespace", "complexType"); when(edmProvider.getComplexType(complexName)).thenReturn(complexType); ComplexProperty propertyComplex = new ComplexProperty().setName("complexProperty").setType(complexName); propertyComplexProvider = new EdmComplexPropertyImplProv(edmImplProv, propertyComplex); }
Example #12
Source File: EdmNamedImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testPropertyUnicodeTwo() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); SimpleProperty propertySimple = new SimpleProperty().setName("Содержание") .setType(EdmSimpleTypeKind.String); assertEquals("Содержание", new EdmSimplePropertyImplProv(edmImplProv, propertySimple).getName()); }
Example #13
Source File: EdmAssociationImplProvTest.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); 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()); List<PropertyRef> propRef = new ArrayList<PropertyRef>(); propRef.add(new PropertyRef().setName("prop1")); List<PropertyRef> propRef2 = new ArrayList<PropertyRef>(); propRef2.add(new PropertyRef().setName("prop2")); ReferentialConstraintRole dependent = new ReferentialConstraintRole().setRole("end1Role"); ReferentialConstraintRole principal = new ReferentialConstraintRole().setRole("end2Role"); ReferentialConstraint referentialConstraint = new ReferentialConstraint().setDependent(dependent).setPrincipal(principal); Association association = new Association().setName("association").setEnd1(end1).setEnd2(end2); association.setReferentialConstraint(referentialConstraint); associationProv = new EdmAssociationImplProv(edmImplProv, association, "namespace"); }
Example #14
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 #15
Source File: XmlMetadataDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testRefScenario() throws Exception { EdmProvider testProvider = new EdmTestProvider(); ODataResponse response = EntityProvider.writeMetadata(testProvider.getSchemas(), null); String stream = StringHelper.inputStreamToString((InputStream) response.getEntity()); XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); EdmDataServices result = parser.readMetadata(createStreamReader(stream), true); assertNotNull(result); }
Example #16
Source File: AbstractRefTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override protected ODataSingleProcessorService createService() { DataContainer dataContainer = new DataContainer(); dataContainer.reset(); ODataSingleProcessor processor = new ListsProcessor(new ScenarioDataSource(dataContainer)); EdmProvider provider = new ScenarioEdmProvider(); return new ODataSingleProcessorService(provider, processor) {}; }
Example #17
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 #18
Source File: EdmComplexTypeImplProvTest.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); ComplexType fooComplexType = new ComplexType().setName("fooComplexType"); List<Property> keyPropertysFoo = new ArrayList<Property>(); keyPropertysFoo.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)); keyPropertysFoo.add(new SimpleProperty().setName("Address").setType(EdmSimpleTypeKind.String)); fooComplexType.setProperties(keyPropertysFoo); edmComplexType = new EdmComplexTypeImplProv(edmImplProv, fooComplexType, "namespace"); FullQualifiedName barBaseTypeName = new FullQualifiedName("namespace", "barBase"); ComplexType barBase = new ComplexType().setName("barBase"); when(edmProvider.getComplexType(barBaseTypeName)).thenReturn(barBase); List<Property> propertysBarBase = new ArrayList<Property>(); propertysBarBase.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)); propertysBarBase.add(new SimpleProperty().setName("Address").setType(EdmSimpleTypeKind.String)); barBase.setProperties(propertysBarBase); ComplexType barComplexType = new ComplexType().setName("barComplexType").setBaseType(barBaseTypeName); edmComplexTypeWithBaseType = new EdmComplexTypeImplProv(edmImplProv, barComplexType, "namespace"); }
Example #19
Source File: InvalidDataInScenarioTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override protected ODataSingleProcessorService createService() { ODataSingleProcessor processor = new LocalProcessor(); EdmProvider provider = new ScenarioEdmProvider(); return new ODataSingleProcessorService(provider, processor) {}; }
Example #20
Source File: AbstractContentNegotiationTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override protected ODataService createService() throws ODataException { DataContainer dataContainer = new DataContainer(); dataContainer.init(); final ODataSingleProcessor processor = new ListsProcessor(new ScenarioDataSource(dataContainer)); final EdmProvider provider = new ScenarioEdmProvider(); return new ODataSingleProcessorService(provider, processor) {}; }
Example #21
Source File: ClientDeltaResponseTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override protected ODataService createService() throws ODataException { EdmProvider provider = new ScenarioEdmProvider(); processor = new StubProcessor(); return new ODataSingleProcessorService(provider, processor); }
Example #22
Source File: BasicBatchTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override protected ODataService createService() throws ODataException { final EdmProvider provider = createEdmProvider(); final ODataSingleProcessor processor = createProcessor(); return new ODataSingleProcessorService(provider, processor) { Edm edm = MockFacade.getMockEdm(); @Override public Edm getEntityDataModel() throws ODataException { return edm; } }; }
Example #23
Source File: EdmAssociationEndImplProvTest.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); AssociationEnd end1 = new AssociationEnd().setRole("end1Role").setMultiplicity(EdmMultiplicity.ONE).setType( EdmSimpleTypeKind.String.getFullQualifiedName()); associationEndProv = new EdmAssociationEndImplProv(edmImplProv, end1); }
Example #24
Source File: EdmNamedImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testPropertyUnicode() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); SimpleProperty propertySimple = new SimpleProperty().setName("\u00C0roperty\u00C1ame\u00C0\u00D5\u00D6") .setType(EdmSimpleTypeKind.String); assertEquals("ÀropertyÁameÀÕÖ", new EdmSimplePropertyImplProv(edmImplProv, propertySimple).getName()); }
Example #25
Source File: EdmNamedImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testPropertyUmlaut() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); SimpleProperty propertySimple = new SimpleProperty().setName("ÄropertyName").setType(EdmSimpleTypeKind.String); assertEquals("ÄropertyName", new EdmSimplePropertyImplProv(edmImplProv, propertySimple).getName()); }
Example #26
Source File: EdmNamedImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testPropertyWithNumber() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); SimpleProperty propertySimple = new SimpleProperty().setName("Prop_1_Name").setType(EdmSimpleTypeKind .String); new EdmSimplePropertyImplProv(edmImplProv, propertySimple); assertEquals("Prop_1_Name", new EdmSimplePropertyImplProv(edmImplProv, propertySimple).getName()); }
Example #27
Source File: EdmNamedImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test(expected = EdmException.class) public void testPropertyIllegalStartWithNumber() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); SimpleProperty propertySimple = new SimpleProperty().setName("1_PropertyName").setType(EdmSimpleTypeKind.String); new EdmSimplePropertyImplProv(edmImplProv, propertySimple); expectedEx.expect(RuntimeException.class); expectedEx.expectMessage("'Prop;ertyName' name pattern not valid."); }
Example #28
Source File: EdmNamedImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test(expected = EdmException.class) public void testPropertySimple() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); SimpleProperty propertySimple = new SimpleProperty().setName("Prop;ertyName").setType(EdmSimpleTypeKind.String); new EdmSimplePropertyImplProv(edmImplProv, propertySimple); }
Example #29
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 #30
Source File: EdmServiceMetadataImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void dataServiceVersion() throws Exception { EdmProvider edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); EdmServiceMetadata serviceMetadata = edmImplProv.getServiceMetadata(); assertEquals("1.0", serviceMetadata.getDataServiceVersion()); }