You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/03/31 10:59:49 UTC

[1/4] git commit: [OLINGO-200] More V4 Enum tests

Repository: olingo-odata4
Updated Branches:
  refs/heads/olingo200 cd7ede00e -> dc2922c95


[OLINGO-200] More V4 Enum tests


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/117cf6f0
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/117cf6f0
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/117cf6f0

Branch: refs/heads/olingo200
Commit: 117cf6f0d0099ef5d553e2a46b359d0e38222996
Parents: cd7ede0
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Sun Mar 30 16:12:17 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Sun Mar 30 16:12:17 2014 +0200

----------------------------------------------------------------------
 .../retrieve/CommonRetrieveRequestFactory.java  |  12 +-
 .../retrieve/v3/RetrieveRequestFactory.java     |   2 +-
 .../AbstractRetrieveRequestFactory.java         |   8 +-
 .../retrieve/v3/RetrieveRequestFactoryImpl.java |  19 ++-
 .../retrieve/v4/RetrieveRequestFactoryImpl.java |  19 ++-
 .../client/core/op/AbstractODataBinder.java     |  35 +++--
 .../client/core/op/impl/v4/ODataBinderImpl.java |  45 +++++++
 .../core/it/v3/EntityCreateTestITCase.java      |   4 +-
 .../it/v3/NavigationLinkCreateTestITCase.java   |   2 +-
 .../olingo/client/core/v3/EntityTest.java       |   5 +-
 .../apache/olingo/client/core/v3/JSONTest.java  |   4 +-
 .../olingo/client/core/v4/EntityTest.java       | 133 +++++++++++++++++++
 .../api/domain/CommonODataObjectFactory.java    |   4 +-
 .../api/domain/v4/ODataObjectFactory.java       |   2 +
 .../core/domain/AbstractODataObjectFactory.java |   4 +-
 .../core/domain/v4/ODataEnumValueImpl.java      |  50 +++++++
 .../core/domain/v4/ODataObjectFactoryImpl.java  |   5 +
 17 files changed, 298 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
