DataProvider { public EntityCollection readAll(final EdmEntitySet edmEntitySet) throws DataProviderException { EntityCollection entityCollection = data.get(edmEntitySet.getName()); if (entityCollection == null) { entityCollection = new EntityCollection(); data.put(edmEntitySet.getName(), entityCollection); } return entityCollection; } DataProvider(final OData odata, final Edm edm); EntityCollection readAll(final EdmEntitySet edmEntitySet); Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys); Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet,
      final List<UriParameter> keys); void delete(final EdmEntitySet edmEntitySet, final Entity entity); void deleteLinksTo(final Entity to); Entity create(final EdmEntitySet edmEntitySet); void update(final String rawBaseUri, final EdmEntitySet edmEntitySet, Entity entity,
      final Entity changedEntity, final boolean patch, final boolean isInsert); void updateETag(Entity entity); void setLink(final EdmNavigationProperty navigationProperty, final Entity srcEntity,
      final Entity targetEntity); @SuppressWarnings("unchecked") void updateProperty(final EdmProperty edmProperty, Property property, final Property newProperty,
      final boolean patch); void updatePropertyValue(Property property, final Object value); byte[] readMedia(final Entity entity); void setMedia(final Entity entity, final byte[] media, final String type); List<DeletedEntity> readDeletedEntities(final EdmEntitySet edmEntitySet); List<DeltaLink> readAddedLinks(final EdmEntitySet edmEntitySet); List<DeltaLink> readDeletedLinks(final EdmEntitySet edmEntitySet); EntityCollection readFunctionEntityCollection(final EdmFunction function, final List<UriParameter> parameters,
      final UriInfoResource uriInfo); Entity readFunctionEntity(final EdmFunction function, final List<UriParameter> parameters,
      final UriInfoResource uriInfo); Property readFunctionPrimitiveComplex(final EdmFunction function, final List<UriParameter> parameters,
      final UriInfoResource uriInfo); Property processActionPrimitive(final String name, final Map<String, Parameter> actionParameters); Property processBoundActionPrimitive(final String name, final Map<String, Parameter> actionParameters, 
      final EdmEntitySet edmEntitySet, final List<UriParameter> keyList); Property processActionComplex(final String name, final Map<String, Parameter> actionParameters); Property processBoundActionComplex(final String name, final Map<String, Parameter> actionParameters,
      final EdmEntitySet edmEntitySet, 
      final List<UriParameter> keyList); Property processActionComplexCollection(final String name, final Map<String, Parameter> actionParameters); Property processBoundActionComplexCollection(final String name, 
      final Map<String, Parameter> actionParameters, final EdmEntitySet edmEntitySet, 
      final List<UriParameter> keyList); Property processActionPrimitiveCollection(final String name, final Map<String, Parameter> actionParameters); Property processBoundActionPrimitiveCollection(final String name, 
      final Map<String, Parameter> actionParameters, final EdmEntitySet edmEntitySet, 
      final List<UriParameter> keyList); EntityActionResult processActionEntity(final String name, final Map<String, Parameter> actionParameters); EntityActionResult processBoundActionEntity(final String name, final Map<String, Parameter> actionParameters, 
      List<UriParameter> keyList, EdmEntitySet edmEntitySet); EntityActionResult processBoundActionWithNavigationEntity(final String name, 
      final Map<String, Parameter> actionParameters, 
      List<UriParameter> keyList, EdmEntitySet edmEntitySet, EdmNavigationProperty navProperty); EntityCollection processActionEntityCollection(final String name,
      final Map<String, Parameter> actionParameters); EntityCollection processBoundActionEntityCollection(final String name,
      final Map<String, Parameter> actionParameters, EdmEntitySet edmEntitySet); EntityCollection processBoundActionWithNavEntityCollection(final String name,
      final Map<String, Parameter> actionParameters, EdmEntitySet edmEntitySet, EdmNavigationProperty navProperty); void createReference(final Entity entity, final EdmNavigationProperty navigationProperty, final URI entityId,
      final String rawServiceRoot); void deleteReference(final Entity entity, final EdmNavigationProperty navigationProperty,
      final String entityId, final String rawServiceRoot); List<Entity> readNavigationEntities(EdmEntitySet entitySet); Entity read(EdmSingleton singleton); byte[] readStreamProperty(Property property); Entity createContNav(final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType, 
      final Entity newEntity, List<UriParameter> keys, String navPropertyName); Entity readDataFromEntity(final EdmEntityType edmEntityType,
      final List<UriParameter> keys);  }
@Test public void esAllPrim() throws Exception { final DataProvider data = new DataProvider(oData, edm); EntityCollection outSet = data.readAll(esAllPrim); Assert.assertEquals(4, outSet.getEntities().size()); Entity first = outSet.getEntities().get(0); Assert.assertEquals(16, first.getProperties().size()); Assert.assertEquals(2, first.getNavigationLinks().size()); final EntityCollection target = first.getNavigationLink("NavPropertyETTwoPrimMany").getInlineEntitySet(); Assert.assertNotNull(target); Assert.assertEquals(1, target.getEntities().size()); Assert.assertEquals(data.readAll(entityContainer.getEntitySet("ESTwoPrim")).getEntities().get(1), target.getEntities().get(0)); Assert.assertEquals(16, outSet.getEntities().get(1).getProperties().size()); Assert.assertEquals(16, outSet.getEntities().get(2).getProperties().size()); }
@Test public void esCollAllPrim() throws Exception { final DataProvider dataProvider = new DataProvider(oData, edm); EntityCollection outSet = dataProvider.readAll(esCollAllPrim); Assert.assertEquals(3, outSet.getEntities().size()); Assert.assertEquals(17, outSet.getEntities().get(0).getProperties().size()); Property list = outSet.getEntities().get(0).getProperties().get(1); Assert.assertTrue(list.isCollection()); Assert.assertEquals(3, list.asCollection().size()); Assert.assertEquals(17, outSet.getEntities().get(1).getProperties().size()); Assert.assertEquals(17, outSet.getEntities().get(2).getProperties().size()); }
@Test public void esCompAllPrim() throws Exception { final DataProvider dataProvider = new DataProvider(oData, edm); EntityCollection outSet = dataProvider.readAll(esCompAllPrim); Assert.assertEquals(4, outSet.getEntities().size()); Assert.assertEquals(2, outSet.getEntities().get(0).getProperties().size()); Property complex = outSet.getEntities().get(0).getProperties().get(1); Assert.assertTrue(complex.isComplex()); Assert.assertEquals(16, complex.asComplex().getValue().size()); Assert.assertEquals(2, outSet.getEntities().get(1).getProperties().size()); Assert.assertEquals(2, outSet.getEntities().get(2).getProperties().size()); }
@Test public void esMixPrimCollComp() throws Exception { final DataProvider dataProvider = new DataProvider(oData, edm); EntityCollection outSet = dataProvider.readAll(esMixPrimCollComp); Assert.assertEquals(3, outSet.getEntities().size()); Assert.assertEquals(4, outSet.getEntities().get(0).getProperties().size()); Property complex = outSet.getEntities().get(0).getProperties().get(2); Assert.assertTrue(complex.isComplex()); Assert.assertEquals(2, complex.asComplex().getValue().size()); Property complexCollection = outSet.getEntities().get(0).getProperties().get(3); Assert.assertTrue(complexCollection.isCollection()); List<?> linkedComplexValues = complexCollection.asCollection(); Assert.assertEquals(3, linkedComplexValues.size()); ComplexValue linkedComplexValue = (ComplexValue) linkedComplexValues.get(0); Assert.assertEquals(2, linkedComplexValue.getValue().size()); Property lcProp = linkedComplexValue.getValue().get(0); Assert.assertFalse(lcProp.isCollection()); Assert.assertEquals((short) 123, lcProp.getValue()); Assert.assertEquals(4, outSet.getEntities().get(1).getProperties().size()); Assert.assertEquals(4, outSet.getEntities().get(2).getProperties().size()); }