index f8d48b3..69e53e7 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
@@ -60,7 +60,7 @@ public interface CommonRetrieveRequestFactory extends Serializable {
   ODataServiceDocumentRequest getServiceDocumentRequest(String serviceRoot);
 
   /**
-   * Gets a query request returning a set of one or more OData entities.
+   * Gets a uri request returning a set of one or more OData entities.
    *
    * @param <T> concrete ODataEntitySet implementation.
    * @param uri request URI.
@@ -69,7 +69,7 @@ public interface CommonRetrieveRequestFactory extends Serializable {
   <T extends CommonODataEntitySet> ODataEntitySetRequest<T> getEntitySetRequest(URI uri);
 
   /**
-   * Gets a query request returning a set of one or more OData entities.
+   * Gets a uri request returning a set of one or more OData entities.
    * <br/>
    * Returned request gives the possibility to consume entities iterating on them without parsing and loading in memory
    * the entire entity set.
@@ -83,7 +83,7 @@ public interface CommonRetrieveRequestFactory extends Serializable {
           ODataEntitySetIteratorRequest<ES, E> getEntitySetIteratorRequest(URI uri);
 
   /**
-   * Gets a query request returning a single OData entity.
+   * Gets a uri request returning a single OData entity.
    *
    * @param <T> concrete ODataEntity implementation.
    * @param uri request URI.
@@ -92,7 +92,7 @@ public interface CommonRetrieveRequestFactory extends Serializable {
   <T extends CommonODataEntity> ODataEntityRequest<T> getEntityRequest(URI uri);
 
   /**
-   * Gets a query request returning a single OData entity property.
+   * Gets a uri request returning a single OData entity property.
    *
    * @param <T> concrete ODataProperty implementation.
    * @param uri request URI.
@@ -101,7 +101,7 @@ public interface CommonRetrieveRequestFactory extends Serializable {
   <T extends CommonODataProperty> ODataPropertyRequest<T> getPropertyRequest(URI uri);
 
   /**
-   * Gets a query request returning a single OData entity property value.
+   * Gets a uri request returning a single OData entity property value.
    *
    * @param uri request URI.
    * @return new {@link ODataValueRequest} instance.
@@ -109,7 +109,7 @@ public interface CommonRetrieveRequestFactory extends Serializable {
   ODataValueRequest getValueRequest(URI uri);
 
   /**
-   * Gets a query request returning a media stream.
+   * Gets a uri request returning a media stream.
    *
    * @param uri request URI.
    * @return new {@link ODataMediaRequest} instance.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
index 00568bd..0d133cb 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
@@ -47,7 +47,7 @@ public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory {
   ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri);
 
   /**
-   * Gets a query request returning a single OData link.
+   * Gets a uri request returning a single OData link.
    *
    * @param targetURI target URI.
    * @param linkName link name.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
index a801953..d5e0319 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
@@ -39,13 +39,13 @@ public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRe
   }
 
   @Override
-  public ODataValueRequest getValueRequest(final URI query) {
-    return new ODataValueRequestImpl(client, query);
+  public ODataValueRequest getValueRequest(final URI uri) {
+    return new ODataValueRequestImpl(client, uri);
   }
 
   @Override
-  public ODataMediaRequest getMediaRequest(final URI query) {
-    return new ODataMediaRequestImpl(client, query);
+  public ODataMediaRequest getMediaRequest(final URI uri) {
+    return new ODataMediaRequestImpl(client, uri);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
index 3943747..0e8db34 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
@@ -36,6 +36,7 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 
+@SuppressWarnings("unchecked")
 public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
         implements RetrieveRequestFactory {
 
@@ -56,27 +57,23 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
     return new ODataLinkCollectionRequestImpl((ODataClient) client, targetURI, linkName);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(final URI query) {
-    return new ODataEntitySetRequestImpl<ODataEntitySet>(client, query);
+  public ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(final URI uri) {
+    return new ODataEntitySetRequestImpl<ODataEntitySet>(client, uri);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri) {
+  public ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(final URI uri) {
     return new ODataEntitySetIteratorRequestImpl<ODataEntitySet, ODataEntity>(client, uri);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataEntityRequest<ODataEntity> getEntityRequest(final URI query) {
-    return new ODataEntityRequestImpl<ODataEntity>(client, query);
+  public ODataEntityRequest<ODataEntity> getEntityRequest(final URI uri) {
+    return new ODataEntityRequestImpl<ODataEntity>(client, uri);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataPropertyRequest<ODataProperty> getPropertyRequest(final URI query) {
-    return new ODataPropertyRequestImpl<ODataProperty>(client, query);
+  public ODataPropertyRequest<ODataProperty> getPropertyRequest(final URI uri) {
+    return new ODataPropertyRequestImpl<ODataProperty>(client, uri);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
index 96419c2..879417b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
@@ -35,6 +35,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 
+@SuppressWarnings("unchecked")
 public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
         implements RetrieveRequestFactory {
 
@@ -50,27 +51,23 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
             client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(final URI query) {
-    return new ODataEntitySetRequestImpl<ODataEntitySet>(client, query);
+  public ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(final URI uri) {
+    return new ODataEntitySetRequestImpl<ODataEntitySet>(client, uri);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri) {
+  public ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(final URI uri) {
     return new ODataEntitySetIteratorRequestImpl<ODataEntitySet, ODataEntity>(client, uri);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataEntityRequest<ODataEntity> getEntityRequest(final URI query) {
-    return new ODataEntityRequestImpl<ODataEntity>(client, query);
+  public ODataEntityRequest<ODataEntity> getEntityRequest(final URI uri) {
+    return new ODataEntityRequestImpl<ODataEntity>(client, uri);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
-  public ODataPropertyRequest<ODataProperty> getPropertyRequest(final URI query) {
-    return new ODataPropertyRequestImpl<ODataProperty>(client, query);
+  public ODataPropertyRequest<ODataProperty> getPropertyRequest(final URI uri) {
+    return new ODataPropertyRequestImpl<ODataProperty>(client, uri);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index 4c86604..13a49fb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -42,6 +42,7 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataOperation;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -54,6 +55,7 @@ import org.apache.olingo.commons.core.data.JSONPropertyImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.NullValueImpl;
 import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 import org.apache.olingo.commons.core.op.ResourceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -228,7 +230,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     return propertyResource;
   }
 
-  private Value getValue(final ODataValue value, final Class<? extends Entry> reference, final boolean setType) {
+  protected Value getValue(final ODataValue value, final Class<? extends Entry> reference, final boolean setType) {
     Value valueResource = null;
 
     if (value == null) {
@@ -329,8 +331,12 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       final Feed inlineFeed = link.getInlineFeed();
 
       if (inlineEntry == null && inlineFeed == null) {
-        entity.addLink(
-                client.getObjectFactory().newEntityNavigationLink(link.getTitle(), base, link.getHref()));
+        final ODataLinkType linkType = link.getType() == null
+                ? ODataLinkType.ENTITY_NAVIGATION
+                : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
+        entity.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION
+                ? client.getObjectFactory().newEntityNavigationLink(link.getTitle(), base, link.getHref())
+                : client.getObjectFactory().newEntitySetNavigationLink(link.getTitle(), base, link.getHref()));
       } else if (inlineEntry != null) {
         entity.addLink(client.getObjectFactory().newInlineEntity(
                 link.getTitle(), base, link.getHref(),
@@ -369,28 +375,35 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   protected ODataValue getODataValue(final Property resource) {
     ODataValue value = null;
 
+    final EdmTypeInfo typeInfo = resource.getType() == null
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(resource.getType()).build();
     if (resource.getValue().isPrimitive()) {
       value = client.getObjectFactory().newPrimitiveValueBuilder().
               setText(resource.getValue().asPrimitive().get()).
-              setType(resource.getType() == null
+              setType(typeInfo == null
                       ? null
-                      : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), resource.getType())).build();
+                      : EdmPrimitiveTypeKind.valueOfFQN(
+                              client.getServiceVersion(), typeInfo.getFullQualifiedName().toString())).build();
     } else if (resource.getValue().isGeospatial()) {
       value = client.getObjectFactory().newPrimitiveValueBuilder().
               setValue(resource.getValue().asGeospatial().get()).
-              setType(resource.getType() == null
-                      || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().toString().equals(resource.getType())
-                      || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().toString().equals(resource.getType())
+              setType(typeInfo == null
+                      || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().equals(typeInfo.getFullQualifiedName())
+                      || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().equals(typeInfo.getFullQualifiedName())
                       ? resource.getValue().asGeospatial().get().getEdmPrimitiveTypeKind()
-                      : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), resource.getType())).build();
+                      : EdmPrimitiveTypeKind.valueOfFQN(
+                              client.getServiceVersion(), typeInfo.getFullQualifiedName().toString())).build();
     } else if (resource.getValue().isComplex()) {
-      value = client.getObjectFactory().newComplexValue(resource.getType());
+      value = client.getObjectFactory().newComplexValue(typeInfo == null
+              ? null : typeInfo.getFullQualifiedName().toString());
 
       for (Property property : resource.getValue().asComplex().get()) {
         value.asComplex().add(getODataProperty(property));
       }
     } else if (resource.getValue().isCollection()) {
-      value = client.getObjectFactory().newCollectionValue(resource.getType());
+      value = client.getObjectFactory().newCollectionValue(typeInfo == null
+              ? null : "Collection(" + typeInfo.getFullQualifiedName().toString() + ")");
 
       for (Value _value : resource.getValue().asCollection().get()) {
         final JSONPropertyImpl fake = new JSONPropertyImpl();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
index 0acc7d1..e85b34e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
@@ -29,13 +29,17 @@ import org.apache.olingo.client.core.op.AbstractODataBinder;
 import org.apache.olingo.commons.api.data.Entry;
 import org.apache.olingo.commons.api.data.Feed;
 import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.Value;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.core.data.EnumValueImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
 public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
 
@@ -86,6 +90,31 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   }
 
   @Override
+  public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference,
+          final boolean setType) {
+
+    final Property propertyResource = super.getProperty(property, reference, setType);
+    if (property instanceof ODataProperty && ((ODataProperty) property).hasEnumValue() && setType) {
+      propertyResource.setType(((ODataProperty) property).getEnumValue().getTypeName());
+    }
+    return propertyResource;
+  }
+
+  @Override
+  protected Value getValue(final ODataValue value, final Class<? extends Entry> reference, final boolean setType) {
+    Value valueResource;
+    if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+            && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isEnum()) {
+
+      valueResource = new EnumValueImpl(
+              ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asEnum().getValue());
+    } else {
+      valueResource = super.getValue(value, reference, setType);
+    }
+    return valueResource;
+  }
+
+  @Override
   public ODataEntitySet getODataEntitySet(final Feed resource) {
     return (ODataEntitySet) super.getODataEntitySet(resource);
   }
@@ -112,4 +141,20 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
     return new ODataPropertyImpl(property.getName(), getODataValue(property));
   }
 
+  @Override
+  protected ODataValue getODataValue(final Property resource) {
+    ODataValue value;
+    if (resource.getValue().isEnum()) {
+      final EdmTypeInfo typeInfo = resource.getType() == null
+              ? null
+              : new EdmTypeInfo.Builder().setTypeExpression(resource.getType()).build();
+      value = ((ODataClient) client).getObjectFactory().newEnumValue(
+              typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(),
+              resource.getValue().asEnum().get());
+    } else {
+      value = super.getODataValue(resource);
+    }
+
+    return value;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
index bd1419f..2a4efee 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
@@ -305,7 +305,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
               client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Order").build(), order);
       createReq.setFormat(format);
 
-      original.addLink(client.getObjectFactory().newFeedNavigationLink(
+      original.addLink(client.getObjectFactory().newEntitySetNavigationLink(
               "Orders",
               createReq.execute().getBody().getEditLink()));
     }
@@ -409,7 +409,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     ODataEntity changes = client.getObjectFactory().newEntity(
             "Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
     changes.setEditLink(customer.getEditLink());
-    changes.addLink(client.getObjectFactory().newFeedNavigationLink(
+    changes.addLink(client.getObjectFactory().newEntitySetNavigationLink(
             "Orders", URIUtils.getURI(getServiceRoot(), order.getEditLink().toASCIIString())));
     update(UpdateType.PATCH, changes, format, null);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
index fcbbe80..3b518d9 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
@@ -223,7 +223,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
                 orderEntity);
         createReq.setFormat(format);
         createReq.setContentType(contentType);
-        original.addLink(client.getObjectFactory().newFeedNavigationLink(
+        original.addLink(client.getObjectFactory().newEntitySetNavigationLink(
                 "Orders",
                 createReq.execute().getBody().getEditLink()));
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
index fe5b148..41da651 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java
@@ -29,6 +29,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
 import org.apache.olingo.client.core.AbstractTest;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.core.op.ResourceFactory;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -45,7 +46,7 @@ public class EntityTest extends AbstractTest {
 
   private void readAndWrite(final ODataPubFormat format) {
     final InputStream input = getClass().getResourceAsStream("Customer_-10." + getSuffix(format));
-    final CommonODataEntity entity = getClient().getBinder().getODataEntity(
+    final ODataEntity entity = getClient().getBinder().getODataEntity(
             getClient().getDeserializer().toEntry(input, format).getObject());
     assertNotNull(entity);
 
@@ -64,7 +65,7 @@ public class EntityTest extends AbstractTest {
 
     assertTrue(check);
 
-    final CommonODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
+    final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
             getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
     assertEquals(entity, written);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
index bae0bdd..522e686 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/JSONTest.java
@@ -1,5 +1,3 @@
-package org.apache.olingo.client.core.v3;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -18,6 +16,8 @@ package org.apache.olingo.client.core.v3;
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.olingo.client.core.v3;
+
 import static org.junit.Assert.assertEquals;
 
 import com.fasterxml.jackson.databind.JsonNode;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
new file mode 100644
index 0000000..f9c57c2
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.v4;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.util.Iterator;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.AbstractTest;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
+import org.apache.olingo.commons.core.op.ResourceFactory;
+import org.junit.Test;
+
+public class EntityTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  private void singleton(final ODataPubFormat format) {
+    final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format));
+    final ODataEntity entity = getClient().getBinder().getODataEntity(
+            getClient().getDeserializer().toEntry(input, format).getObject());
+    assertNotNull(entity);
+
+    assertEquals("#Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getName());
+
+    final ODataProperty birthday = entity.getProperty("Birthday");
+    assertTrue(birthday.hasPrimitiveValue());
+    assertEquals(EdmDateTimeOffset.getInstance(), birthday.getPrimitiveValue().getType());
+
+    final ODataProperty timeBetweenLastTwoOrders = entity.getProperty("TimeBetweenLastTwoOrders");
+    assertTrue(timeBetweenLastTwoOrders.hasPrimitiveValue());
+    assertEquals(EdmDuration.getInstance(), timeBetweenLastTwoOrders.getPrimitiveValue().getType());
+
+    int checked = 0;
+    for (ODataLink link : entity.getNavigationLinks()) {
+      if ("Parent".equals(link.getName())) {
+        checked++;
+        assertEquals(ODataLinkType.ENTITY_NAVIGATION, link.getType());
+      }
+      if ("Orders".equals(link.getName())) {
+        checked++;
+        if (format == ODataPubFormat.ATOM) {
+          assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, link.getType());
+        }
+      }
+      if ("Company".equals(link.getName())) {
+        checked++;
+        assertEquals(ODataLinkType.ENTITY_NAVIGATION, link.getType());
+      }
+    }
+    assertEquals(3, checked);
+
+    // operations won't get serialized
+    entity.getOperations().clear();
+    final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
+            getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
+    assertEquals(entity, written);
+  }
+
+  @Test
+  public void atomSingleton() {
+    singleton(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void jsonSingleton() {
+    singleton(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void withEnums(final ODataPubFormat format) {
+    final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format));
+    final ODataEntity entity = getClient().getBinder().getODataEntity(
+            getClient().getDeserializer().toEntry(input, format).getObject());
+    assertNotNull(entity);
+
+    final ODataProperty skinColor = entity.getProperty("SkinColor");
+    assertTrue(skinColor.hasEnumValue());
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", skinColor.getEnumValue().getTypeName());
+    assertEquals("Red", skinColor.getEnumValue().getValue());
+
+//    final ODataProperty coverColors = entity.getProperty("CoverColors");
+//    assertTrue(coverColors.hasCollectionValue());
+//    for (final Iterator<ODataValue> itor = coverColors.getCollectionValue().iterator(); itor.hasNext();) {
+//      final ODataValue item = itor.next();
+//      assertTrue(item.isEnum());
+//    }
+
+    // operations won't get serialized
+    entity.getOperations().clear();    
+    final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
+            getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
+    assertEquals(entity, written);
+  }
+
+  @Test
+  public void atomWithEnums() {
+    withEnums(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void jsonWithEnums() {
+    withEnums(ODataPubFormat.JSON_FULL_METADATA);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
index 525dc9d..40ffda9 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
@@ -125,7 +125,7 @@ public interface CommonODataObjectFactory {
    * @param link link.
    * @return entity set navigation link.
    */
-  ODataLink newFeedNavigationLink(String name, URI link);
+  ODataLink newEntitySetNavigationLink(String name, URI link);
 
   /**
    * Instantiates a new entity set navigation link.
@@ -135,7 +135,7 @@ public interface CommonODataObjectFactory {
    * @param href href.
    * @return entity set navigation link.
    */
-  ODataLink newFeedNavigationLink(String name, URI baseURI, String href);
+  ODataLink newEntitySetNavigationLink(String name, URI baseURI, String href);
 
   /**
    * Instantiates a new association link.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
index 8b43bc1..d12f0dc 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
@@ -38,6 +38,8 @@ public interface ODataObjectFactory extends CommonODataObjectFactory {
   @Override
   ODataEntity newEntity(String name, URI link);
 
+  ODataEnumValue newEnumValue(String typeName, String value);
+
   @Override
   ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
index ea73910..a3133cd 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
@@ -80,13 +80,13 @@ public abstract class AbstractODataObjectFactory implements CommonODataObjectFac
   }
 
   @Override
-  public ODataLink newFeedNavigationLink(final String name, final URI link) {
+  public ODataLink newEntitySetNavigationLink(final String name, final URI link) {
     return new ODataLink.Builder().setVersion(version).setURI(link).
             setType(ODataLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
   }
 
   @Override
-  public ODataLink newFeedNavigationLink(final String name, final URI baseURI, final String href) {
+  public ODataLink newEntitySetNavigationLink(final String name, final URI baseURI, final String href) {
     return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
             setType(ODataLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java
new file mode 100644
index 0000000..ee21018
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v4;
+
+import org.apache.olingo.commons.api.domain.AbstractODataValue;
+import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
+
+public class ODataEnumValueImpl extends AbstractODataValue implements ODataEnumValue {
+
+  private static final long serialVersionUID = 5830261159033325828L;
+
+  private final String value;
+
+  public ODataEnumValueImpl(final String typeName, final String value) {
+    super(typeName);
+    this.value = value;
+  }
+
+  @Override
+  public String getValue() {
+    return value;
+  }
+
+  @Override
+  public boolean isEnum() {
+    return true;
+  }
+
+  @Override
+  public ODataEnumValue asEnum() {
+    return this;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/117cf6f0/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
index 1b6428f..0a84407 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
@@ -59,6 +59,11 @@ public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implement
   }
 
   @Override
+  public ODataEnumValue newEnumValue(final String typeName, final String value) {
+    return new ODataEnumValueImpl(typeName, value);
+  }
+
+  @Override
   public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
     return new ODataPropertyImpl(name, value);
   }


[2/4] [OLINGO-200] V4 ODataValue full reachable via API

Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java
index cddd66d..18613cf 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java
@@ -23,7 +23,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.client.api.uri.v4.URIBuilder;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
@@ -38,7 +38,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveIntPropertyValueTest() throws EdmPrimitiveTypeException {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -48,7 +48,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveBooleanPropertyValueTest() throws EdmPrimitiveTypeException {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -58,7 +58,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveStringPropertyValueTest() throws EdmPrimitiveTypeException {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -68,7 +68,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveDatePropertyValueTest() {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -79,7 +79,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveDecimalPropertyValueTest() throws EdmPrimitiveTypeException {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -90,7 +90,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveBinaryPropertyValueTest() throws IOException {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -102,7 +102,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test(expected = ODataClientErrorException.class)
   public void retrieveBinaryPropertyValueTestWithAtom() throws IOException {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -112,7 +112,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test(expected = ODataClientErrorException.class)
   public void retrieveBinaryPropertyValueTestWithXML() throws IOException {
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
@@ -122,7 +122,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveCollectionPropertyValueTest() {
-    CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
     final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
             getPropertyRequest(uriBuilder.build());
@@ -134,7 +134,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
 
   @Test
   public void retrieveNullPropertyValueTest() {
-    CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+    URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("MiddleName").
             appendValueSegment();
     final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
index 4b3167e..8676d6f 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
@@ -31,11 +31,12 @@ import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
 import org.junit.Test;
 
 public class PropertyTest extends AbstractTest {
@@ -57,15 +58,15 @@ public class PropertyTest extends AbstractTest {
     assertEquals("-10", value.toString());
   }
 
-  private CommonODataProperty primitive(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
+  private ODataProperty primitive(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
     final InputStream input = getClass().getResourceAsStream("Customer_-10_CustomerId." + getSuffix(format));
-    final CommonODataProperty property = getClient().getReader().readProperty(input, format);
+    final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
     assertTrue(property.hasPrimitiveValue());
     assertTrue(-10 == property.getPrimitiveValue().toCastValue(Integer.class));
 
-    CommonODataProperty comparable;
-    final CommonODataProperty written = getClient().getReader().readProperty(
+    ODataProperty comparable;
+    final ODataProperty written = getClient().getReader().readProperty(
             getClient().getWriter().writeProperty(property, format), format);
     if (format == ODataFormat.XML) {
       comparable = written;
@@ -93,24 +94,24 @@ public class PropertyTest extends AbstractTest {
     primitive(ODataFormat.JSON);
   }
 
-  private CommonODataProperty complex(final ODataFormat format) throws IOException {
+  private ODataProperty complex(final ODataFormat format) throws IOException {
     final InputStream input = getClass().getResourceAsStream("Customer_-10_PrimaryContactInfo." + getSuffix(format));
-    final CommonODataProperty property = getClient().getReader().readProperty(input, format);
+    final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
     assertTrue(property.hasComplexValue());
     assertEquals(6, property.getComplexValue().size());
 
-    CommonODataProperty comparable;
-    final CommonODataProperty written = getClient().getReader().readProperty(
+    ODataProperty comparable;
+    final ODataProperty written = getClient().getReader().readProperty(
             getClient().getWriter().writeProperty(property, format), format);
     if (format == ODataFormat.XML) {
       comparable = written;
     } else {
       // This is needed because type information gets lost with JSON serialization
-      final ODataComplexValue typedValue = getClient().getObjectFactory().
+      final ODataComplexValue<ODataProperty> typedValue = getClient().getObjectFactory().
               newComplexValue(property.getComplexValue().getTypeName());
-      for (final Iterator<CommonODataProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
-        final CommonODataProperty prop = itor.next();
+      for (final Iterator<ODataProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
+        final ODataProperty prop = itor.next();
         typedValue.add(prop);
       }
       comparable = getClient().getObjectFactory().newComplexProperty(written.getName(), typedValue);
@@ -131,21 +132,21 @@ public class PropertyTest extends AbstractTest {
     complex(ODataFormat.JSON);
   }
 
-  private CommonODataProperty collection(final ODataFormat format) throws IOException {
+  private ODataProperty collection(final ODataFormat format) throws IOException {
     final InputStream input = getClass().getResourceAsStream("Customer_-10_BackupContactInfo." + getSuffix(format));
-    final CommonODataProperty property = getClient().getReader().readProperty(input, format);
+    final ODataProperty property = getClient().getReader().readProperty(input, format);
     assertNotNull(property);
     assertTrue(property.hasCollectionValue());
     assertEquals(9, property.getCollectionValue().size());
 
-    CommonODataProperty comparable;
-    final CommonODataProperty written = getClient().getReader().readProperty(
+    ODataProperty comparable;
+    final ODataProperty written = getClient().getReader().readProperty(
             getClient().getWriter().writeProperty(property, format), format);
     if (format == ODataFormat.XML) {
       comparable = written;
     } else {
       // This is needed because type information gets lost with JSON serialization
-      final ODataCollectionValue typedValue = getClient().getObjectFactory().
+      final ODataCollectionValue<ODataValue> typedValue = getClient().getObjectFactory().
               newCollectionValue(property.getCollectionValue().getTypeName());
       for (final Iterator<ODataValue> itor = written.getCollectionValue().iterator(); itor.hasNext();) {
         final ODataValue value = itor.next();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index f9c57c2..97b6a44 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -28,9 +28,9 @@ import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.domain.v4.ODataValue;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
@@ -107,15 +107,15 @@ public class EntityTest extends AbstractTest {
     assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", skinColor.getEnumValue().getTypeName());
     assertEquals("Red", skinColor.getEnumValue().getValue());
 
-//    final ODataProperty coverColors = entity.getProperty("CoverColors");
-//    assertTrue(coverColors.hasCollectionValue());
-//    for (final Iterator<ODataValue> itor = coverColors.getCollectionValue().iterator(); itor.hasNext();) {
-//      final ODataValue item = itor.next();
-//      assertTrue(item.isEnum());
-//    }
+    final ODataProperty coverColors = entity.getProperty("CoverColors");
+    assertTrue(coverColors.hasCollectionValue());
+    for (final Iterator<ODataValue> itor = coverColors.getCollectionValue().iterator(); itor.hasNext();) {
+      final ODataValue item = itor.next();
+      assertTrue(item.isEnum());
+    }
 
     // operations won't get serialized
-    entity.getOperations().clear();    
+    entity.getOperations().clear();
     final ODataEntity written = getClient().getBinder().getODataEntity(getClient().getBinder().
             getEntry(entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)));
     assertEquals(entity, written);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
index 1dbfdf8..4fb9de9 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
@@ -35,7 +35,7 @@ public abstract class AbstractODataValue implements ODataValue {
    */
   private final String typeName;
 
-  public AbstractODataValue(String typeName) {
+  public AbstractODataValue(final String typeName) {
     this.typeName = typeName;
   }
 
@@ -79,9 +79,10 @@ public abstract class AbstractODataValue implements ODataValue {
    *
    * @return complex value.
    */
+//  @SuppressWarnings("unchecked")
   @Override
-  public ODataComplexValue asComplex() {
-    return isComplex() ? (ODataComplexValue) this : null;
+  public <OP extends CommonODataProperty> ODataComplexValue<OP> asComplex() {
+    return isComplex() ? (ODataComplexValue<OP>) this : null;
   }
 
   /**
@@ -99,9 +100,10 @@ public abstract class AbstractODataValue implements ODataValue {
    *
    * @return collection value.
    */
+//  @SuppressWarnings("unchecked")
   @Override
-  public ODataCollectionValue asCollection() {
-    return isCollection() ? (ODataCollectionValue) this : null;
+  public <OV extends ODataValue> ODataCollectionValue<OV> asCollection() {
+    return isCollection() ? (ODataCollectionValue<OV>) this : null;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
index 40ffda9..434906e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataObjectFactory.java
@@ -177,9 +177,9 @@ public interface CommonODataObjectFactory {
 
   ODataPrimitiveValue.Builder newPrimitiveValueBuilder();
 
-  ODataComplexValue newComplexValue(String typeName);
+  ODataComplexValue<? extends CommonODataProperty> newComplexValue(String typeName);
 
-  ODataCollectionValue newCollectionValue(String typeName);
+  ODataCollectionValue<? extends ODataValue> newCollectionValue(String typeName);
 
   /**
    * Instantiates a new primitive property.
@@ -197,7 +197,7 @@ public interface CommonODataObjectFactory {
    * @param value value.
    * @return complex property.
    */
-  CommonODataProperty newComplexProperty(String name, ODataComplexValue value);
+  CommonODataProperty newComplexProperty(String name, ODataComplexValue<? extends CommonODataProperty> value);
 
   /**
    * Instantiates a new collection property.
@@ -206,5 +206,5 @@ public interface CommonODataObjectFactory {
    * @param value value.
    * @return collection property.
    */
-  CommonODataProperty newCollectionProperty(String name, ODataCollectionValue value);
+  CommonODataProperty newCollectionProperty(String name, ODataCollectionValue<? extends ODataValue> value);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java
index 99a5131..8eae93e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/CommonODataProperty.java
@@ -68,24 +68,10 @@ public interface CommonODataProperty extends ODataInvokeResult, Serializable {
   boolean hasCollectionValue();
 
   /**
-   * Gets collection value.
-   *
-   * @return collection value if exists; null otherwise.
-   */
-  ODataCollectionValue getCollectionValue();
-
-  /**
    * Checks if has complex value.
    *
    * @return 'TRUE' if has complex value; 'FALSE' otherwise.
    */
   boolean hasComplexValue();
 
-  /**
-   * Gets complex value.
-   *
-   * @return complex value if exists; null otherwise.
-   */
-  ODataComplexValue getComplexValue();
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
index d0daf59..29eedab 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
@@ -20,15 +20,17 @@ package org.apache.olingo.commons.api.domain;
 
 /**
  * OData collection property value.
+ *
+ * @param <OV> The actual ODataValue interface.
  */
-public interface ODataCollectionValue extends ODataValue, Iterable<ODataValue> {
+public interface ODataCollectionValue<OV extends ODataValue> extends ODataValue, Iterable<OV> {
 
   /**
    * Adds a value to the collection.
    *
    * @param value value to be added.
    */
-  void add(ODataValue value);
+  void add(OV value);
 
   /**
    * Checks if collection is empty.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
index b34006c..7eb02c0 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
@@ -20,15 +20,17 @@ package org.apache.olingo.commons.api.domain;
 
 /**
  * OData complex property value.
+ *
+ * @param <OP> The actual ODataProperty interface.
  */
-public interface ODataComplexValue extends ODataValue, Iterable<CommonODataProperty> {
+public interface ODataComplexValue<OP extends CommonODataProperty> extends ODataValue, Iterable<OP> {
 
   /**
    * Adds field to the complex type.
    *
    * @param field field to be added.
    */
-  void add(CommonODataProperty field);
+  void add(OP field);
 
   /**
    * Gets field.
@@ -36,7 +38,7 @@ public interface ODataComplexValue extends ODataValue, Iterable<CommonODataPrope
    * @param name name of the field to be retrieved.
    * @return requested field.
    */
-  CommonODataProperty get(String name);
+  OP get(String name);
 
   /**
    * Gets number of fields.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
index 6db4b2b..0727976 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
@@ -56,9 +56,10 @@ public interface ODataValue extends Serializable {
   /**
    * Casts to collection value.
    *
+   * @param <OV> The actual ODataValue interface.
    * @return collection value.
    */
-  ODataCollectionValue asCollection();
+  <OV extends ODataValue> ODataCollectionValue<OV> asCollection();
 
   /**
    * Check is is a complex value.
@@ -70,8 +71,9 @@ public interface ODataValue extends Serializable {
   /**
    * Casts to complex value.
    *
+   * @param <OP> The actual ODataProperty interface.
    * @return complex value.
    */
-  ODataComplexValue asComplex();
+  <OP extends CommonODataProperty> ODataComplexValue<OP> asComplex();
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java
index 363f1de..31f5ba1 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataObjectFactory.java
@@ -20,9 +20,11 @@ package org.apache.olingo.commons.api.domain.v3;
 
 import java.net.URI;
 import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ODataValue;
 
 public interface ODataObjectFactory extends CommonODataObjectFactory {
 
@@ -39,12 +41,18 @@ public interface ODataObjectFactory extends CommonODataObjectFactory {
   ODataEntity newEntity(String name, URI link);
 
   @Override
+  ODataComplexValue<ODataProperty> newComplexValue(String typeName);
+
+  @Override
+  ODataCollectionValue<ODataValue> newCollectionValue(String typeName);
+
+  @Override
   ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
 
   @Override
-  ODataProperty newComplexProperty(String name, ODataComplexValue value);
+  ODataProperty newComplexProperty(String name, ODataComplexValue<? extends CommonODataProperty> value);
 
   @Override
-  ODataProperty newCollectionProperty(String name, ODataCollectionValue value);
+  ODataProperty newCollectionProperty(String name, ODataCollectionValue<? extends ODataValue> value);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java
index 266d53c..46f1c39 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v3/ODataProperty.java
@@ -19,7 +19,23 @@
 package org.apache.olingo.commons.api.domain.v3;
 
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataValue;
 
 public interface ODataProperty extends CommonODataProperty {
 
+  /**
+   * Gets collection value.
+   *
+   * @return collection value if exists; null otherwise.
+   */
+  ODataCollectionValue<ODataValue> getCollectionValue();
+
+  /**
+   * Gets complex value.
+   *
+   * @return complex value if exists; null otherwise.
+   */
+  ODataComplexValue<ODataProperty> getComplexValue();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
index d12f0dc..67adf57 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataObjectFactory.java
@@ -20,6 +20,7 @@ package org.apache.olingo.commons.api.domain.v4;
 
 import java.net.URI;
 import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
@@ -41,14 +42,21 @@ public interface ODataObjectFactory extends CommonODataObjectFactory {
   ODataEnumValue newEnumValue(String typeName, String value);
 
   @Override
+  ODataComplexValue<ODataProperty> newComplexValue(String typeName);
+
+  @Override
+  ODataCollectionValue<ODataValue> newCollectionValue(String typeName);
+
+  @Override
   ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
 
   ODataProperty newEnumProperty(String name, ODataEnumValue value);
 
   @Override
-  ODataProperty newComplexProperty(String name, ODataComplexValue value);
+  ODataProperty newComplexProperty(String name, ODataComplexValue<? extends CommonODataProperty> value);
 
   @Override
-  ODataProperty newCollectionProperty(String name, ODataCollectionValue value);
+  ODataProperty newCollectionProperty(String name,
+          ODataCollectionValue<? extends org.apache.olingo.commons.api.domain.ODataValue> value);
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
index 61a8193..4666e6e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java
@@ -19,10 +19,26 @@
 package org.apache.olingo.commons.api.domain.v4;
 
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
 
 public interface ODataProperty extends CommonODataProperty {
 
   /**
+   * Gets collection value.
+   *
+   * @return collection value if exists; null otherwise.
+   */
+  ODataCollectionValue<ODataValue> getCollectionValue();
+
+  /**
+   * Gets complex value.
+   *
+   * @return complex value if exists; null otherwise.
+   */
+  ODataComplexValue<ODataProperty> getComplexValue();
+
+  /**
    * Checks if has enum value.
    *
    * @return 'TRUE' if has enum value; 'FALSE' otherwise.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java
new file mode 100644
index 0000000..fe2fd52
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.olingo.commons.api.domain.AbstractODataValue;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataValue;
+
+/**
+ * OData collection property value.
+ *
+ * @param <OV> The actual ODataValue interface.
+ */
+public abstract class AbstractODataCollectionValue<OV extends ODataValue>
+        extends AbstractODataValue implements ODataCollectionValue<OV> {
+
+  private static final long serialVersionUID = -3665659846001987187L;
+
+  /**
+   * Values.
+   */
+  private final List<OV> values = new ArrayList<OV>();
+
+  /**
+   * Constructor.
+   *
+   * @param typeName type name.
+   */
+  public AbstractODataCollectionValue(final String typeName) {
+    super(typeName);
+  }
+
+  /**
+   * Adds a value to the collection.
+   *
+   * @param value value to be added.
+   */
+  @Override
+  public void add(final OV value) {
+    if (value.isPrimitive() || value.isComplex()) {
+      values.add(value);
+    }
+  }
+
+  /**
+   * Value iterator.
+   *
+   * @return value iterator.
+   */
+  @Override
+  public Iterator<OV> iterator() {
+    return values.iterator();
+  }
+
+  /**
+   * Gets collection size.
+   *
+   * @return collection size.
+   */
+  @Override
+  public int size() {
+    return values.size();
+  }
+
+  /**
+   * Checks if collection is empty.
+   *
+   * @return 'TRUE' if empty; 'FALSE' otherwise.
+   */
+  @Override
+  public boolean isEmpty() {
+    return values.isEmpty();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java
new file mode 100644
index 0000000..6a09664
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.olingo.commons.api.domain.AbstractODataValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+
+/**
+ * OData complex property value.
+ *
+ * @param <OP> The actual ODataProperty interface.
+ */
+public abstract class AbstractODataComplexValue<OP extends CommonODataProperty>
+        extends AbstractODataValue implements ODataComplexValue<OP> {
+
+  private static final long serialVersionUID = -1878555027714020431L;
+
+  /**
+   * Complex type fields.
+   */
+  private final Map<String, OP> fields = new LinkedHashMap<String, OP>();
+
+  /**
+   * Constructor.
+   *
+   * @param typeName type name.
+   */
+  public AbstractODataComplexValue(final String typeName) {
+    super(typeName);
+  }
+
+  /**
+   * Adds field to the complex type.
+   *
+   * @param field field to be added.
+   */
+  @Override
+  @SuppressWarnings("unchecked")
+  public void add(final CommonODataProperty field) {
+    fields.put(field.getName(), (OP) field);
+  }
+
+  /**
+   * Gets field.
+   *
+   * @param name name of the field to be retrieved.
+   * @return requested field.
+   */
+  @Override
+  public OP get(final String name) {
+    return fields.get(name);
+  }
+
+  /**
+   * Complex property fields iterator.
+   *
+   * @return fields iterator.
+   */
+  @Override
+  public Iterator<OP> iterator() {
+    return fields.values().iterator();
+  }
+
+  /**
+   * Gets number of fields.
+   *
+   * @return number of fields.
+   */
+  @Override
+  public int size() {
+    return fields.size();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
index a3133cd..43853fa 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
@@ -20,15 +20,12 @@ package org.apache.olingo.commons.core.domain;
 
 import java.net.URI;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.domain.ODataInlineEntity;
 import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 
 public abstract class AbstractODataObjectFactory implements CommonODataObjectFactory {
@@ -115,19 +112,4 @@ public abstract class AbstractODataObjectFactory implements CommonODataObjectFac
             setType(ODataLinkType.MEDIA_EDIT).setTitle(name).build();
   }
 
-  @Override
-  public ODataPrimitiveValue.Builder newPrimitiveValueBuilder() {
-    return new ODataPrimitiveValueImpl.BuilderImpl(version);
-  }
-
-  @Override
-  public ODataComplexValue newComplexValue(final String typeName) {
-    return new ODataComplexValueImpl(typeName);
-  }
-
-  @Override
-  public ODataCollectionValue newCollectionValue(final String typeName) {
-    return new ODataCollectionValueImpl(typeName);
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java
new file mode 100644
index 0000000..9d2d6ec
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.domain.AbstractODataValue;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+public abstract class AbstractODataPrimitiveValue extends AbstractODataValue implements ODataPrimitiveValue {
+
+  private static final long serialVersionUID = 8889282662298376036L;
+
+  public static abstract class AbstractBuilder implements Builder {
+
+    private final ODataServiceVersion version;
+
+    public AbstractBuilder(final ODataServiceVersion version) {
+      this.version = version;
+    }
+
+    protected abstract AbstractODataPrimitiveValue getInstance();
+
+    @Override
+    public AbstractBuilder setType(final EdmPrimitiveTypeKind type) {
+      if (type != null && !type.getSupportedVersions().contains(version)) {
+        throw new IllegalArgumentException(String.format(
+                "Type %s not supported by OData version %s", type.toString(), version));
+      }
+      if (type == EdmPrimitiveTypeKind.Stream) {
+        throw new IllegalArgumentException(String.format(
+                "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString()));
+      }
+      if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) {
+        throw new IllegalArgumentException(
+                type + "is not an instantiable type. "
+                + "An entity can declare a property to be of type Geometry. "
+                + "An instance of an entity MUST NOT have a value of type Geometry. "
+                + "Each value MUST be of some subtype.");
+      }
+
+      getInstance().typeKind = type == null ? EdmPrimitiveTypeKind.String : type;
+      getInstance().type = EdmPrimitiveTypeFactory.getInstance(getInstance().typeKind);
+
+      return this;
+    }
+
+    @Override
+    public AbstractBuilder setText(final String text) {
+      getInstance().text = text;
+      return this;
+    }
+
+    @Override
+    public AbstractBuilder setValue(final Object value) {
+      getInstance().value = value;
+      return this;
+    }
+
+    @Override
+    public AbstractODataPrimitiveValue build() {
+      if (getInstance().text == null && getInstance().value == null) {
+        throw new IllegalArgumentException("Must provide either text or value");
+      }
+      if (getInstance().text != null && getInstance().value != null) {
+        throw new IllegalArgumentException("Cannot provide both text and value");
+      }
+
+      if (getInstance().type == null) {
+        setType(EdmPrimitiveTypeKind.String);
+      }
+
+      if (getInstance().text != null) {
+        final Class<?> returnType = getInstance().type.getDefaultType().isAssignableFrom(Calendar.class)
+                ? Timestamp.class : getInstance().type.getDefaultType();
+        try {
+          // TODO: when Edm is available, set facets when calling this method
+          getInstance().value = getInstance().type.valueOfString(
+                  getInstance().text, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null,
+                  returnType);
+        } catch (EdmPrimitiveTypeException e) {
+          throw new IllegalArgumentException(e);
+        }
+      }
+      if (getInstance().value != null) {
+        try {
+          // TODO: when Edm is available, set facets when calling this method
+          getInstance().text = getInstance().type.valueToString(
+                  getInstance().value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
+        } catch (EdmPrimitiveTypeException e) {
+          throw new IllegalArgumentException(e);
+        }
+      }
+
+      return getInstance();
+    }
+  }
+
+  /**
+   * Type kind.
+   */
+  private EdmPrimitiveTypeKind typeKind;
+
+  /**
+   * Type.
+   */
+  private EdmPrimitiveType type;
+
+  /**
+   * Text value.
+   */
+  private String text;
+
+  /**
+   * Actual value.
+   */
+  private Object value;
+
+  protected AbstractODataPrimitiveValue() {
+    super(null);
+  }
+
+  @Override
+  public String getTypeName() {
+    return typeKind.getFullQualifiedName().toString();
+  }
+
+  @Override
+  public EdmPrimitiveTypeKind getTypeKind() {
+    return typeKind;
+  }
+
+  @Override
+  public EdmPrimitiveType getType() {
+    return type;
+  }
+
+  @Override
+  public Object toValue() {
+    return this.value;
+  }
+
+  @Override
+  public <T> T toCastValue(final Class<T> reference) throws EdmPrimitiveTypeException {
+    return typeKind.isGeospatial()
+            ? reference.cast(this.value)
+            // TODO: when Edm is available, set facets when calling this method
+            : type.valueOfString(this.text,
+                    null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference);
+  }
+
+  @Override
+  public String toString() {
+    return this.text;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
index c68dfab..532303c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
@@ -22,8 +22,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
@@ -114,16 +112,6 @@ public abstract class AbstractODataProperty implements CommonODataProperty {
   }
 
   /**
-   * Gets complex value.
-   *
-   * @return complex value if exists; null otherwise.
-   */
-  @Override
-  public ODataComplexValue getComplexValue() {
-    return hasComplexValue() ? this.value.asComplex() : null;
-  }
-
-  /**
    * Checks if has collection value.
    *
    * @return 'TRUE' if has collection value; 'FALSE' otherwise.
@@ -134,16 +122,6 @@ public abstract class AbstractODataProperty implements CommonODataProperty {
   }
 
   /**
-   * Gets collection value.
-   *
-   * @return collection value if exists; null otherwise.
-   */
-  @Override
-  public ODataCollectionValue getCollectionValue() {
-    return hasCollectionValue() ? this.value.asCollection() : null;
-  }
-
-  /**
    * {@inheritDoc }
    */
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
deleted file mode 100644
index 1189aae..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.domain;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataValue;
-
-/**
- * OData collection property value.
- */
-public class ODataCollectionValueImpl extends AbstractODataValue implements ODataCollectionValue {
-
-  private static final long serialVersionUID = -3665659846001987187L;
-
-  /**
-   * Values.
-   */
-  private final List<ODataValue> values = new ArrayList<ODataValue>();
-
-  /**
-   * Constructor.
-   *
-   * @param typeName type name.
-   */
-  public ODataCollectionValueImpl(final String typeName) {
-    super(typeName);
-  }
-
-  /**
-   * Adds a value to the collection.
-   *
-   * @param value value to be added.
-   */
-  @Override
-  public void add(final ODataValue value) {
-    if (value.isPrimitive() || value.isComplex()) {
-      values.add(value);
-    }
-  }
-
-  /**
-   * Value iterator.
-   *
-   * @return value iterator.
-   */
-  @Override
-  public Iterator<ODataValue> iterator() {
-    return values.iterator();
-  }
-
-  /**
-   * Gets collection size.
-   *
-   * @return collection size.
-   */
-  @Override
-  public int size() {
-    return values.size();
-  }
-
-  /**
-   * Checks if collection is empty.
-   *
-   * @return 'TRUE' if empty; 'FALSE' otherwise.
-   */
-  @Override
-  public boolean isEmpty() {
-    return values.isEmpty();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
deleted file mode 100644
index ba8fe56..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.domain;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-
-/**
- * OData complex property value.
- */
-public class ODataComplexValueImpl extends AbstractODataValue implements ODataComplexValue {
-
-  private static final long serialVersionUID = -1878555027714020431L;
-
-  /**
-   * Complex type fields.
-   */
-  private final Map<String, CommonODataProperty> fields = new LinkedHashMap<String, CommonODataProperty>();
-
-  /**
-   * Constructor.
-   *
-   * @param typeName type name.
-   */
-  public ODataComplexValueImpl(final String typeName) {
-    super(typeName);
-  }
-
-  /**
-   * Adds field to the complex type.
-   *
-   * @param field field to be added.
-   */
-  @Override
-  public void add(final CommonODataProperty field) {
-    fields.put(field.getName(), field);
-  }
-
-  /**
-   * Gets field.
-   *
-   * @param name name of the field to be retrieved.
-   * @return requested field.
-   */
-  @Override
-  public CommonODataProperty get(final String name) {
-    return fields.get(name);
-  }
-
-  /**
-   * Complex property fields iterator.
-   *
-   * @return fields iterator.
-   */
-  @Override
-  public Iterator<CommonODataProperty> iterator() {
-    return fields.values().iterator();
-  }
-
-  /**
-   * Gets number of fields.
-   *
-   * @return number of fields.
-   */
-  @Override
-  public int size() {
-    return fields.size();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
deleted file mode 100644
index 965d5fc..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.domain;
-
-import java.sql.Timestamp;
-import java.util.Calendar;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-
-public class ODataPrimitiveValueImpl extends AbstractODataValue implements ODataPrimitiveValue {
-
-  private static final long serialVersionUID = 8889282662298376036L;
-
-  public static class BuilderImpl implements Builder {
-
-    private final ODataServiceVersion version;
-
-    private final ODataPrimitiveValueImpl instance;
-
-    public BuilderImpl(final ODataServiceVersion version) {
-      this.version = version;
-      this.instance = new ODataPrimitiveValueImpl();
-    }
-
-    @Override
-    public BuilderImpl setType(final EdmPrimitiveTypeKind type) {
-      if (type != null && !type.getSupportedVersions().contains(version)) {
-        throw new IllegalArgumentException(String.format(
-                "Type %s not supported by OData version %s", type.toString(), version));
-      }
-      if (type == EdmPrimitiveTypeKind.Stream) {
-        throw new IllegalArgumentException(String.format(
-                "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString()));
-      }
-      if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) {
-        throw new IllegalArgumentException(
-                type + "is not an instantiable type. "
-                + "An entity can declare a property to be of type Geometry. "
-                + "An instance of an entity MUST NOT have a value of type Geometry. "
-                + "Each value MUST be of some subtype.");
-      }
-
-      this.instance.typeKind = type == null ? EdmPrimitiveTypeKind.String : type;
-      this.instance.type = EdmPrimitiveTypeFactory.getInstance(this.instance.typeKind);
-
-      return this;
-    }
-
-    @Override
-    public BuilderImpl setText(final String text) {
-      this.instance.text = text;
-      return this;
-    }
-
-    @Override
-    public BuilderImpl setValue(final Object value) {
-      this.instance.value = value;
-      return this;
-    }
-
-    @Override
-    public ODataPrimitiveValueImpl build() {
-      if (this.instance.text == null && this.instance.value == null) {
-        throw new IllegalArgumentException("Must provide either text or value");
-      }
-      if (this.instance.text != null && this.instance.value != null) {
-        throw new IllegalArgumentException("Cannot provide both text and value");
-      }
-
-      if (this.instance.type == null) {
-        setType(EdmPrimitiveTypeKind.String);
-      }
-
-      if (this.instance.text != null) {
-        final Class<?> returnType = this.instance.type.getDefaultType().isAssignableFrom(Calendar.class)
-                ? Timestamp.class : this.instance.type.getDefaultType();
-        try {
-          // TODO: when Edm is available, set facets when calling this method
-          this.instance.value = this.instance.type.valueOfString(
-                  this.instance.text, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null,
-                  returnType);
-        } catch (EdmPrimitiveTypeException e) {
-          throw new IllegalArgumentException(e);
-        }
-      }
-      if (this.instance.value != null) {
-        try {
-          // TODO: when Edm is available, set facets when calling this method
-          this.instance.text = this.instance.type.valueToString(
-                  this.instance.value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
-        } catch (EdmPrimitiveTypeException e) {
-          throw new IllegalArgumentException(e);
-        }
-      }
-
-      return this.instance;
-    }
-  }
-
-  /**
-   * Type kind.
-   */
-  private EdmPrimitiveTypeKind typeKind;
-
-  /**
-   * Type.
-   */
-  private EdmPrimitiveType type;
-
-  /**
-   * Text value.
-   */
-  private String text;
-
-  /**
-   * Actual value.
-   */
-  private Object value;
-
-  private ODataPrimitiveValueImpl() {
-    super(null);
-  }
-
-  @Override
-  public String getTypeName() {
-    return typeKind.getFullQualifiedName().toString();
-  }
-
-  @Override
-  public EdmPrimitiveTypeKind getTypeKind() {
-    return typeKind;
-  }
-
-  @Override
-  public EdmPrimitiveType getType() {
-    return type;
-  }
-
-  @Override
-  public Object toValue() {
-    return this.value;
-  }
-
-  @Override
-  public <T> T toCastValue(final Class<T> reference) throws EdmPrimitiveTypeException {
-    return typeKind.isGeospatial()
-            ? reference.cast(this.value)
-            // TODO: when Edm is available, set facets when calling this method
-            : type.valueOfString(this.text,
-                    null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference);
-  }
-
-  @Override
-  public String toString() {
-    return this.text;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataCollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataCollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataCollectionValueImpl.java
new file mode 100644
index 0000000..1ebd62a
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataCollectionValueImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v3;
+
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.core.domain.AbstractODataCollectionValue;
+
+public class ODataCollectionValueImpl extends AbstractODataCollectionValue<ODataValue> {
+
+  private static final long serialVersionUID = 5887168245885401351L;
+
+  public ODataCollectionValueImpl(final String typeName) {
+    super(typeName);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataComplexValueImpl.java
new file mode 100644
index 0000000..4b09fcc
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataComplexValueImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v3;
+
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.core.domain.AbstractODataComplexValue;
+
+public class ODataComplexValueImpl extends AbstractODataComplexValue<ODataProperty> {
+
+  private static final long serialVersionUID = 1143925901934898802L;
+
+  public ODataComplexValueImpl(final String typeName) {
+    super(typeName);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java
index 2bfb8f5..18f9e13 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java
@@ -19,9 +19,11 @@
 package org.apache.olingo.commons.core.domain.v3;
 
 import java.net.URI;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
 import org.apache.olingo.commons.api.domain.v3.ODataEntity;
@@ -58,17 +60,36 @@ public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implement
   }
 
   @Override
+  public ODataPrimitiveValue.Builder newPrimitiveValueBuilder() {
+    return new ODataPrimitiveValueImpl.BuilderImpl(version);
+  }
+
+  @Override
+  public ODataComplexValue<ODataProperty> newComplexValue(final String typeName) {
+    return new ODataComplexValueImpl(typeName);
+  }
+
+  @Override
+  public ODataCollectionValue<ODataValue> newCollectionValue(final String typeName) {
+    return new ODataCollectionValueImpl(typeName);
+  }
+
+  @Override
   public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
     return new ODataPropertyImpl(name, value);
   }
 
   @Override
-  public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
+  public ODataProperty newComplexProperty(final String name,
+          final ODataComplexValue<? extends CommonODataProperty> value) {
+
     return new ODataPropertyImpl(name, value);
   }
 
   @Override
-  public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
+  public ODataProperty newCollectionProperty(final String name,
+          final ODataCollectionValue<? extends ODataValue> value) {
+
     return new ODataPropertyImpl(name, value);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java
new file mode 100644
index 0000000..6dc3034
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v3;
+
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.domain.AbstractODataPrimitiveValue;
+
+public class ODataPrimitiveValueImpl extends AbstractODataPrimitiveValue {
+
+  private static final long serialVersionUID = -5201738902625613179L;
+
+  public static class BuilderImpl extends AbstractBuilder {
+
+    private final ODataPrimitiveValueImpl instance;
+
+    public BuilderImpl(final ODataServiceVersion version) {
+      super(version);
+      this.instance = new ODataPrimitiveValueImpl();
+    }
+
+    @Override
+    protected AbstractODataPrimitiveValue getInstance() {
+      return instance;
+    }
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java
index 68c44ec..45eb01f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java
@@ -18,6 +18,8 @@
  */
 package org.apache.olingo.commons.core.domain.v3;
 
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.core.domain.AbstractODataProperty;
@@ -30,4 +32,14 @@ public class ODataPropertyImpl extends AbstractODataProperty implements ODataPro
     super(name, value);
   }
 
+  @Override
+  public ODataComplexValue<ODataProperty> getComplexValue() {
+    return hasComplexValue() ? getValue().<ODataProperty>asComplex() : null;
+  }
+
+  @Override
+  public ODataCollectionValue<ODataValue> getCollectionValue() {
+    return hasCollectionValue() ? getValue().<ODataValue>asCollection() : null;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java
new file mode 100644
index 0000000..b0e0539
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v4;
+
+import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
+import org.apache.olingo.commons.api.domain.v4.ODataValue;
+import org.apache.olingo.commons.core.domain.AbstractODataCollectionValue;
+
+public class ODataCollectionValueImpl extends AbstractODataCollectionValue<ODataValue> implements ODataValue {
+
+  private static final long serialVersionUID = 5887168245885401351L;
+
+  public ODataCollectionValueImpl(final String typeName) {
+    super(typeName);
+  }
+
+  @Override
+  public boolean isEnum() {
+    return false;
+  }
+
+  @Override
+  public ODataEnumValue asEnum() {
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
new file mode 100644
index 0000000..7c6e72f
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v4;
+
+import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.domain.v4.ODataValue;
+import org.apache.olingo.commons.core.domain.AbstractODataComplexValue;
+
+public class ODataComplexValueImpl extends AbstractODataComplexValue<ODataProperty> implements ODataValue {
+
+  private static final long serialVersionUID = 1143925901934898802L;
+
+  public ODataComplexValueImpl(final String typeName) {
+    super(typeName);
+  }
+
+  @Override
+  public boolean isEnum() {
+    return false;
+  }
+
+  @Override
+  public ODataEnumValue asEnum() {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
index 0a84407..4f46a76 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.commons.core.domain.v4;
 
 import java.net.URI;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
@@ -27,6 +28,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.domain.v4.ODataValue;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.domain.AbstractODataObjectFactory;
 
@@ -59,22 +61,41 @@ public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implement
   }
 
   @Override
+  public ODataPrimitiveValue.Builder newPrimitiveValueBuilder() {
+    return new ODataPrimitiveValueImpl.BuilderImpl(version);
+  }
+
+  @Override
   public ODataEnumValue newEnumValue(final String typeName, final String value) {
     return new ODataEnumValueImpl(typeName, value);
   }
 
   @Override
+  public ODataComplexValue<ODataProperty> newComplexValue(final String typeName) {
+    return new ODataComplexValueImpl(typeName);
+  }
+
+  @Override
+  public ODataCollectionValue<ODataValue> newCollectionValue(final String typeName) {
+    return new ODataCollectionValueImpl(typeName);
+  }
+
+  @Override
   public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
     return new ODataPropertyImpl(name, value);
   }
 
   @Override
-  public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
+  public ODataProperty newComplexProperty(final String name,
+          final ODataComplexValue<? extends CommonODataProperty> value) {
+
     return new ODataPropertyImpl(name, value);
   }
 
   @Override
-  public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
+  public ODataProperty newCollectionProperty(final String name,
+          final ODataCollectionValue<? extends org.apache.olingo.commons.api.domain.ODataValue> value) {
+
     return new ODataPropertyImpl(name, value);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java
new file mode 100644
index 0000000..0d7ace8
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain.v4;
+
+import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
+import org.apache.olingo.commons.api.domain.v4.ODataValue;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.domain.AbstractODataPrimitiveValue;
+
+public class ODataPrimitiveValueImpl extends AbstractODataPrimitiveValue implements ODataValue {
+
+  private static final long serialVersionUID = -5201738902625613179L;
+
+  public static class BuilderImpl extends AbstractBuilder {
+
+    private final ODataPrimitiveValueImpl instance;
+
+    public BuilderImpl(final ODataServiceVersion version) {
+      super(version);
+      this.instance = new ODataPrimitiveValueImpl();
+    }
+
+    @Override
+    protected AbstractODataPrimitiveValue getInstance() {
+      return instance;
+    }
+
+  }
+
+  @Override
+  public boolean isEnum() {
+    return false;
+  }
+
+  @Override
+  public ODataEnumValue asEnum() {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
index fe6bf9d..85cdf67 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
@@ -18,8 +18,11 @@
  */
 package org.apache.olingo.commons.core.domain.v4;
 
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.domain.v4.ODataValue;
 import org.apache.olingo.commons.core.domain.AbstractODataProperty;
 
 public class ODataPropertyImpl extends AbstractODataProperty implements ODataProperty {
@@ -41,4 +44,14 @@ public class ODataPropertyImpl extends AbstractODataProperty implements ODataPro
     return hasEnumValue() ? ((org.apache.olingo.commons.api.domain.v4.ODataValue) getValue()).asEnum() : null;
   }
 
+  @Override
+  public ODataComplexValue<ODataProperty> getComplexValue() {
+    return hasComplexValue() ? getValue().<ODataProperty>asComplex() : null;
+  }
+
+  @Override
+  public ODataCollectionValue<ODataValue> getCollectionValue() {
+    return hasCollectionValue() ? getValue().<ODataValue>asCollection() : null;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6b0668b..01136c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -231,6 +231,11 @@
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>3.1</version>
+          <configuration>
+            <showWarnings>true</showWarnings>
+            <showDeprecation>true</showDeprecation>
+            <compilerArgument>-Xlint:unchecked</compilerArgument>
+          </configuration>
         </plugin>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>


[3/4] [OLINGO-200] V4 ODataValue full reachable via API

Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AbstractTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AbstractTestITCase.java
index 3dc766e..325f2dd 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AbstractTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/AbstractTestITCase.java
@@ -19,11 +19,72 @@
 package org.apache.olingo.client.core.it.v3;
 
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.request.cud.UpdateType;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
+import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.uri.CommonURIBuilder;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataInlineEntity;
+import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.core.data.AtomEntryImpl;
+import org.apache.olingo.commons.core.data.JSONEntryImpl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractTestITCase {
+
+  /**
+   * Logger.
+   */
+  protected static final Logger LOG = LoggerFactory.getLogger(AbstractTestITCase.class);
+
+  protected static final String TEST_PRODUCT_TYPE = "Microsoft.Test.OData.Services.AstoriaDefaultService.Product";
 
-public abstract class AbstractTestITCase extends org.apache.olingo.client.core.it.AbstractTestITCase {
+  protected static final String servicesODataServiceRootURL =
+          "http://services.odata.org/V3/(S(csquyjnoaywmz5xcdbfhlc1p))/OData/OData.svc/";
 
   protected static ODataClient client;
 
@@ -45,8 +106,473 @@ public abstract class AbstractTestITCase extends org.apache.olingo.client.core.i
     client = ODataClientFactory.getV3();
   }
 
-  @Override
   protected ODataClient getClient() {
     return client;
   }
+
+  protected void checkLinks(final Collection<ODataLink> original, final Collection<ODataLink> actual) {
+    assertTrue(original.size() <= actual.size());
+
+    for (ODataLink originalLink : original) {
+      ODataLink foundOriginal = null;
+      ODataLink foundActual = null;
+
+      for (ODataLink actualLink : actual) {
+
+        if (actualLink.getType() == originalLink.getType()
+                && (originalLink.getLink() == null
+                || actualLink.getLink().toASCIIString().endsWith(originalLink.getLink().toASCIIString()))
+                && actualLink.getName().equals(originalLink.getName())) {
+
+          foundOriginal = originalLink;
+          foundActual = actualLink;
+        }
+      }
+
+      assertNotNull(foundOriginal);
+      assertNotNull(foundActual);
+
+      if (foundOriginal instanceof ODataInlineEntity && foundActual instanceof ODataInlineEntity) {
+        final CommonODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
+        assertNotNull(originalInline);
+
+        final CommonODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
+        assertNotNull(actualInline);
+
+        checkProperties(originalInline.getProperties(), actualInline.getProperties());
+      }
+    }
+  }
+
+  protected void checkProperties(final Collection<? extends CommonODataProperty> original,
+          final Collection<? extends CommonODataProperty> actual) {
+
+    assertTrue(original.size() <= actual.size());
+
+    // re-organize actual properties into a Map<String, ODataProperty>
+    final Map<String, CommonODataProperty> actualProps = new HashMap<String, CommonODataProperty>(actual.size());
+
+    for (CommonODataProperty prop : actual) {
+      assertFalse(actualProps.containsKey(prop.getName()));
+      actualProps.put(prop.getName(), prop);
+    }
+
+    assertTrue(actual.size() <= actualProps.size());
+
+    for (CommonODataProperty prop : original) {
+      assertNotNull(prop);
+      if (actualProps.containsKey(prop.getName())) {
+        final CommonODataProperty actualProp = actualProps.get(prop.getName());
+        assertNotNull(actualProp);
+
+        if (prop.getValue() != null && actualProp.getValue() != null) {
+          checkPropertyValue(prop.getName(), prop.getValue(), actualProp.getValue());
+        }
+      } else {
+        // nothing ... maybe :FC_KeepInContent="false"
+        // ..... no assert can be done ....
+      }
+    }
+  }
+
+  protected void checkPropertyValue(final String propertyName,
+          final ODataValue original, final ODataValue actual) {
+
+    assertNotNull("Null original value for " + propertyName, original);
+    assertNotNull("Null actual value for " + propertyName, actual);
+
+    assertEquals("Type mismatch for '" + propertyName + "': "
+            + original.getClass().getSimpleName() + "-" + actual.getClass().getSimpleName(),
+            original.getClass().getSimpleName(), actual.getClass().getSimpleName());
+
+    if (original.isComplex()) {
+      final List<CommonODataProperty> originalFileds = new ArrayList<CommonODataProperty>();
+      for (CommonODataProperty prop : original.asComplex()) {
+        originalFileds.add(prop);
+      }
+
+      final List<CommonODataProperty> actualFileds = new ArrayList<CommonODataProperty>();
+      for (CommonODataProperty prop : actual.asComplex()) {
+        actualFileds.add(prop);
+      }
+
+      checkProperties(originalFileds, actualFileds);
+    } else if (original.isCollection()) {
+      assertTrue(original.asCollection().size() <= actual.asCollection().size());
+
+      boolean found = original.asCollection().isEmpty();
+
+      for (ODataValue originalValue : original.asCollection()) {
+        for (ODataValue actualValue : actual.asCollection()) {
+          try {
+            checkPropertyValue(propertyName, originalValue, actualValue);
+            found = true;
+          } catch (AssertionError ignore) {
+            // ignore
+          }
+        }
+      }
+
+      assertTrue("Found " + actual + " but expected " + original, found);
+    } else {
+      assertTrue("Primitive value for '" + propertyName + "' type mismatch: " + original.asPrimitive().
+              getTypeKind() + "-" + actual.asPrimitive().getTypeKind(),
+              original.asPrimitive().getTypeKind().equals(actual.asPrimitive().getTypeKind()));
+
+      assertEquals("Primitive value for '" + propertyName + "' mismatch: " + original.asPrimitive().toString()
+              + "-" + actual.asPrimitive().toString(),
+              original.asPrimitive().toString(), actual.asPrimitive().toString());
+    }
+  }
+
+  protected ODataEntity getSampleCustomerInfo(final int id, final String sampleinfo) {
+    final ODataEntity entity = getClient().getObjectFactory().newEntity(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
+    entity.setMediaEntity(true);
+
+    getClient().getBinder().add(entity,
+            getClient().getObjectFactory().newPrimitiveProperty("Information",
+                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleinfo).
+                    setType(EdmPrimitiveTypeKind.String).build()));
+
+    return entity;
+  }
+
+  protected ODataEntity getSampleCustomerProfile(
+          final int id, final String sampleName, final boolean withInlineInfo) {
+
+    final ODataEntity entity =
+            getClient().getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
+
+    // add name attribute
+    getClient().getBinder().add(entity,
+            getClient().getObjectFactory().newPrimitiveProperty("Name",
+                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleName).
+                    setType(EdmPrimitiveTypeKind.String).build()));
+
+    // add key attribute
+    getClient().getBinder().add(entity,
+            getClient().getObjectFactory().newPrimitiveProperty("CustomerId",
+                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)).
+                    setType(EdmPrimitiveTypeKind.Int32).build()));
+
+    // add BackupContactInfo attribute (collection)
+    final ODataCollectionValue<ODataValue> backupContactInfoValue = getClient().getObjectFactory().newCollectionValue(
+            "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)");
+    getClient().getBinder().add(entity,
+            getClient().getObjectFactory().newCollectionProperty("BackupContactInfo", backupContactInfoValue));
+
+    // add BackupContactInfo.ContactDetails attribute (complex)
+    final ODataComplexValue<ODataProperty> contactDetails = getClient().getObjectFactory().newComplexValue(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails");
+    backupContactInfoValue.add(contactDetails);
+
+    // add BackupContactInfo.ContactDetails.AlternativeNames attribute (collection)
+    final ODataCollectionValue<ODataValue> altNamesValue = getClient().getObjectFactory().
+            newCollectionValue("Collection(Edm.String)");
+    altNamesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
+            setText("myname").setType(EdmPrimitiveTypeKind.String).build());
+    contactDetails.add(getClient().getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue));
+
+    // add BackupContactInfo.ContactDetails.EmailBag attribute (collection)
+    final ODataCollectionValue<ODataValue> emailBagValue = getClient().getObjectFactory().
+            newCollectionValue("Collection(Edm.String)");
+    emailBagValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
+            setText("myname@mydomain.com").setType(EdmPrimitiveTypeKind.String).build());
+    contactDetails.add(getClient().getObjectFactory().newCollectionProperty("EmailBag", emailBagValue));
+
+    // add BackupContactInfo.ContactDetails.ContactAlias attribute (complex)
+    final ODataComplexValue<ODataProperty> contactAliasValue = getClient().getObjectFactory().newComplexValue(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.Aliases");
+    contactDetails.add(getClient().getObjectFactory().newComplexProperty("ContactAlias", contactAliasValue));
+
+    // add BackupContactInfo.ContactDetails.ContactAlias.AlternativeNames attribute (collection)
+    final ODataCollectionValue<ODataValue> aliasAltNamesValue = getClient().getObjectFactory().
+            newCollectionValue("Collection(Edm.String)");
+    aliasAltNamesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
+            setText("myAlternativeName").setType(EdmPrimitiveTypeKind.String).build());
+    contactAliasValue.add(getClient().getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue));
+
+    if (withInlineInfo) {
+      final ODataInlineEntity inlineInfo = getClient().getObjectFactory().newInlineEntity(
+              "Info",
+              URI.create("Customer(" + id + ")/Info"),
+              getSampleCustomerInfo(id, sampleName + "_Info"));
+      inlineInfo.getEntity().setMediaEntity(true);
+      entity.addLink(inlineInfo);
+    }
+
+    return entity;
+  }
+
+  protected void debugEntry(final Entry entry, final String message) {
+    if (LOG.isDebugEnabled()) {
+      final StringWriter writer = new StringWriter();
+      getClient().getSerializer().entry(entry, writer);
+      writer.flush();
+      LOG.debug(message + "\n{}", writer.toString());
+    }
+  }
+
+  protected void debugFeed(final Feed feed, final String message) {
+    if (LOG.isDebugEnabled()) {
+      final StringWriter writer = new StringWriter();
+      getClient().getSerializer().feed(feed, writer);
+      writer.flush();
+      LOG.debug(message + "\n{}", writer.toString());
+    }
+  }
+
+  protected void debugODataProperty(final ODataProperty property, final String message) {
+    LOG.debug(message + "\n{}", property.toString());
+  }
+
+  protected void debugODataValue(final ODataValue value, final String message) {
+    LOG.debug(message + "\n{}", value.toString());
+  }
+
+  protected void debugODataEntity(final ODataEntity entity, final String message) {
+    if (LOG.isDebugEnabled()) {
+      StringWriter writer = new StringWriter();
+      getClient().getSerializer().entry(getClient().getBinder().getEntry(entity, AtomEntryImpl.class), writer);
+      writer.flush();
+      LOG.debug(message + " (Atom)\n{}", writer.toString());
+
+      writer = new StringWriter();
+      getClient().getSerializer().entry(getClient().getBinder().getEntry(entity, JSONEntryImpl.class), writer);
+      writer.flush();
+      LOG.debug(message + " (JSON)\n{}", writer.toString());
+    }
+  }
+
+  protected void debugInputStream(final InputStream input, final String message) {
+    if (LOG.isDebugEnabled()) {
+      try {
+        LOG.debug(message + "\n{}", IOUtils.toString(input));
+      } catch (IOException e) {
+        LOG.error("Error writing stream", e);
+      } finally {
+        IOUtils.closeQuietly(input);
+      }
+    }
+  }
+
+  protected String getETag(final URI uri) {
+    final ODataRetrieveResponse<ODataEntity> res = getClient().getRetrieveRequestFactory().
+            getEntityRequest(uri).execute();
+    try {
+      return res.getEtag();
+    } finally {
+      res.close();
+    }
+  }
+
+  protected ODataEntity read(final ODataPubFormat format, final URI editLink) {
+    final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().
+            getEntityRequest(editLink);
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    final ODataEntity entity = res.getBody();
+
+    assertNotNull(entity);
+
+    if (ODataPubFormat.JSON_FULL_METADATA == format || ODataPubFormat.ATOM == format) {
+      assertEquals(req.getURI(), entity.getEditLink());
+    }
+
+    return entity;
+  }
+
+  protected ODataEntity createEntity(
+          final String serviceRootURL,
+          final ODataPubFormat format,
+          final ODataEntity original,
+          final String entitySetName) {
+
+    final CommonURIBuilder<?> uriBuilder = getClient().getURIBuilder(serviceRootURL).
+            appendEntitySetSegment(entitySetName);
+
+    debugODataEntity(original, "About to create");
+
+    final ODataEntityCreateRequest<ODataEntity> createReq =
+            getClient().getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
+    createReq.setFormat(format);
+
+    final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
+    assertEquals(201, createRes.getStatusCode());
+    assertEquals("Created", createRes.getStatusMessage());
+
+    final ODataEntity created = createRes.getBody();
+    assertNotNull(created);
+
+    debugODataEntity(created, "Just created");
+
+    return created;
+  }
+
+  protected ODataEntity compareEntities(final String serviceRootURL,
+          final ODataPubFormat format,
+          final ODataEntity original,
+          final int actualObjectId,
+          final Collection<String> expands) {
+
+    final CommonURIBuilder<?> uriBuilder = getClient().getURIBuilder(serviceRootURL).
+            appendEntitySetSegment("Customer").appendKeySegment(actualObjectId);
+
+    // search expanded
+    if (expands != null) {
+      for (String expand : expands) {
+        uriBuilder.expand(expand);
+      }
+    }
+
+    final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().
+            getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+
+    final ODataEntity actual = res.getBody();
+    assertNotNull(actual);
+
+    // check defined links
+    checkLinks(original.getAssociationLinks(), actual.getAssociationLinks());
+    checkLinks(original.getEditMediaLinks(), actual.getEditMediaLinks());
+    checkLinks(original.getNavigationLinks(), actual.getNavigationLinks());
+
+    // check defined properties equality
+    checkProperties(original.getProperties(), actual.getProperties());
+
+    return actual;
+  }
+
+  protected void cleanAfterCreate(
+          final ODataPubFormat format,
+          final ODataEntity created,
+          final boolean includeInline,
+          final String baseUri) {
+
+    final Set<URI> toBeDeleted = new HashSet<URI>();
+    toBeDeleted.add(created.getEditLink());
+
+    if (includeInline) {
+      for (ODataLink link : created.getNavigationLinks()) {
+        if (link instanceof ODataInlineEntity) {
+          final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
+          if (inline.getEditLink() != null) {
+            toBeDeleted.add(URIUtils.getURI(baseUri, inline.getEditLink().toASCIIString()));
+          }
+        }
+
+        if (link instanceof ODataInlineEntitySet) {
+          final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
+          for (CommonODataEntity entity : inline.getEntities()) {
+            if (entity.getEditLink() != null) {
+              toBeDeleted.add(URIUtils.getURI(baseUri, entity.getEditLink().toASCIIString()));
+            }
+          }
+        }
+      }
+    }
+
+    assertFalse(toBeDeleted.isEmpty());
+
+    for (URI link : toBeDeleted) {
+      final ODataDeleteRequest deleteReq = getClient().getCUDRequestFactory().getDeleteRequest(link);
+      final ODataDeleteResponse deleteRes = deleteReq.execute();
+
+      assertEquals(204, deleteRes.getStatusCode());
+      assertEquals("No Content", deleteRes.getStatusMessage());
+
+      deleteRes.close();
+
+      final ODataEntityRequest<ODataEntity> retrieveReq = getClient().getRetrieveRequestFactory().
+              getEntityRequest(link);
+      // bug that needs to be fixed on the SampleService - cannot get entity not found with header
+      // Accept: application/json;odata=minimalmetadata
+      retrieveReq.setFormat(format == ODataPubFormat.JSON_FULL_METADATA ? ODataPubFormat.JSON : format);
+
+      Exception exception = null;
+      try {
+        retrieveReq.execute();
+        fail();
+      } catch (ODataClientErrorException e) {
+        exception = e;
+        assertEquals(404, e.getStatusLine().getStatusCode());
+      }
+      assertNotNull(exception);
+    }
+  }
+
+  protected void updateEntityDescription(
+          final ODataPubFormat format, final ODataEntity changes, final UpdateType type) {
+
+    updateEntityDescription(format, changes, type, null);
+  }
+
+  protected void updateEntityDescription(
+          final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
+
+    updateEntityStringProperty("Description", format, changes, type, etag);
+  }
+
+  protected void updateEntityStringProperty(final String propertyName,
+          final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
+
+    final URI editLink = changes.getEditLink();
+
+    final String newm = "New " + propertyName + "(" + System.currentTimeMillis() + ")";
+
+    ODataProperty propertyValue = changes.getProperty(propertyName);
+
+    final String oldm;
+    if (propertyValue == null) {
+      oldm = null;
+    } else {
+      oldm = propertyValue.getValue().toString();
+      changes.getProperties().remove(propertyValue);
+    }
+
+    assertNotEquals(newm, oldm);
+
+    getClient().getBinder().add(changes,
+            getClient().getObjectFactory().newPrimitiveProperty(propertyName,
+                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(newm).build()));
+
+    update(type, changes, format, etag);
+
+    final ODataEntity actual = read(format, editLink);
+
+    propertyValue = null;
+
+    for (ODataProperty prop : actual.getProperties()) {
+      if (prop.getName().equals(propertyName)) {
+        propertyValue = prop;
+      }
+    }
+
+    assertNotNull(propertyValue);
+    assertEquals(newm, propertyValue.getValue().toString());
+  }
+
+  protected void update(
+          final UpdateType type, final ODataEntity changes, final ODataPubFormat format, final String etag) {
+    final ODataEntityUpdateRequest req = getClient().getCUDRequestFactory().getEntityUpdateRequest(type, changes);
+
+    if (getClient().getConfiguration().isUseXHTTPMethod()) {
+      assertEquals(HttpMethod.POST, req.getMethod());
+    } else {
+      assertEquals(type.getMethod(), req.getMethod());
+    }
+    req.setFormat(format);
+
+    if (StringUtils.isNotBlank(etag)) {
+      req.setIfMatch(etag); // Product include ETag header into the response .....
+    }
+
+    final ODataEntityUpdateResponse res = req.execute();
+    assertEquals(204, res.getStatusCode());
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
index 2a4efee..c6a7c15 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
@@ -18,6 +18,11 @@
  */
 package org.apache.olingo.client.core.it.v3;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.net.URI;
 import java.util.Collections;
 import java.util.HashSet;
@@ -37,21 +42,14 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
 import org.apache.olingo.client.api.http.NoContentException;
 import org.apache.olingo.client.api.uri.CommonURIBuilder;
 import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -68,10 +66,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createAsAtom() {
     final ODataPubFormat format = ODataPubFormat.ATOM;
     final int id = 1;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
 
     createEntity(getServiceRoot(), format, original, "Customer");
-    final CommonODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
+    final ODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
 
     cleanAfterCreate(format, actual, false, getServiceRoot());
   }
@@ -80,10 +78,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createAsJSON() {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final int id = 2;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
 
     createEntity(getServiceRoot(), format, original, "Customer");
-    final CommonODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
+    final ODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
 
     cleanAfterCreate(format, actual, false, getServiceRoot());
   }
@@ -92,10 +90,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createWithInlineAsAtom() {
     final ODataPubFormat format = ODataPubFormat.ATOM;
     final int id = 3;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
 
     createEntity(getServiceRoot(), format, original, "Customer");
-    final CommonODataEntity actual =
+    final ODataEntity actual =
             compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
 
     cleanAfterCreate(format, actual, true, getServiceRoot());
@@ -106,10 +104,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     // this needs to be full, otherwise there is no mean to recognize links
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final int id = 4;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
 
     createEntity(getServiceRoot(), format, original, "Customer");
-    final CommonODataEntity actual =
+    final ODataEntity actual =
             compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
 
     cleanAfterCreate(format, actual, true, getServiceRoot());
@@ -119,13 +117,13 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createInlineWithoutLinkAsAtom() {
     final ODataPubFormat format = ODataPubFormat.ATOM;
     final int id = 5;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
 
     original.addLink(client.getObjectFactory().newInlineEntity(
             "Info", null, getSampleCustomerInfo(id, "Sample Customer_Info")));
 
     createEntity(getServiceRoot(), format, original, "Customer");
-    final CommonODataEntity actual =
+    final ODataEntity actual =
             compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
 
     boolean found = false;
@@ -146,13 +144,13 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createInlineWithoutLinkAsJSON() {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final int id = 6;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
 
     original.addLink(client.getObjectFactory().newInlineEntity(
             "Info", null, getSampleCustomerInfo(id, "Sample Customer_Info")));
 
     createEntity(getServiceRoot(), format, original, "Customer");
-    final CommonODataEntity actual =
+    final ODataEntity actual =
             compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
 
     boolean found = false;
@@ -172,7 +170,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   @Test
   public void createWithNavigationAsAtom() {
     final ODataPubFormat format = ODataPubFormat.ATOM;
-    final CommonODataEntity actual = createWithNavigationLink(format, 5);
+    final ODataEntity actual = createWithNavigationLink(format, 5);
     cleanAfterCreate(format, actual, false, getServiceRoot());
   }
 
@@ -180,14 +178,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createWithNavigationAsJSON() {
     // this needs to be full, otherwise there is no mean to recognize links
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-    final CommonODataEntity actual = createWithNavigationLink(format, 6);
+    final ODataEntity actual = createWithNavigationLink(format, 6);
     cleanAfterCreate(format, actual, false, getServiceRoot());
   }
 
   @Test
   public void createWithFeedNavigationAsAtom() throws EdmPrimitiveTypeException {
     final ODataPubFormat format = ODataPubFormat.ATOM;
-    final CommonODataEntity actual = createWithFeedNavigationLink(format, 7);
+    final ODataEntity actual = createWithFeedNavigationLink(format, 7);
     cleanAfterCreate(format, actual, false, getServiceRoot());
   }
 
@@ -195,14 +193,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createWithFeedNavigationAsJSON() throws EdmPrimitiveTypeException {
     // this needs to be full, otherwise there is no mean to recognize links
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-    final CommonODataEntity actual = createWithFeedNavigationLink(format, 8);
+    final ODataEntity actual = createWithFeedNavigationLink(format, 8);
     cleanAfterCreate(format, actual, false, getServiceRoot());
   }
 
   @Test
   public void createWithBackNavigationAsAtom() throws EdmPrimitiveTypeException {
     final ODataPubFormat format = ODataPubFormat.ATOM;
-    final CommonODataEntity actual = createWithBackNavigationLink(format, 9);
+    final ODataEntity actual = createWithBackNavigationLink(format, 9);
     cleanAfterCreate(format, actual, true, getServiceRoot());
   }
 
@@ -210,7 +208,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   public void createWithBackNavigationAsJSON() throws EdmPrimitiveTypeException {
     // this needs to be full, otherwise there is no mean to recognize links
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-    final CommonODataEntity actual = createWithBackNavigationLink(format, 10);
+    final ODataEntity actual = createWithBackNavigationLink(format, 10);
     cleanAfterCreate(format, actual, true, getServiceRoot());
   }
 
@@ -227,13 +225,13 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   @Test
   public void createReturnNoContent() {
     final int id = 1;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+    final ODataEntity original = (ODataEntity) getSampleCustomerProfile(id, "Sample customer", false);
 
-    final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
+    final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(
             client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").build(), original);
     createReq.setPrefer(new ODataPreferences(client.getServiceVersion()).returnNoContent());
 
-    final ODataEntityCreateResponse createRes = createReq.execute();
+    final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
     assertEquals(204, createRes.getStatusCode());
     assertEquals(new ODataPreferences(client.getServiceVersion()).returnNoContent(),
             createRes.getHeader(HeaderName.preferenceApplied).iterator().next());
@@ -255,10 +253,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   @Ignore
   public void issue135() {
     final int id = 2;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer for issue 135", false);
+    final ODataEntity original = (ODataEntity) getSampleCustomerProfile(id, "Sample customer for issue 135", false);
 
     final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer");
-    final ODataEntityCreateRequest createReq =
+    final ODataEntityCreateRequest<ODataEntity> createReq =
             client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
     createReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
     createReq.setContentType(ContentType.APPLICATION_ATOM_XML.getMimeType());
@@ -278,18 +276,18 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     }
   }
 
-  private CommonODataEntity createWithFeedNavigationLink(final ODataPubFormat format, final int id)
+  private ODataEntity createWithFeedNavigationLink(final ODataPubFormat format, final int id)
           throws EdmPrimitiveTypeException {
 
     final String sampleName = "Sample customer";
-    final CommonODataEntity original = getSampleCustomerProfile(id, sampleName, false);
+    final ODataEntity original = (ODataEntity) getSampleCustomerProfile(id, sampleName, false);
 
     final Set<Integer> keys = new HashSet<Integer>();
     keys.add(-100);
     keys.add(-101);
 
     for (Integer key : keys) {
-      final CommonODataEntity order =
+      final ODataEntity order =
               client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
 
       getClient().getBinder().add(order,
@@ -301,7 +299,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
                       client.getObjectFactory().newPrimitiveValueBuilder().setValue(id).
                       setType(EdmPrimitiveTypeKind.Int32).build()));
 
-      final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
+      final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(
               client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Order").build(), order);
       createReq.setFormat(format);
 
@@ -310,9 +308,9 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
               createReq.execute().getBody().getEditLink()));
     }
 
-    final CommonODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity created = (ODataEntity) createEntity(getServiceRoot(), format, original, "Customer");
     // now, compare the created one with the actual one and go deeply into the associated customer info.....
-    final CommonODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
+    final ODataEntity actual = (ODataEntity) compareEntities(getServiceRoot(), format, created, id, null);
 
     final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
     uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Orders");
@@ -324,11 +322,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
     assertEquals(200, res.getStatusCode());
 
-    final CommonODataEntitySet entitySet = res.getBody();
+    final ODataEntitySet entitySet = res.getBody();
     assertNotNull(entitySet);
     assertEquals(2, entitySet.getCount());
 
-    for (CommonODataEntity entity : entitySet.getEntities()) {
+    for (ODataEntity entity : entitySet.getEntities()) {
       final Integer key = entity.getProperty("OrderId").getPrimitiveValue().toCastValue(Integer.class);
       final Integer customerId = entity.getProperty("CustomerId").getPrimitiveValue().toCastValue(Integer.class);
       assertTrue(keys.contains(key));
@@ -345,16 +343,16 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     return actual;
   }
 
-  private CommonODataEntity createWithNavigationLink(final ODataPubFormat format, final int id) {
+  private ODataEntity createWithNavigationLink(final ODataPubFormat format, final int id) {
     final String sampleName = "Sample customer";
 
-    final CommonODataEntity original = getSampleCustomerProfile(id, sampleName, false);
+    final ODataEntity original = getSampleCustomerProfile(id, sampleName, false);
     original.addLink(client.getObjectFactory().newEntityNavigationLink(
             "Info", URI.create(getServiceRoot() + "/CustomerInfo(12)")));
 
-    final CommonODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
     // now, compare the created one with the actual one and go deeply into the associated customer info.....
-    final CommonODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
+    final ODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
 
     final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
     uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Info");
@@ -365,12 +363,12 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     final ODataRetrieveResponse<ODataEntity> res = req.execute();
     assertEquals(200, res.getStatusCode());
 
-    final CommonODataEntity info = res.getBody();
+    final ODataEntity info = res.getBody();
     assertNotNull(info);
 
     boolean found = false;
 
-    for (CommonODataProperty prop : info.getProperties()) {
+    for (ODataProperty prop : info.getProperties()) {
       if ("CustomerInfoId".equals(prop.getName())) {
         assertEquals("12", prop.getValue().toString());
         found = true;
@@ -382,7 +380,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     return actual;
   }
 
-  private CommonODataEntity createWithBackNavigationLink(final ODataPubFormat format, final int id)
+  private ODataEntity createWithBackNavigationLink(final ODataPubFormat format, final int id)
           throws EdmPrimitiveTypeException {
 
     final String sampleName = "Sample customer";
@@ -451,7 +449,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
   }
 
   private void multiKey(final ODataPubFormat format) {
-    final CommonODataEntity message = client.getObjectFactory().newEntity(
+    final ODataEntity message = client.getObjectFactory().newEntity(
             "Microsoft.Test.OData.Services.AstoriaDefaultService.Message");
 
     getClient().getBinder().add(message,
@@ -481,11 +479,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
 
     final CommonURIBuilder<?> builder =
             client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Message");
-    final ODataEntityCreateRequest req = client.getCUDRequestFactory().getEntityCreateRequest(builder.build(),
-            message);
+    final ODataEntityCreateRequest<ODataEntity> req = client.getCUDRequestFactory().
+            getEntityCreateRequest(builder.build(), message);
     req.setFormat(format);
 
-    final ODataEntityCreateResponse res = req.execute();
+    final ODataEntityCreateResponse<ODataEntity> res = req.execute();
     assertNotNull(res);
     assertEquals(201, res.getStatusCode());
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java
index 6ed898d..223f908 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java
@@ -27,7 +27,6 @@ import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateR
 import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -53,7 +52,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     final URI uri = client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Product").appendKeySegment(-10).build();
     final String etag = getETag(uri);
-    final CommonODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
     merge.setEditLink(uri);
     updateEntityDescription(format, merge, UpdateType.MERGE, etag);
   }
@@ -64,7 +63,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     final URI uri = client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Product").appendKeySegment(-10).build();
     final String etag = getETag(uri);
-    final CommonODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
     merge.setEditLink(uri);
     updateEntityDescription(format, merge, UpdateType.MERGE, etag);
   }
@@ -75,7 +74,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     final URI uri = client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Product").appendKeySegment(-10).build();
     final String etag = getETag(uri);
-    final CommonODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
     patch.setEditLink(uri);
     updateEntityDescription(format, patch, UpdateType.PATCH, etag);
   }
@@ -86,7 +85,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     final URI uri = client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Product").appendKeySegment(-10).build();
     final String etag = getETag(uri);
-    final CommonODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
     patch.setEditLink(uri);
     updateEntityDescription(format, patch, UpdateType.PATCH, etag);
   }
@@ -94,7 +93,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
   @Test
   public void replaceAsAtom() {
     final ODataPubFormat format = ODataPubFormat.ATOM;
-    final CommonODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
+    final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Car").appendKeySegment(14).build());
     updateEntityDescription(format, changes, UpdateType.REPLACE);
   }
@@ -102,7 +101,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
   @Test
   public void replaceAsJSON() {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-    final CommonODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
+    final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Car").appendKeySegment(14).build());
     updateEntityDescription(format, changes, UpdateType.REPLACE);
   }
@@ -121,7 +120,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     final URI uri = client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Customer").appendKeySegment(-10).build();
 
-    final CommonODataEntity patch =
+    final ODataEntity patch =
             client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
     patch.setEditLink(uri);
 
@@ -141,7 +140,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI);
     req.setFormat(format);
 
-    CommonODataEntity newInfo = req.execute().getBody();
+    ODataEntity newInfo = req.execute().getBody();
 
     assertEquals(Integer.valueOf(12),
             newInfo.getProperty("CustomerInfoId").getPrimitiveValue().toCastValue(Integer.class));
@@ -179,7 +178,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
     multiKey.put("FromUsername", "1");
     multiKey.put("MessageId", -10);
-    final CommonODataEntity message = read(format, client.getURIBuilder(getServiceRoot()).
+    final ODataEntity message = read(format, client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Message").appendKeySegment(multiKey).build());
     message.getAssociationLinks().clear();
     message.getNavigationLinks().clear();
@@ -226,7 +225,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
     final URI uri = client.getURIBuilder(getServiceRoot()).
             appendEntitySetSegment("Product").appendKeySegment(-10).build();
     String etag = getETag(uri);
-    final CommonODataEntity product = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    final ODataEntity product = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
     product.setEditLink(uri);
     updateEntityStringProperty("BaseConcurrency",
             client.getConfiguration().getDefaultPubFormat(), product, UpdateType.MERGE, etag);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java
index 4a9d05f..1b4892d 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java
@@ -22,7 +22,6 @@ import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.uri.CommonURIBuilder;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
 import org.junit.AfterClass;
@@ -68,10 +67,10 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
   public void createODataEntityAsAtom() {
     final ODataPubFormat format = ODataPubFormat.ATOM;
     final int id = 1;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
 
     createEntity(testStaticServiceRootURL, format, original, "Customer");
-    final CommonODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
+    final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
 
     cleanAfterCreate(format, actual, false, testStaticServiceRootURL);
   }
@@ -80,10 +79,10 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
   public void createODataEntityAsJSON() {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final int id = 2;
-    final CommonODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
 
     createEntity(testStaticServiceRootURL, format, original, "Customer");
-    final CommonODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
+    final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
 
     cleanAfterCreate(format, actual, false, testStaticServiceRootURL);
   }
@@ -91,7 +90,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
   @Test
   public void replaceODataEntityAsAtom() {
     final ODataPubFormat format = ODataPubFormat.ATOM;
-    final CommonODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
+    final ODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Car").appendKeySegment(14).build());
     updateEntityDescription(format, changes, UpdateType.REPLACE);
   }
@@ -99,7 +98,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
   @Test
   public void replaceODataEntityAsJSON() {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
-    final CommonODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
+    final ODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Car").appendKeySegment(14).build());
     updateEntityDescription(format, changes, UpdateType.REPLACE);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
index 3b518d9..1972fec 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
@@ -18,6 +18,11 @@
  */
 package org.apache.olingo.client.core.it.v3;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -39,22 +44,18 @@ import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataInlineEntity;
 import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -66,7 +67,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.ATOM;
     final String contentType = "application/atom+xml";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createNavigation(format, 20, contentType, prefer);
+    final ODataEntity actual = createNavigation(format, 20, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
   // create navigation link with JSON full metadata
@@ -76,7 +77,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final String contentType = "application/json;odata=fullmetadata";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createNavigation(format, 21, contentType, prefer);
+    final ODataEntity actual = createNavigation(format, 21, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
   // throws Null pointer exception when the format is JSON No metadata
@@ -86,7 +87,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
     final String contentType = "application/json;odata=nometadata";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createNavigation(format, 22, contentType, prefer);
+    final ODataEntity actual = createNavigation(format, 22, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
   // test with JSON accept and atom content type
@@ -97,7 +98,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final String contentType = "application/atom+xml";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createNavigation(format, 23, contentType, prefer);
+    final ODataEntity actual = createNavigation(format, 23, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
   // test with JSON full metadata in format and json no metadata in content type
@@ -107,7 +108,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final String contentType = "application/json;odata=nometadata";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createNavigation(format, 24, contentType, prefer);
+    final ODataEntity actual = createNavigation(format, 24, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
   // test with JSON no metadata format and json no metadata in content type
@@ -117,7 +118,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
     final String contentType = "application/json;odata=fullmetadata";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createNavigation(format, 25, contentType, prefer);
+    final ODataEntity actual = createNavigation(format, 25, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
   // create collection navigation link with ATOM
@@ -127,7 +128,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.ATOM;
     final String contentType = "application/atom+xml";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createCollectionNavigation(format, 55, contentType, prefer);
+    final ODataEntity actual = createCollectionNavigation(format, 55, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
   // create collection navigation link with JSON
@@ -137,22 +138,22 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
     final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
     final String contentType = "application/json;odata=fullmetadata";
     final String prefer = "return-content";
-    final CommonODataEntity actual = createCollectionNavigation(format, 77, contentType, prefer);
+    final ODataEntity actual = createCollectionNavigation(format, 77, contentType, prefer);
     delete(format, actual, false, testStaticServiceRootURL);
   }
 
   // create a navigation link
-  public CommonODataEntity createNavigation(final ODataPubFormat format, final int id, final String contenttype,
+  public ODataEntity createNavigation(final ODataPubFormat format, final int id, final String contenttype,
           final String prefer) {
     final String name = "Customer Navigation test";
 
-    final CommonODataEntity original = getNewCustomer(id, name, false);
+    final ODataEntity original = getNewCustomer(id, name, false);
     original.addLink(client.getObjectFactory().newEntityNavigationLink(
             "Info", URI.create(testStaticServiceRootURL + "/CustomerInfo(11)")));
-    final CommonODataEntity created = createNav(testStaticServiceRootURL, format, original, "Customer", contenttype,
+    final ODataEntity created = createNav(testStaticServiceRootURL, format, original, "Customer", contenttype,
             prefer);
 
-    final CommonODataEntity actual = validateEntities(testStaticServiceRootURL, format, created, id, null, "Customer");
+    final ODataEntity actual = validateEntities(testStaticServiceRootURL, format, created, id, null, "Customer");
 
     final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
     uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Info");
@@ -175,38 +176,38 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
   }
 
   // create a navigation link
-  public CommonODataEntity createNav(final String url, final ODataPubFormat format, final CommonODataEntity original,
+  public ODataEntity createNav(final String url, final ODataPubFormat format, final ODataEntity original,
           final String entitySetName, final String contentType, final String prefer) {
     final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(url);
     uriBuilder.appendEntitySetSegment(entitySetName);
-    final ODataEntityCreateRequest createReq =
+    final ODataEntityCreateRequest<ODataEntity> createReq =
             client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
     createReq.setFormat(format);
     createReq.setContentType(contentType);
     createReq.setPrefer(prefer);
-    final ODataEntityCreateResponse createRes = createReq.execute();
+    final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
     assertEquals(201, createRes.getStatusCode());
 
     assertEquals("Created", createRes.getStatusMessage());
 
-    final CommonODataEntity created = createRes.getBody();
+    final ODataEntity created = createRes.getBody();
     assertNotNull(created);
     return created;
   }
   // create collection navigation link
 
-  public CommonODataEntity createCollectionNavigation(final ODataPubFormat format, final int id,
+  public ODataEntity createCollectionNavigation(final ODataPubFormat format, final int id,
           final String contentType, final String prefer) throws EdmPrimitiveTypeException {
     {
       final String name = "Collection Navigation Key Customer";
-      final CommonODataEntity original = getNewCustomer(id, name, false);
+      final ODataEntity original = getNewCustomer(id, name, false);
 
       final Set<Integer> navigationKeys = new HashSet<Integer>();
       navigationKeys.add(-118);
       navigationKeys.add(-119);
 
       for (Integer key : navigationKeys) {
-        final CommonODataEntity orderEntity =
+        final ODataEntity orderEntity =
                 client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
 
         getClient().getBinder().add(orderEntity,
@@ -218,7 +219,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
                         client.getObjectFactory().newPrimitiveValueBuilder().setValue(id).
                         setType(EdmPrimitiveTypeKind.Int32).build()));
 
-        final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
+        final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(
                 client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Order").build(),
                 orderEntity);
         createReq.setFormat(format);
@@ -227,9 +228,9 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
                 "Orders",
                 createReq.execute().getBody().getEditLink()));
       }
-      final CommonODataEntity createdEntity = createNav(testStaticServiceRootURL, format, original, "Customer",
+      final ODataEntity createdEntity = createNav(testStaticServiceRootURL, format, original, "Customer",
               contentType, prefer);
-      final CommonODataEntity actualEntity =
+      final ODataEntity actualEntity =
               validateEntities(testStaticServiceRootURL, format, createdEntity, id, null, "Customer");
 
       final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
@@ -242,12 +243,12 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
       final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
       assertEquals(200, res.getStatusCode());
 
-      final CommonODataEntitySet entitySet = res.getBody();
+      final ODataEntitySet entitySet = res.getBody();
       assertNotNull(entitySet);
 
       assertEquals(2, entitySet.getCount());
 
-      for (CommonODataEntity entity : entitySet.getEntities()) {
+      for (ODataEntity entity : entitySet.getEntities()) {
         final Integer key = entity.getProperty("OrderId").getPrimitiveValue().toCastValue(Integer.class);
         final Integer customerId = entity.getProperty("CustomerId").getPrimitiveValue().toCastValue(Integer.class);
         assertTrue(navigationKeys.contains(key));
@@ -265,10 +266,10 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
   }
   // get a Customer entity to be created
 
-  public CommonODataEntity getNewCustomer(
+  public ODataEntity getNewCustomer(
           final int id, final String name, final boolean withInlineInfo) {
 
-    final CommonODataEntity entity =
+    final ODataEntity entity =
             client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
 
     // add name attribute
@@ -284,35 +285,35 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
                       client.getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)).
                       setType(EdmPrimitiveTypeKind.Int32).build()));
     }
-    final ODataCollectionValue backupContactInfoValue = getClient().getObjectFactory().newCollectionValue(
+    final ODataCollectionValue<ODataValue> backupContactInfoValue = getClient().getObjectFactory().newCollectionValue(
             "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)");
 
-    final ODataComplexValue contactDetails = getClient().getObjectFactory().newComplexValue(
+    final ODataComplexValue<ODataProperty> contactDetails = getClient().getObjectFactory().newComplexValue(
             "Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails");
 
-    final ODataCollectionValue altNamesValue = getClient().getObjectFactory().
+    final ODataCollectionValue<ODataValue> altNamesValue = getClient().getObjectFactory().
             newCollectionValue("Collection(Edm.String)");
     altNamesValue.add(client.getObjectFactory().newPrimitiveValueBuilder().
             setText("My Alternative name").setType(EdmPrimitiveTypeKind.String).build());
     contactDetails.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue));
 
-    final ODataCollectionValue emailBagValue = getClient().getObjectFactory().
+    final ODataCollectionValue<ODataValue> emailBagValue = getClient().getObjectFactory().
             newCollectionValue("Collection(Edm.String)");
     emailBagValue.add(client.getObjectFactory().newPrimitiveValueBuilder().
             setText("altname@mydomain.com").setType(EdmPrimitiveTypeKind.String).build());
     contactDetails.add(client.getObjectFactory().newCollectionProperty("EmailBag", emailBagValue));
 
-    final ODataComplexValue contactAliasValue = getClient().getObjectFactory().newComplexValue(
+    final ODataComplexValue<ODataProperty> contactAliasValue = getClient().getObjectFactory().newComplexValue(
             "Microsoft.Test.OData.Services.AstoriaDefaultService.Aliases");
     contactDetails.add(client.getObjectFactory().newComplexProperty("ContactAlias", contactAliasValue));
 
-    final ODataCollectionValue aliasAltNamesValue = getClient().getObjectFactory().
+    final ODataCollectionValue<ODataValue> aliasAltNamesValue = getClient().getObjectFactory().
             newCollectionValue("Collection(Edm.String)");
     aliasAltNamesValue.add(client.getObjectFactory().newPrimitiveValueBuilder().
             setText("myAlternativeName").setType(EdmPrimitiveTypeKind.String).build());
     contactAliasValue.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue));
 
-    final ODataComplexValue homePhone = getClient().getObjectFactory().newComplexValue(
+    final ODataComplexValue<ODataProperty> homePhone = getClient().getObjectFactory().newComplexValue(
             "Microsoft.Test.OData.Services.AstoriaDefaultService.Phone");
     homePhone.add(client.getObjectFactory().newPrimitiveProperty("PhoneNumber",
             client.getObjectFactory().newPrimitiveValueBuilder().setText("8437568356834568").
@@ -338,7 +339,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
   }
   //delete an entity and associated links after creation
 
-  public void delete(final ODataPubFormat format, final CommonODataEntity created, final boolean includeInline,
+  public void delete(final ODataPubFormat format, final ODataEntity created, final boolean includeInline,
           final String baseUri) {
     final Set<URI> toBeDeleted = new HashSet<URI>();
     toBeDeleted.add(created.getEditLink());
@@ -376,8 +377,8 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
   }
   // add Information property
 
-  public CommonODataEntity getInfo(final int id, final String info) {
-    final CommonODataEntity entity =
+  public ODataEntity getInfo(final int id, final String info) {
+    final ODataEntity entity =
             client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
     entity.setMediaEntity(true);
 
@@ -388,9 +389,9 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
   }
   // validate newly created entities
 
-  public CommonODataEntity validateEntities(final String serviceRootURL,
+  public ODataEntity validateEntities(final String serviceRootURL,
           final ODataPubFormat format,
-          final CommonODataEntity original,
+          final ODataEntity original,
           final int actualObjectId,
           final Collection<String> expands, final String entitySetName) {
 
@@ -501,7 +502,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
       }
 
       final List<CommonODataProperty> actualPropertyValue = new ArrayList<CommonODataProperty>();
-      for (CommonODataProperty prop : (ODataComplexValue) actual) {
+      for (CommonODataProperty prop : actual.asComplex()) {
         actualPropertyValue.add(prop);
       }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java
index f576a03..3a90d70 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java
@@ -18,9 +18,6 @@
  */
 package org.apache.olingo.client.core.it.v3;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -28,10 +25,11 @@ import java.util.UUID;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.client.api.uri.v3.URIBuilder;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmSchema;
@@ -43,6 +41,10 @@ import org.apache.olingo.commons.api.edm.geo.MultiPoint;
 import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
 import org.apache.olingo.commons.api.edm.geo.Point;
 import org.apache.olingo.commons.api.edm.geo.Polygon;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -61,10 +63,10 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
 //        assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
   }
 
-  private CommonODataEntity readRow(final ODataPubFormat format, final String uuid) {
-    final CommonURIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+  private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
+    final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
-    return read(format, builder.build());
+    return (ODataEntity) read(format, builder.build());
   }
 
   private void read(final ODataPubFormat format) {
@@ -91,7 +93,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
   private void cud(final ODataPubFormat format) {
     final UUID guid = UUID.randomUUID();
 
-    CommonODataEntity row = client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.OpenTypesService.Row");
+    ODataEntity row = client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.OpenTypesService.Row");
     getClient().getBinder().add(row,
             client.getObjectFactory().newPrimitiveProperty("Id",
                     client.getObjectFactory().newPrimitiveValueBuilder().
@@ -192,7 +194,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
                     setType(EdmPrimitiveTypeKind.GeographyCollection).
                     setValue(geoColl).build()));
 
-    final ODataComplexValue contactDetails = client.getObjectFactory().newComplexValue(
+    final ODataComplexValue<ODataProperty> contactDetails = client.getObjectFactory().newComplexValue(
             "Microsoft.Test.OData.Services.OpenTypesService.ContactDetails");
     contactDetails.add(client.getObjectFactory().newPrimitiveProperty("FirstContacted",
             client.getObjectFactory().newPrimitiveValueBuilder().
@@ -233,11 +235,11 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
     getClient().getBinder().add(row,
             client.getObjectFactory().newComplexProperty("aContact", contactDetails));
 
-    final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().
+    final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().
             getEntityCreateRequest(client.getURIBuilder(testStaticServiceRootURL).
                     appendEntitySetSegment("Row").build(), row);
     createReq.setFormat(format);
-    final ODataEntityCreateResponse createRes = createReq.execute();
+    final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
     assertEquals(201, createRes.getStatusCode());
 
     row = readRow(format, guid.toString());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java
index 9d10d24..f98e12a 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyTestITCase.java
@@ -18,6 +18,11 @@
  */
 package org.apache.olingo.client.core.it.v3;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
@@ -36,14 +41,11 @@ import org.apache.olingo.client.api.uri.CommonURIBuilder;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataValueFormat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 
 /**
@@ -218,7 +220,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
 
     final String newItem = "new item " + System.currentTimeMillis();
 
-    final ODataCollectionValue originalValue =
+    final ODataCollectionValue<ODataValue> originalValue =
             primaryContactInfo.getComplexValue().get("EmailBag").getCollectionValue();
 
     final int origSize = originalValue.size();
@@ -266,7 +268,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
 
     final String newItem = "new item " + System.currentTimeMillis();
 
-    final ODataCollectionValue originalValue = alternativeNames.getCollectionValue();
+    final ODataCollectionValue<ODataValue> originalValue = alternativeNames.getCollectionValue();
 
     final int origSize = originalValue.size();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/AbstractTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/AbstractTestITCase.java
index a745380..28cb871 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/AbstractTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/AbstractTestITCase.java
@@ -23,7 +23,7 @@ import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.junit.BeforeClass;
 
-public abstract class AbstractTestITCase extends org.apache.olingo.client.core.it.AbstractTestITCase {
+public abstract class AbstractTestITCase {
 
   protected static ODataClient client;
 
@@ -45,7 +45,6 @@ public abstract class AbstractTestITCase extends org.apache.olingo.client.core.i
     client = ODataClientFactory.getV4();
   }
 
-  @Override
   protected ODataClient getClient() {
     return client;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java
index 7806fd0..989dd98 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java
@@ -18,6 +18,11 @@
  */
 package org.apache.olingo.client.core.it.v4;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.net.URI;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -27,7 +32,6 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataRawReque
 import org.apache.olingo.client.api.communication.response.ODataRawResponse;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.uri.CommonURIBuilder;
-import static org.apache.olingo.client.core.it.v4.AbstractTestITCase.client;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
@@ -38,12 +42,6 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.core.op.ResourceFactory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -81,9 +79,6 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
         final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
         assertNotNull(inline);
 
-        debugEntry(client.getBinder().getEntry(
-                inline, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)), "Just read");
-
         final List<? extends CommonODataProperty> properties = inline.getProperties();
         assertEquals(5, properties.size());
 
@@ -136,9 +131,6 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
         final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
         assertNotNull(inline);
 
-        debugFeed(client.getBinder().getFeed(inline, ResourceFactory.feedClassForFormat(
-                format == ODataPubFormat.ATOM)), "Just read");
-
         found = true;
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java
index c354a1d..bc0905c 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java
@@ -36,7 +36,6 @@ import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -109,9 +108,6 @@ public class EntitySetTestITCase extends AbstractTestITCase {
 
     assertTrue(res.getContextURL().toASCIIString().endsWith("$metadata#People"));
 
-    debugFeed(client.getBinder().getFeed(feed, ResourceFactory.feedClassForFormat(
-            ODataPubFormat.ATOM == format)), "Just retrieved feed");
-
     assertEquals(5, feed.getEntities().size());
     assertNotNull(feed.getNext());
 


[4/4] git commit: [OLINGO-200] V4 ODataValue full reachable via API

Posted by il...@apache.org.
[OLINGO-200] V4 ODataValue full reachable via API


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/dc2922c9
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/dc2922c9
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/dc2922c9

Branch: refs/heads/olingo200
Commit: dc2922c956fd4570353130ae1407cab4fd4846f0
Parents: 117cf6f
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Mar 31 10:59:35 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Mar 31 10:59:35 2014 +0200

----------------------------------------------------------------------
 .../request/cud/CommonCUDRequestFactory.java    |   3 +-
 .../request/cud/ODataEntityCreateRequest.java   |   8 +-
 .../request/retrieve/ODataEntitySetRequest.java |   8 +-
 .../retrieve/v3/RetrieveRequestFactory.java     |   5 +-
 .../retrieve/v4/RetrieveRequestFactory.java     |   1 -
 .../response/ODataEntityCreateResponse.java     |   7 +-
 .../api/domain/ODataEntitySetIterator.java      |   3 +
 .../olingo/client/api/op/v3/ODataReader.java    |  13 +
 .../olingo/client/api/op/v4/ODataReader.java    |  14 +
 .../request/cud/AbstractCUDRequestFactory.java  |   6 +-
 .../cud/ODataEntityCreateRequestImpl.java       |  25 +-
 .../cud/ODataValueUpdateRequestImpl.java        |   4 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |  15 +-
 .../request/retrieve/ODataValueRequestImpl.java |   4 +-
 .../client/core/op/AbstractODataBinder.java     |  29 +-
 .../client/core/op/AbstractODataReader.java     |  16 -
 .../client/core/op/impl/v3/ODataBinderImpl.java |  22 +
 .../client/core/op/impl/v3/ODataReaderImpl.java |  23 +
 .../client/core/op/impl/v4/ODataBinderImpl.java |  25 +-
 .../client/core/op/impl/v4/ODataReaderImpl.java |  25 +
 .../core/it/AbstractMetadataTestITCase.java     |   3 +-
 .../client/core/it/AbstractTestITCase.java      | 562 -------------------
 .../client/core/it/v3/AbstractTestITCase.java   | 530 ++++++++++++++++-
 .../core/it/v3/EntityCreateTestITCase.java      |  98 ++--
 .../core/it/v3/EntityUpdateTestITCase.java      |  21 +-
 .../core/it/v3/KeyAsSegmentTestITCase.java      |  13 +-
 .../it/v3/NavigationLinkCreateTestITCase.java   |  89 +--
 .../client/core/it/v3/OpenTypeTestITCase.java   |  28 +-
 .../client/core/it/v3/PropertyTestITCase.java   |  14 +-
 .../client/core/it/v4/AbstractTestITCase.java   |   3 +-
 .../core/it/v4/EntityRetrieveTestITCase.java    |  18 +-
 .../client/core/it/v4/EntitySetTestITCase.java  |   4 -
 .../core/it/v4/PropertyValueTestITCase.java     |  22 +-
 .../olingo/client/core/v3/PropertyTest.java     |  37 +-
 .../olingo/client/core/v4/EntityTest.java       |  16 +-
 .../commons/api/domain/AbstractODataValue.java  |  12 +-
 .../api/domain/CommonODataObjectFactory.java    |   8 +-
 .../commons/api/domain/CommonODataProperty.java |  14 -
 .../api/domain/ODataCollectionValue.java        |   6 +-
 .../commons/api/domain/ODataComplexValue.java   |   8 +-
 .../olingo/commons/api/domain/ODataValue.java   |   6 +-
 .../api/domain/v3/ODataObjectFactory.java       |  12 +-
 .../commons/api/domain/v3/ODataProperty.java    |  16 +
 .../api/domain/v4/ODataObjectFactory.java       |  12 +-
 .../commons/api/domain/v4/ODataProperty.java    |  16 +
 .../domain/AbstractODataCollectionValue.java    |  93 +++
 .../core/domain/AbstractODataComplexValue.java  |  93 +++
 .../core/domain/AbstractODataObjectFactory.java |  18 -
 .../domain/AbstractODataPrimitiveValue.java     | 179 ++++++
 .../core/domain/AbstractODataProperty.java      |  22 -
 .../core/domain/ODataCollectionValueImpl.java   |  90 ---
 .../core/domain/ODataComplexValueImpl.java      |  89 ---
 .../core/domain/ODataPrimitiveValueImpl.java    | 180 ------
 .../domain/v3/ODataCollectionValueImpl.java     |  32 ++
 .../core/domain/v3/ODataComplexValueImpl.java   |  32 ++
 .../core/domain/v3/ODataObjectFactoryImpl.java  |  25 +-
 .../core/domain/v3/ODataPrimitiveValueImpl.java |  44 ++
 .../core/domain/v3/ODataPropertyImpl.java       |  12 +
 .../domain/v4/ODataCollectionValueImpl.java     |  42 ++
 .../core/domain/v4/ODataComplexValueImpl.java   |  44 ++
 .../core/domain/v4/ODataObjectFactoryImpl.java  |  25 +-
 .../core/domain/v4/ODataPrimitiveValueImpl.java |  56 ++
 .../core/domain/v4/ODataPropertyImpl.java       |  13 +
 pom.xml                                         |   5 +
 64 files changed, 1645 insertions(+), 1273 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
index f05eb1a..b6c74dd 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java
@@ -35,11 +35,12 @@ public interface CommonCUDRequestFactory extends Serializable {
    * <br/>
    * Use this kind of request to create a new entity.
    *
+   * @param <E> concrete ODataEntity implementation
    * @param targetURI entity set URI.
    * @param entity entity to be created.
    * @return new ODataEntityCreateRequest instance.
    */
-  ODataEntityCreateRequest getEntityCreateRequest(URI targetURI, CommonODataEntity entity);
+  <E extends CommonODataEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(URI targetURI, E entity);
 
   /**
    * Gets an update request object instance.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
index 02f41e7..73471b9 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataEntityCreateRequest.java
@@ -20,10 +20,14 @@ package org.apache.olingo.client.api.communication.request.cud;
 
 import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
 
 /**
- * This class implements an OData create request.
+ * This interface describes an OData create request.
+ *
+ * @param <E> concrete ODataEntity implementation
  */
-public interface ODataEntityCreateRequest extends ODataBasicRequest<ODataEntityCreateResponse, ODataPubFormat>{
+public interface ODataEntityCreateRequest<E extends CommonODataEntity>
+        extends ODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat> {
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
index 865596c..c7e1964 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataEntitySetRequest.java
@@ -22,8 +22,10 @@ import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
 
 /**
- * This class implements an OData EntitySet query request.
+ * This interface describes an OData EntitySet query request.
+ *
+ * @param <ES> concrete ODataEntitySet implementation
  */
-public interface ODataEntitySetRequest<T extends CommonODataEntitySet>
-        extends ODataRetrieveRequest<T, ODataPubFormat> {
+public interface ODataEntitySetRequest<ES extends CommonODataEntitySet>
+        extends ODataRetrieveRequest<ES, ODataPubFormat> {
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
index 0d133cb..5adc932 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v3/RetrieveRequestFactory.java
@@ -28,21 +28,18 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 
+@SuppressWarnings("unchecked")
 public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory {
 
-  @SuppressWarnings("unchecked")
   @Override
   ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(URI uri);
 
-  @SuppressWarnings("unchecked")
   @Override
   ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri);
 
-  @SuppressWarnings("unchecked")
   @Override
   ODataEntityRequest<ODataEntity> getEntityRequest(URI uri);
 
-  @SuppressWarnings("unchecked")
   @Override
   ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java
index 63f3515..ab8dade 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/v4/RetrieveRequestFactory.java
@@ -34,7 +34,6 @@ public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory {
   @Override
   ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(URI uri);
 
-  @SuppressWarnings("unchecked")
   @Override
   ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java
index 0407422..678b894 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataEntityCreateResponse.java
@@ -21,16 +21,17 @@ package org.apache.olingo.client.api.communication.response;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 
 /**
- * This class implements the response to an OData entity create request.
+ * This interface describes the response to an OData entity create request.
  *
+ * @param <E> concrete ODataEntity implementation
  * @see org.apache.olingo.client.core.communication.request.cud.ODataEntityCreateRequest
  */
-public interface ODataEntityCreateResponse extends ODataResponse {
+public interface ODataEntityCreateResponse<E extends CommonODataEntity> extends ODataResponse {
 
   /**
    * Gets created object.
    *
    * @return created object.
    */
-  CommonODataEntity getBody();
+  E getBody();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
index dd77a44..107816f 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataEntitySetIterator.java
@@ -41,6 +41,9 @@ import org.slf4j.LoggerFactory;
  * OData entity set iterator class.
  * <br/>
  * <b>Please don't forget to call the <tt>close()>/<tt> method when not needed any more.</b>
+ *
+ * @param <E> concrete ODataEntity implementation
+ * @param <ES> concrete ODataEntitySet implementation
  */
 public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends CommonODataEntity>
         implements Iterator<E> {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java
index 7049617..2e72ce4 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v3/ODataReader.java
@@ -22,9 +22,22 @@ import java.io.InputStream;
 import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.client.api.op.CommonODataReader;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
 
 public interface ODataReader extends CommonODataReader {
 
+  @Override
+  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
+
+  @Override
+  ODataEntity readEntity(InputStream input, ODataPubFormat format);
+
+  @Override
+  ODataProperty readProperty(InputStream input, ODataFormat format);
+
   /**
    * Parses a $links request response.
    *

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java
index 25d989d..c976c05 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/v4/ODataReader.java
@@ -18,8 +18,22 @@
  */
 package org.apache.olingo.client.api.op.v4;
 
+import java.io.InputStream;
 import org.apache.olingo.client.api.op.CommonODataReader;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
 
 public interface ODataReader extends CommonODataReader {
 
+  @Override
+  ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
+
+  @Override
+  ODataEntity readEntity(InputStream input, ODataPubFormat format);
+
+  @Override
+  ODataProperty readProperty(InputStream input, ODataFormat format);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
index ae55269..16eecad 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java
@@ -46,8 +46,10 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
   }
 
   @Override
-  public ODataEntityCreateRequest getEntityCreateRequest(final URI targetURI, final CommonODataEntity entity) {
-    return new ODataEntityCreateRequestImpl(client, targetURI, entity);
+  public <E extends CommonODataEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(
+          final URI targetURI, final E entity) {
+
+    return new ODataEntityCreateRequestImpl<E>(client, targetURI, entity);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
index f8bff7e..18485ae 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataEntityCreateRequestImpl.java
@@ -39,14 +39,17 @@ import org.apache.olingo.commons.api.data.Entry;
 
 /**
  * This class implements an OData create request.
+ *
+ * @param <E> concrete ODataEntity implementation
  */
-public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODataEntityCreateResponse, ODataPubFormat>
-        implements ODataEntityCreateRequest, ODataBatchableRequest {
+public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
+        extends AbstractODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat>
+        implements ODataEntityCreateRequest<E>, ODataBatchableRequest {
 
   /**
    * Entity to be created.
    */
-  private final CommonODataEntity entity;
+  private final E entity;
 
   /**
    * Constructor.
@@ -55,9 +58,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
    * @param targetURI entity set URI.
    * @param entity entity to be created.
    */
-  ODataEntityCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI,
-          final CommonODataEntity entity) {
-
+  ODataEntityCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI, final E entity) {
     super(odataClient, ODataPubFormat.class, HttpMethod.POST, targetURI);
     this.entity = entity;
   }
@@ -74,7 +75,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
    * {@inheritDoc }
    */
   @Override
-  public ODataEntityCreateResponse execute() {
+  public ODataEntityCreateResponse<E> execute() {
     final InputStream input = getPayload();
     ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
 
@@ -88,9 +89,9 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
   /**
    * Response class about an ODataEntityCreateRequest.
    */
-  private class ODataEntityCreateResponseImpl extends AbstractODataResponse implements ODataEntityCreateResponse {
+  private class ODataEntityCreateResponseImpl extends AbstractODataResponse implements ODataEntityCreateResponse<E> {
 
-    private CommonODataEntity entity = null;
+    private E entity = null;
 
     /**
      * Constructor.
@@ -98,6 +99,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
      * Just to create response templates to be initialized from batch.
      */
     private ODataEntityCreateResponseImpl() {
+      super();
     }
 
     /**
@@ -114,13 +116,14 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
      * {@inheritDoc }
      */
     @Override
-    public CommonODataEntity getBody() {
+    @SuppressWarnings("unchecked")
+    public E getBody() {
       if (entity == null) {
         try {
           final Container<Entry> container = odataClient.getDeserializer().toEntry(getRawResponse(),
                   ODataPubFormat.fromString(getAccept()));
 
-          entity = odataClient.getBinder().getODataEntity(extractFromContainer(container));
+          entity = (E) odataClient.getBinder().getODataEntity(extractFromContainer(container));
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
index 5876f49..660f1e3 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
@@ -35,7 +35,6 @@ import org.apache.olingo.client.api.http.HttpMethod;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-import org.apache.olingo.commons.core.domain.ODataPrimitiveValueImpl;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 
 /**
@@ -101,6 +100,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
      * Just to create response templates to be initialized from batch.
      */
     private ODataValueUpdateResponseImpl() {
+      super();
     }
 
     /**
@@ -122,7 +122,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
         final ODataValueFormat format = ODataValueFormat.fromString(getAccept());
 
         try {
-          value = new ODataPrimitiveValueImpl.BuilderImpl(odataClient.getServiceVersion()).
+          value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
                   setType(format == ODataValueFormat.TEXT
                           ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
                   setText(IOUtils.toString(getRawResponse())).

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
index 86fa45c..fb571e9 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
@@ -31,11 +31,13 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
 
 /**
  * This class implements an OData EntitySet query request.
+ *
+ * @param <ES> concrete ODataEntitySet implementation
  */
-public class ODataEntitySetRequestImpl<T extends CommonODataEntitySet>
-        extends AbstractODataRetrieveRequest<T, ODataPubFormat> implements ODataEntitySetRequest<T> {
+public class ODataEntitySetRequestImpl<ES extends CommonODataEntitySet>
+        extends AbstractODataRetrieveRequest<ES, ODataPubFormat> implements ODataEntitySetRequest<ES> {
 
-  private T entitySet = null;
+  private ES entitySet = null;
 
   /**
    * Private constructor.
@@ -51,7 +53,7 @@ public class ODataEntitySetRequestImpl<T extends CommonODataEntitySet>
    * {@inheritDoc }
    */
   @Override
-  public ODataRetrieveResponse<T> execute() {
+  public ODataRetrieveResponse<ES> execute() {
     final HttpResponse res = doExecute();
     return new ODataEntitySetResponseImpl(httpClient, res);
   }
@@ -67,6 +69,7 @@ public class ODataEntitySetRequestImpl<T extends CommonODataEntitySet>
      * Just to create response templates to be initialized from batch.
      */
     private ODataEntitySetResponseImpl() {
+      super();
     }
 
     /**
@@ -84,13 +87,13 @@ public class ODataEntitySetRequestImpl<T extends CommonODataEntitySet>
      */
     @Override
     @SuppressWarnings("unchecked")
-    public T getBody() {
+    public ES getBody() {
       if (entitySet == null) {
         try {
           final Container<Feed> container =
                   odataClient.getDeserializer().toFeed(getRawResponse(), ODataPubFormat.fromString(getContentType()));
 
-          entitySet = (T) odataClient.getBinder().getODataEntitySet(extractFromContainer(container));
+          entitySet = (ES) odataClient.getBinder().getODataEntitySet(extractFromContainer(container));
         } finally {
           this.close();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
index 2d7feed..cd8ca18 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
@@ -28,7 +28,6 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.format.ODataValueFormat;
 import org.apache.olingo.client.api.http.HttpClientException;
-import org.apache.olingo.commons.core.domain.ODataPrimitiveValueImpl;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 
 /**
@@ -69,6 +68,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPri
      * Just to create response templates to be initialized from batch.
      */
     private ODataValueResponseImpl() {
+      super();
     }
 
     /**
@@ -90,7 +90,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPri
         final ODataValueFormat format = ODataValueFormat.fromString(getContentType());
 
         try {
-          value = new ODataPrimitiveValueImpl.BuilderImpl(odataClient.getServiceVersion()).
+          value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
                   setType(format == ODataValueFormat.TEXT
                           ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
                   setText(IOUtils.toString(getRawResponse())).

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index 13a49fb..faed745 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -209,27 +209,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     return linkResource;
   }
 
-  @Override
-  public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference,
-          final boolean setType) {
-
-    final Property propertyResource = ResourceFactory.newProperty(reference);
-    propertyResource.setName(property.getName());
-    propertyResource.setValue(getValue(property.getValue(), reference, setType));
-
-    if (setType) {
-      if (property.hasPrimitiveValue()) {
-        propertyResource.setType(property.getPrimitiveValue().getType().toString());
-      } else if (property.hasComplexValue()) {
-        propertyResource.setType(property.getComplexValue().getTypeName());
-      } else if (property.hasCollectionValue()) {
-        propertyResource.setType(property.getCollectionValue().getTypeName());
-      }
-    }
-
-    return propertyResource;
-  }
-
   protected Value getValue(final ODataValue value, final Class<? extends Entry> reference, final boolean setType) {
     Value valueResource = null;
 
@@ -240,17 +219,17 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
               ? new GeospatialValueImpl((Geospatial) value.asPrimitive().toValue())
               : new PrimitiveValueImpl(value.asPrimitive().toString());
     } else if (value.isComplex()) {
-      final ODataComplexValue _value = value.asComplex();
+      final ODataComplexValue<? extends CommonODataProperty> _value = value.asComplex();
       valueResource = new ComplexValueImpl();
 
-      for (final Iterator<CommonODataProperty> itor = _value.iterator(); itor.hasNext();) {
+      for (final Iterator<? extends CommonODataProperty> itor = _value.iterator(); itor.hasNext();) {
         valueResource.asComplex().get().add(getProperty(itor.next(), reference, setType));
       }
     } else if (value.isCollection()) {
-      final ODataCollectionValue _value = value.asCollection();
+      final ODataCollectionValue<? extends ODataValue> _value = value.asCollection();
       valueResource = new CollectionValueImpl();
 
-      for (final Iterator<ODataValue> itor = _value.iterator(); itor.hasNext();) {
+      for (final Iterator<? extends ODataValue> itor = _value.iterator(); itor.hasNext();) {
         valueResource.asCollection().get().add(getValue(itor.next(), reference, setType));
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
index 4ff36f9..b7d29f7 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
@@ -78,22 +78,6 @@ public abstract class AbstractODataReader implements CommonODataReader {
   }
 
   @Override
-  public CommonODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
-    return client.getBinder().getODataEntitySet(client.getDeserializer().toFeed(input, format).getObject());
-  }
-
-  @Override
-  public CommonODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
-    return client.getBinder().getODataEntity(client.getDeserializer().toEntry(input, format).getObject());
-  }
-
-  @Override
-  public CommonODataProperty readProperty(final InputStream input, final ODataFormat format) {
-    final Property property = client.getDeserializer().toProperty(input, format).getObject();
-    return client.getBinder().getODataProperty(property);
-  }
-
-  @Override
   public ODataError readError(final InputStream inputStream, final boolean isXML) {
     return client.getDeserializer().toError(inputStream, isXML);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
index 28887dc..50deadd 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
@@ -34,6 +34,7 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.core.domain.v3.ODataPropertyImpl;
+import org.apache.olingo.commons.core.op.ResourceFactory;
 
 public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
 
@@ -54,6 +55,27 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   }
 
   @Override
+  public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference,
+          final boolean setType) {
+
+    final Property propertyResource = ResourceFactory.newProperty(reference);
+    propertyResource.setName(property.getName());
+    propertyResource.setValue(getValue(property.getValue(), reference, setType));
+
+    if (setType) {
+      if (property.hasPrimitiveValue()) {
+        propertyResource.setType(property.getPrimitiveValue().getTypeName());
+      } else if (property.hasComplexValue()) {
+        propertyResource.setType(((ODataProperty) property).getComplexValue().getTypeName());
+      } else if (property.hasCollectionValue()) {
+        propertyResource.setType(((ODataProperty) property).getCollectionValue().getTypeName());
+      }
+    }
+
+    return propertyResource;
+  }
+
+  @Override
   public ODataEntitySet getODataEntitySet(final Feed resource) {
     return (ODataEntitySet) super.getODataEntitySet(resource);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
index b9cf6de..8663e79 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
@@ -26,7 +26,12 @@ import org.apache.olingo.client.api.op.v3.ODataReader;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.core.op.AbstractODataReader;
 import org.apache.olingo.commons.api.data.Container;
+import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
 
 public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
 
@@ -37,6 +42,24 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
   }
 
   @Override
+  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
+    return ((ODataClient) client).getBinder().
+            getODataEntitySet(client.getDeserializer().toFeed(input, format).getObject());
+  }
+
+  @Override
+  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
+    return ((ODataClient) client).getBinder().
+            getODataEntity(client.getDeserializer().toEntry(input, format).getObject());
+  }
+
+  @Override
+  public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
+    final Property property = client.getDeserializer().toProperty(input, format).getObject();
+    return ((ODataClient) client).getBinder().getODataProperty(property);
+  }
+
+  @Override
   public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format) {
     return ((ODataClient) client).getBinder().getLinkCollection(
             ((ODataClient) client).getDeserializer().toLinkCollection(input, format).getObject());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
index e85b34e..4f4a484 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
@@ -21,11 +21,10 @@ package org.apache.olingo.client.core.op.impl.v4;
 import java.net.URI;
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.data.ServiceDocumentItem;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.client.api.op.v4.ODataBinder;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.op.AbstractODataBinder;
+import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.Entry;
 import org.apache.olingo.commons.api.data.Feed;
 import org.apache.olingo.commons.api.data.Property;
@@ -33,6 +32,7 @@ import org.apache.olingo.commons.api.data.Value;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
 import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.domain.v4.ODataEntity;
 import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
@@ -40,6 +40,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 import org.apache.olingo.commons.core.data.EnumValueImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.op.ResourceFactory;
 
 public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
 
@@ -93,10 +94,24 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference,
           final boolean setType) {
 
-    final Property propertyResource = super.getProperty(property, reference, setType);
-    if (property instanceof ODataProperty && ((ODataProperty) property).hasEnumValue() && setType) {
-      propertyResource.setType(((ODataProperty) property).getEnumValue().getTypeName());
+    final ODataProperty _property = (ODataProperty) property;
+
+    final Property propertyResource = ResourceFactory.newProperty(reference);
+    propertyResource.setName(_property.getName());
+    propertyResource.setValue(getValue(_property.getValue(), reference, setType));
+
+    if (setType) {
+      if (_property.hasPrimitiveValue()) {
+        propertyResource.setType(_property.getPrimitiveValue().getTypeName());
+      } else if (_property.hasEnumValue()) {
+        propertyResource.setType(_property.getEnumValue().getTypeName());
+      } else if (_property.hasComplexValue()) {
+        propertyResource.setType(_property.getComplexValue().getTypeName());
+      } else if (_property.hasCollectionValue()) {
+        propertyResource.setType(_property.getCollectionValue().getTypeName());
+      }
     }
+
     return propertyResource;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
index 9340963..41f1e3b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
@@ -18,9 +18,16 @@
  */
 package org.apache.olingo.client.core.op.impl.v4;
 
+import java.io.InputStream;
 import org.apache.olingo.client.api.op.v4.ODataReader;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.op.AbstractODataReader;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
 
 public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
 
@@ -29,4 +36,22 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader
   public ODataReaderImpl(final ODataClient client) {
     super(client);
   }
+
+  @Override
+  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
+    return ((ODataClient) client).getBinder().
+            getODataEntitySet(client.getDeserializer().toFeed(input, format).getObject());
+  }
+
+  @Override
+  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
+    return ((ODataClient) client).getBinder().
+            getODataEntity(client.getDeserializer().toEntry(input, format).getObject());
+  }
+
+  @Override
+  public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
+    final Property property = client.getDeserializer().toProperty(input, format).getObject();
+    return ((ODataClient) client).getBinder().getODataProperty(property);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractMetadataTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractMetadataTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractMetadataTestITCase.java
index 11b9104..4f65421 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractMetadataTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractMetadataTestITCase.java
@@ -20,9 +20,8 @@ package org.apache.olingo.client.core.it;
 
 import org.apache.olingo.client.api.CommonODataClient;
 
-public abstract class AbstractMetadataTestITCase extends AbstractTestITCase {
+public abstract class AbstractMetadataTestITCase {
 
-  @Override
   protected abstract CommonODataClient getClient();
 
   protected String getTestServiceRoot() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dc2922c9/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java
deleted file mode 100644
index 0a3b53d..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.communication.ODataClientErrorException;
-import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.UpdateType;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
-import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
-import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
-import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.commons.api.data.Entry;
-import org.apache.olingo.commons.api.data.Feed;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.ODataInlineEntity;
-import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.core.data.AtomEntryImpl;
-import org.apache.olingo.commons.core.data.JSONEntryImpl;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractTestITCase {
-
-  /**
-   * Logger.
-   */
-  protected static final Logger LOG = LoggerFactory.getLogger(AbstractTestITCase.class);
-
-  protected static final String TEST_PRODUCT_TYPE = "Microsoft.Test.OData.Services.AstoriaDefaultService.Product";
-
-  protected static final String servicesODataServiceRootURL =
-          "http://services.odata.org/V3/(S(csquyjnoaywmz5xcdbfhlc1p))/OData/OData.svc/";
-
-  /**
-   * This is needed for correct number handling (Double, for example).
-   */
-  @BeforeClass
-  public static void setEnglishLocale() {
-    Locale.setDefault(Locale.ENGLISH);
-  }
-
-  protected abstract CommonODataClient getClient();
-
-  protected void checkLinks(final Collection<ODataLink> original, final Collection<ODataLink> actual) {
-    assertTrue(original.size() <= actual.size());
-
-    for (ODataLink originalLink : original) {
-      ODataLink foundOriginal = null;
-      ODataLink foundActual = null;
-
-      for (ODataLink actualLink : actual) {
-
-        if (actualLink.getType() == originalLink.getType()
-                && (originalLink.getLink() == null
-                || actualLink.getLink().toASCIIString().endsWith(originalLink.getLink().toASCIIString()))
-                && actualLink.getName().equals(originalLink.getName())) {
-
-          foundOriginal = originalLink;
-          foundActual = actualLink;
-        }
-      }
-
-      assertNotNull(foundOriginal);
-      assertNotNull(foundActual);
-
-      if (foundOriginal instanceof ODataInlineEntity && foundActual instanceof ODataInlineEntity) {
-        final CommonODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
-        assertNotNull(originalInline);
-
-        final CommonODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
-        assertNotNull(actualInline);
-
-        checkProperties(originalInline.getProperties(), actualInline.getProperties());
-      }
-    }
-  }
-
-  protected void checkProperties(final Collection<? extends CommonODataProperty> original,
-          final Collection<? extends CommonODataProperty> actual) {
-
-    assertTrue(original.size() <= actual.size());
-
-    // re-organize actual properties into a Map<String, ODataProperty>
-    final Map<String, CommonODataProperty> actualProps = new HashMap<String, CommonODataProperty>(actual.size());
-
-    for (CommonODataProperty prop : actual) {
-      assertFalse(actualProps.containsKey(prop.getName()));
-      actualProps.put(prop.getName(), prop);
-    }
-
-    assertTrue(actual.size() <= actualProps.size());
-
-    for (CommonODataProperty prop : original) {
-      assertNotNull(prop);
-      if (actualProps.containsKey(prop.getName())) {
-        final CommonODataProperty actualProp = actualProps.get(prop.getName());
-        assertNotNull(actualProp);
-
-        if (prop.getValue() != null && actualProp.getValue() != null) {
-          checkPropertyValue(prop.getName(), prop.getValue(), actualProp.getValue());
-        }
-      } else {
-        // nothing ... maybe :FC_KeepInContent="false"
-        // ..... no assert can be done ....
-      }
-    }
-  }
-
-  protected void checkPropertyValue(final String propertyName,
-          final ODataValue original, final ODataValue actual) {
-
-    assertNotNull("Null original value for " + propertyName, original);
-    assertNotNull("Null actual value for " + propertyName, actual);
-
-    assertEquals("Type mismatch for '" + propertyName + "': "
-            + original.getClass().getSimpleName() + "-" + actual.getClass().getSimpleName(),
-            original.getClass().getSimpleName(), actual.getClass().getSimpleName());
-
-    if (original.isComplex()) {
-      final List<CommonODataProperty> originalFileds = new ArrayList<CommonODataProperty>();
-      for (CommonODataProperty prop : original.asComplex()) {
-        originalFileds.add(prop);
-      }
-
-      final List<CommonODataProperty> actualFileds = new ArrayList<CommonODataProperty>();
-      for (CommonODataProperty prop : (ODataComplexValue) actual) {
-        actualFileds.add(prop);
-      }
-
-      checkProperties(originalFileds, actualFileds);
-    } else if (original.isCollection()) {
-      assertTrue(original.asCollection().size() <= actual.asCollection().size());
-
-      boolean found = original.asCollection().isEmpty();
-
-      for (ODataValue originalValue : original.asCollection()) {
-        for (ODataValue actualValue : actual.asCollection()) {
-          try {
-            checkPropertyValue(propertyName, originalValue, actualValue);
-            found = true;
-          } catch (AssertionError ignore) {
-            // ignore
-          }
-        }
-      }
-
-      assertTrue("Found " + actual + " but expected " + original, found);
-    } else {
-      assertTrue("Primitive value for '" + propertyName + "' type mismatch: " + original.asPrimitive().
-              getTypeKind() + "-" + actual.asPrimitive().getTypeKind(),
-              original.asPrimitive().getTypeKind().equals(actual.asPrimitive().getTypeKind()));
-
-      assertEquals("Primitive value for '" + propertyName + "' mismatch: " + original.asPrimitive().toString()
-              + "-" + actual.asPrimitive().toString(),
-              original.asPrimitive().toString(), actual.asPrimitive().toString());
-    }
-  }
-
-  protected CommonODataEntity getSampleCustomerInfo(final int id, final String sampleinfo) {
-    final CommonODataEntity entity = getClient().getObjectFactory().newEntity(
-            "Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
-    entity.setMediaEntity(true);
-
-    getClient().getBinder().add(entity,
-            getClient().getObjectFactory().newPrimitiveProperty("Information",
-                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleinfo).
-                    setType(EdmPrimitiveTypeKind.String).build()));
-
-    return entity;
-  }
-
-  protected CommonODataEntity getSampleCustomerProfile(
-          final int id, final String sampleName, final boolean withInlineInfo) {
-
-    final CommonODataEntity entity =
-            getClient().getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
-
-    // add name attribute
-    getClient().getBinder().add(entity,
-            getClient().getObjectFactory().newPrimitiveProperty("Name",
-                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(sampleName).
-                    setType(EdmPrimitiveTypeKind.String).build()));
-
-    // add key attribute
-    getClient().getBinder().add(entity,
-            getClient().getObjectFactory().newPrimitiveProperty("CustomerId",
-                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(String.valueOf(id)).
-                    setType(EdmPrimitiveTypeKind.Int32).build()));
-
-    // add BackupContactInfo attribute (collection)
-    final ODataCollectionValue backupContactInfoValue = getClient().getObjectFactory().newCollectionValue(
-            "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)");
-    getClient().getBinder().add(entity,
-            getClient().getObjectFactory().newCollectionProperty("BackupContactInfo", backupContactInfoValue));
-
-    // add BackupContactInfo.ContactDetails attribute (complex)
-    final ODataComplexValue contactDetails = getClient().getObjectFactory().newComplexValue(
-            "Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails");
-    backupContactInfoValue.add(contactDetails);
-
-    // add BackupContactInfo.ContactDetails.AlternativeNames attribute (collection)
-    final ODataCollectionValue altNamesValue = getClient().getObjectFactory().
-            newCollectionValue("Collection(Edm.String)");
-    altNamesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
-            setText("myname").setType(EdmPrimitiveTypeKind.String).build());
-    contactDetails.add(getClient().getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue));
-
-    // add BackupContactInfo.ContactDetails.EmailBag attribute (collection)
-    final ODataCollectionValue emailBagValue = getClient().getObjectFactory().
-            newCollectionValue("Collection(Edm.String)");
-    emailBagValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
-            setText("myname@mydomain.com").setType(EdmPrimitiveTypeKind.String).build());
-    contactDetails.add(getClient().getObjectFactory().newCollectionProperty("EmailBag", emailBagValue));
-
-    // add BackupContactInfo.ContactDetails.ContactAlias attribute (complex)
-    final ODataComplexValue contactAliasValue = getClient().getObjectFactory().newComplexValue(
-            "Microsoft.Test.OData.Services.AstoriaDefaultService.Aliases");
-    contactDetails.add(getClient().getObjectFactory().newComplexProperty("ContactAlias", contactAliasValue));
-
-    // add BackupContactInfo.ContactDetails.ContactAlias.AlternativeNames attribute (collection)
-    final ODataCollectionValue aliasAltNamesValue = getClient().getObjectFactory().
-            newCollectionValue("Collection(Edm.String)");
-    aliasAltNamesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
-            setText("myAlternativeName").setType(EdmPrimitiveTypeKind.String).build());
-    contactAliasValue.add(getClient().getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue));
-
-    if (withInlineInfo) {
-      final ODataInlineEntity inlineInfo = getClient().getObjectFactory().newInlineEntity(
-              "Info",
-              URI.create("Customer(" + id + ")/Info"),
-              getSampleCustomerInfo(id, sampleName + "_Info"));
-      inlineInfo.getEntity().setMediaEntity(true);
-      entity.addLink(inlineInfo);
-    }
-
-    return entity;
-  }
-
-  protected void debugEntry(final Entry entry, final String message) {
-    if (LOG.isDebugEnabled()) {
-      final StringWriter writer = new StringWriter();
-      getClient().getSerializer().entry(entry, writer);
-      writer.flush();
-      LOG.debug(message + "\n{}", writer.toString());
-    }
-  }
-
-  protected void debugFeed(final Feed feed, final String message) {
-    if (LOG.isDebugEnabled()) {
-      final StringWriter writer = new StringWriter();
-      getClient().getSerializer().feed(feed, writer);
-      writer.flush();
-      LOG.debug(message + "\n{}", writer.toString());
-    }
-  }
-
-  protected void debugODataProperty(final CommonODataProperty property, final String message) {
-    LOG.debug(message + "\n{}", property.toString());
-  }
-
-  protected void debugODataValue(final ODataValue value, final String message) {
-    LOG.debug(message + "\n{}", value.toString());
-  }
-
-  protected void debugODataEntity(final CommonODataEntity entity, final String message) {
-    if (LOG.isDebugEnabled()) {
-      StringWriter writer = new StringWriter();
-      getClient().getSerializer().entry(getClient().getBinder().getEntry(entity, AtomEntryImpl.class), writer);
-      writer.flush();
-      LOG.debug(message + " (Atom)\n{}", writer.toString());
-
-      writer = new StringWriter();
-      getClient().getSerializer().entry(getClient().getBinder().getEntry(entity, JSONEntryImpl.class), writer);
-      writer.flush();
-      LOG.debug(message + " (JSON)\n{}", writer.toString());
-    }
-  }
-
-  protected void debugInputStream(final InputStream input, final String message) {
-    if (LOG.isDebugEnabled()) {
-      try {
-        LOG.debug(message + "\n{}", IOUtils.toString(input));
-      } catch (IOException e) {
-        LOG.error("Error writing stream", e);
-      } finally {
-        IOUtils.closeQuietly(input);
-      }
-    }
-  }
-
-  protected String getETag(final URI uri) {
-    final ODataRetrieveResponse<CommonODataEntity> res = getClient().getRetrieveRequestFactory().
-            getEntityRequest(uri).execute();
-    try {
-      return res.getEtag();
-    } finally {
-      res.close();
-    }
-  }
-
-  protected CommonODataEntity read(final ODataPubFormat format, final URI editLink) {
-    final ODataEntityRequest<CommonODataEntity> req = getClient().getRetrieveRequestFactory().
-            getEntityRequest(editLink);
-    req.setFormat(format);
-
-    final ODataRetrieveResponse<CommonODataEntity> res = req.execute();
-    final CommonODataEntity entity = res.getBody();
-
-    assertNotNull(entity);
-
-    if (ODataPubFormat.JSON_FULL_METADATA == format || ODataPubFormat.ATOM == format) {
-      assertEquals(req.getURI(), entity.getEditLink());
-    }
-
-    return entity;
-  }
-
-  protected CommonODataEntity createEntity(
-          final String serviceRootURL,
-          final ODataPubFormat format,
-          final CommonODataEntity original,
-          final String entitySetName) {
-
-    final CommonURIBuilder<?> uriBuilder = getClient().getURIBuilder(serviceRootURL).
-            appendEntitySetSegment(entitySetName);
-
-    debugODataEntity(original, "About to create");
-
-    final ODataEntityCreateRequest createReq =
-            getClient().getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
-    createReq.setFormat(format);
-
-    final ODataEntityCreateResponse createRes = createReq.execute();
-    assertEquals(201, createRes.getStatusCode());
-    assertEquals("Created", createRes.getStatusMessage());
-
-    final CommonODataEntity created = createRes.getBody();
-    assertNotNull(created);
-
-    debugODataEntity(created, "Just created");
-
-    return created;
-  }
-
-  protected CommonODataEntity compareEntities(final String serviceRootURL,
-          final ODataPubFormat format,
-          final CommonODataEntity original,
-          final int actualObjectId,
-          final Collection<String> expands) {
-
-    final CommonURIBuilder<?> uriBuilder = getClient().getURIBuilder(serviceRootURL).
-            appendEntitySetSegment("Customer").appendKeySegment(actualObjectId);
-
-    // search expanded
-    if (expands != null) {
-      for (String expand : expands) {
-        uriBuilder.expand(expand);
-      }
-    }
-
-    final ODataEntityRequest<CommonODataEntity> req = getClient().getRetrieveRequestFactory().
-            getEntityRequest(uriBuilder.build());
-    req.setFormat(format);
-
-    final ODataRetrieveResponse<CommonODataEntity> res = req.execute();
-    assertEquals(200, res.getStatusCode());
-
-    final CommonODataEntity actual = res.getBody();
-    assertNotNull(actual);
-
-    // check defined links
-    checkLinks(original.getAssociationLinks(), actual.getAssociationLinks());
-    checkLinks(original.getEditMediaLinks(), actual.getEditMediaLinks());
-    checkLinks(original.getNavigationLinks(), actual.getNavigationLinks());
-
-    // check defined properties equality
-    checkProperties(original.getProperties(), actual.getProperties());
-
-    return actual;
-  }
-
-  protected void cleanAfterCreate(
-          final ODataPubFormat format,
-          final CommonODataEntity created,
-          final boolean includeInline,
-          final String baseUri) {
-
-    final Set<URI> toBeDeleted = new HashSet<URI>();
-    toBeDeleted.add(created.getEditLink());
-
-    if (includeInline) {
-      for (ODataLink link : created.getNavigationLinks()) {
-        if (link instanceof ODataInlineEntity) {
-          final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
-          if (inline.getEditLink() != null) {
-            toBeDeleted.add(URIUtils.getURI(baseUri, inline.getEditLink().toASCIIString()));
-          }
-        }
-
-        if (link instanceof ODataInlineEntitySet) {
-          final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
-          for (CommonODataEntity entity : inline.getEntities()) {
-            if (entity.getEditLink() != null) {
-              toBeDeleted.add(URIUtils.getURI(baseUri, entity.getEditLink().toASCIIString()));
-            }
-          }
-        }
-      }
-    }
-
-    assertFalse(toBeDeleted.isEmpty());
-
-    for (URI link : toBeDeleted) {
-      final ODataDeleteRequest deleteReq = getClient().getCUDRequestFactory().getDeleteRequest(link);
-      final ODataDeleteResponse deleteRes = deleteReq.execute();
-
-      assertEquals(204, deleteRes.getStatusCode());
-      assertEquals("No Content", deleteRes.getStatusMessage());
-
-      deleteRes.close();
-
-      final ODataEntityRequest<CommonODataEntity> retrieveReq = getClient().getRetrieveRequestFactory().
-              getEntityRequest(link);
-      // bug that needs to be fixed on the SampleService - cannot get entity not found with header
-      // Accept: application/json;odata=minimalmetadata
-      retrieveReq.setFormat(format == ODataPubFormat.JSON_FULL_METADATA ? ODataPubFormat.JSON : format);
-
-      Exception exception = null;
-      try {
-        retrieveReq.execute();
-        fail();
-      } catch (ODataClientErrorException e) {
-        exception = e;
-        assertEquals(404, e.getStatusLine().getStatusCode());
-      }
-      assertNotNull(exception);
-    }
-  }
-
-  protected void updateEntityDescription(
-          final ODataPubFormat format, final CommonODataEntity changes, final UpdateType type) {
-
-    updateEntityDescription(format, changes, type, null);
-  }
-
-  protected void updateEntityDescription(
-          final ODataPubFormat format, final CommonODataEntity changes, final UpdateType type, final String etag) {
-
-    updateEntityStringProperty("Description", format, changes, type, etag);
-  }
-
-  protected void updateEntityStringProperty(final String propertyName,
-          final ODataPubFormat format, final CommonODataEntity changes, final UpdateType type, final String etag) {
-
-    final URI editLink = changes.getEditLink();
-
-    final String newm = "New " + propertyName + "(" + System.currentTimeMillis() + ")";
-
-    CommonODataProperty propertyValue = changes.getProperty(propertyName);
-
-    final String oldm;
-    if (propertyValue == null) {
-      oldm = null;
-    } else {
-      oldm = propertyValue.getValue().toString();
-      changes.getProperties().remove(propertyValue);
-    }
-
-    assertNotEquals(newm, oldm);
-
-    getClient().getBinder().add(changes,
-            getClient().getObjectFactory().newPrimitiveProperty(propertyName,
-                    getClient().getObjectFactory().newPrimitiveValueBuilder().setText(newm).build()));
-
-    update(type, changes, format, etag);
-
-    final CommonODataEntity actual = read(format, editLink);
-
-    propertyValue = null;
-
-    for (CommonODataProperty prop : actual.getProperties()) {
-      if (prop.getName().equals(propertyName)) {
-        propertyValue = prop;
-      }
-    }
-
-    assertNotNull(propertyValue);
-    assertEquals(newm, propertyValue.getValue().toString());
-  }
-
-  protected void update(
-          final UpdateType type, final CommonODataEntity changes, final ODataPubFormat format, final String etag) {
-    final ODataEntityUpdateRequest req = getClient().getCUDRequestFactory().getEntityUpdateRequest(type, changes);
-
-    if (getClient().getConfiguration().isUseXHTTPMethod()) {
-      assertEquals(HttpMethod.POST, req.getMethod());
-    } else {
-      assertEquals(type.getMethod(), req.getMethod());
-    }
-    req.setFormat(format);
-
-    if (StringUtils.isNotBlank(etag)) {
-      req.setIfMatch(etag); // Product include ETag header into the response .....
-    }
-
-    final ODataEntityUpdateResponse res = req.execute();
-    assertEquals(204, res.getStatusCode());
-  }
-}