Repository: olingo-odata4
Updated Branches:
  refs/heads/master 8f40d49c4 -> dd09d61ab


[OLINGO-1191]Code improvements


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

Branch: refs/heads/master
Commit: dd09d61ab2a0f7ec7f7acf0353322ea12f6af2fd
Parents: 8f40d49
Author: ramya vasanth <ramya.vasa...@sap.com>
Authored: Tue Oct 24 11:32:25 2017 +0530
Committer: ramya vasanth <ramya.vasa...@sap.com>
Committed: Tue Oct 24 11:32:25 2017 +0530

----------------------------------------------------------------------
 .../ODataMetadataValidationImpl.java            |   1 -
 .../org/apache/olingo/client/core/AtomTest.java | 364 +++++++++++++++++++
 .../olingo/client/core/EntitySetTest.java       |  15 +
 .../apache/olingo/client/core/EntityTest.java   |  16 +
 .../org/apache/olingo/client/core/JSONTest.java | 354 ++++++++++++++++++
 .../apache/olingo/client/core/MetadataTest.java |   3 +-
 .../client/core/uri/FilterFactoryTest.java      |   2 -
 .../olingo/client/core/uri/URIEscapeTest.java   |   1 -
 .../client/core/CustomersWithOperations.json    |  61 ++++
 .../org/apache/olingo/client/core/VOC_Core.xml  |   6 +-
 .../olingo/client/core/fromdoc1-metadata.xml    |  22 +-
 .../olingo/client/core/fromdoc3-metadata.xml    |  16 +-
 .../olingo/client/core/tripinServEntity.json    |  60 +++
 13 files changed, 907 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java
index 97e2d6d..325cf1f 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java
@@ -27,7 +27,6 @@ import 
org.apache.olingo.client.api.serialization.ODataMetadataValidation;
 import org.apache.olingo.client.core.metadatavalidator.CsdlTypeValidator;
 import org.apache.olingo.client.core.metadatavalidator.EdmTypeValidator;
 import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAction;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;
 import org.apache.olingo.commons.api.edm.EdmEntityType;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java
index 8f70768..85607e7 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java
@@ -35,13 +35,27 @@ import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.data.ResWrap;
+import org.apache.olingo.client.api.domain.ClientAnnotation;
 import org.apache.olingo.client.api.domain.ClientCollectionValue;
 import org.apache.olingo.client.api.domain.ClientComplexValue;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEnumValue;
+import org.apache.olingo.client.api.domain.ClientLink;
+import org.apache.olingo.client.api.domain.ClientOperation;
+import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
 import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
 import org.apache.olingo.client.core.serialization.AtomDeserializer;
 import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+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.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.custommonkey.xmlunit.Diff;
@@ -281,4 +295,354 @@ public class AtomTest extends JSONTest {
       i++;
     }
   }
+  
+  @Test
+  public void issue2OLINGO1073_WithEntitySet() throws Exception {
+    final ClientEntity message = createClientEntity();
+    
+    InputStream inputStream = client.getWriter().writeEntity(message, 
ContentType.APPLICATION_ATOM_XML);
+    ResWrap<Entity> entity = new AtomDeserializer().toEntity(inputStream);
+    assertNotNull(entity);
+    assertEquals(7, entity.getPayload().getProperties().size());
+    assertEquals(3, 
entity.getPayload().getProperty("AddressInfo").asCollection().size());
+    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Location", 
+        
((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(0)).getTypeName());
+    
assertEquals("#Microsoft.OData.SampleService.Models.TripPin.EventLocation", 
+        
((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(1)).getTypeName());
+    
assertEquals("#Microsoft.OData.SampleService.Models.TripPin.AirportLocation", 
+        
((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(2)).getTypeName());
+    
assertEquals("Collection(Microsoft.OData.SampleService.Models.TripPin.Location)",
 
+        entity.getPayload().getProperty("AddressInfo").getType());
+    
+    StringWriter writer = new StringWriter();
+    setNavigationBindingLinkOnEntity(entity);
+    
+    client.getSerializer(ContentType.APPLICATION_ATOM_XML).write(writer, 
entity);
+    assertNotNull(writer.toString());
+    writer = new StringWriter();
+    client.getSerializer(ContentType.APPLICATION_ATOM_XML).write(writer, 
+        new 
ResWrap<URI>(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/"), null, 
+            
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')")));
+    assertNotNull(writer.toString());
+    assertEquals("<?xml version='1.0' "
+        + "encoding='UTF-8'?>"
+        + "<metadata:ref 
xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"; "
+        + "metadata:context=\"http://services.odata.org/V4/";
+        + "(S(fe5rsnxo3fkkkk2bvmh1nl1y))/TripPinServiceRW/\" "
+        + "id=\"http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))"
+        + "/TripPinServiceRW/People(&apos;russellwhyte&apos;)\"/>", 
writer.toString());
+    
+    writer = new StringWriter();
+    Link linkPayload = new Link();
+    linkPayload.setBindingLink("Photos");
+    linkPayload.setMediaETag("xyz");
+    linkPayload.setInlineEntity(createEntity());
+    linkPayload.setTitle("Photos");
+    
linkPayload.setHref("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/Photos");
+    client.getSerializer(ContentType.APPLICATION_ATOM_XML).write(writer, 
+        new 
ResWrap<Link>(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/"), linkPayload.getMediaETag(), linkPayload));
+    assertNotNull(writer.toString());
+    assertEquals("<?xml version='1.0' encoding='UTF-8'?>"
+        + "<links xmlns=\"http://docs.oasis-open.org/odata/ns/data\";>"
+        + "<uri>http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/Photos</uri></links>", writer.toString());
+  }
+
+  /**
+   * @return
+   */
+  private ClientEntity createClientEntity() {
+    final ClientEntity message = client.getObjectFactory().
+        newEntity(new 
FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person"));
+    
+    final ClientComplexValue cityComplexType = getCityComplexType();
+    
+    final ClientComplexValue locationComplexType = client.getObjectFactory().
+        
newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location");
+    
locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln.")));
+    
locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
+
+    final ClientComplexValue eventLocationComplexType = 
client.getObjectFactory().
+        
newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation");
+    
eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln12.")));
+    
eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln12.")));
+    
eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
+    
+    final ClientComplexValue airportLocationComplexType = 
client.getObjectFactory().
+        
newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation");
+    
airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln123.")));
+    
airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
+    
+    final ClientCollectionValue<ClientValue> collectionAddressInfo = 
client.getObjectFactory().
+        
newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location");
+    collectionAddressInfo.add(locationComplexType);
+    collectionAddressInfo.add(eventLocationComplexType);
+    collectionAddressInfo.add(airportLocationComplexType);
+    
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte")));
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell")));
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte")));
+    final ClientLink messageLink1 = 
client.getObjectFactory().newEntityNavigationLink("Photo", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Photo"));
+    final ClientAnnotation messageLink1Annotation = createAnnotation();
+    messageLink1.getAnnotations().add(messageLink1Annotation);
+    
+    final ClientLink messageLink2 = 
client.getObjectFactory().newEntitySetNavigationLink("Friends", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Friends"));
+    final ClientAnnotation messageLink2Annotation = createAnnotation();
+    messageLink2.getAnnotations().add(messageLink2Annotation);
+    
+    final ClientLink messageLink3 = 
client.getObjectFactory().newEntitySetNavigationLink("Trips", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Trips"));
+    final ClientAnnotation messageLink3Annotation = createAnnotation();
+    messageLink3.getAnnotations().add(messageLink3Annotation);
+        
+    message.getNavigationLinks().add(messageLink1);
+    message.getNavigationLinks().add(messageLink2);
+    message.getNavigationLinks().add(messageLink3);
+    
+    final ClientAnnotation messageAnnotation = createAnnotation();
+    message.getAnnotations().add(messageAnnotation);
+    
+    final ClientCollectionValue<ClientValue> emailCollectionValue = 
client.getObjectFactory().
+        newCollectionValue("String");
+    
emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("russ...@example.com"));
+    
emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("russ...@contoso.com"));
+    
message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails",
 emailCollectionValue));
+    
+    
message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo",
 collectionAddressInfo));
+    
message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", 
+        client.getObjectFactory().newEnumValue(
+            "Microsoft.OData.SampleService.Models.TripPin.PersonGender", 
"Male")));
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747"))));
+    
message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')"));
+    message.setETag("W/\"08D491CCBE417AAB\"");
+    
message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')"));
+    
+    final ClientEntity innerEntity = client.getObjectFactory().
+        newEntity(new 
FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Photo"));
+    
innerEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Id",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf(123))));
+    
innerEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Name",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("ABC")));
+    innerEntity.getAnnotations().add(createAnnotation());
+    final ClientLink link = 
client.getObjectFactory().newDeepInsertEntity("Photos", innerEntity);
+    final ClientAnnotation linkAnnotation = createAnnotation();
+    link.getAnnotations().add(linkAnnotation);
+    message.getNavigationLinks().add(link);
+    
+    final ClientLink assoLink = 
client.getObjectFactory().newAssociationLink("Photos", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Photo"));
+    final ClientAnnotation assoLinkAnnotation = createAnnotation();
+    assoLink.getAnnotations().add(assoLinkAnnotation);
+
+    message.getAssociationLinks().add(assoLink);
+    final ClientOperation operation = new ClientOperation();
+    
operation.setTarget(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/Photos"));
+    operation.setTitle("Photos");
+    message.getOperations().add(operation);
+    return message;
+  }
+
+  /**
+   * @param entity
+   */
+  private void setNavigationBindingLinkOnEntity(ResWrap<Entity> entity) {
+    Link entityLink = new Link();
+    Entity en = createEntity();
+    
+    entityLink.setBindingLink("Photos");
+    entityLink.setInlineEntity(en);
+    entityLink.setType("Microsoft.OData.SampleService.Models.TripPin.Photos");
+    
+    Link entityColLink = new Link();
+    EntityCollection enCol = new EntityCollection();
+    enCol.getEntities().add(en);
+    
+    entityColLink.setBindingLink("Friends");
+    entityColLink.setInlineEntitySet(enCol);
+    
entityColLink.setType("Microsoft.OData.SampleService.Models.TripPin.Friends");
+    
+    Link link = new Link();
+    link.setBindingLink("Trips");
+    link.setType("Microsoft.OData.SampleService.Models.TripPin.Trips");
+    
+    entity.getPayload().getNavigationBindings().add(entityLink);
+    entity.getPayload().getNavigationBindings().add(entityColLink);
+    entity.getPayload().getNavigationBindings().add(link);
+  }
+
+  /**
+   * @return
+   */
+  private Entity createEntity() {
+    Entity en = new Entity();
+    Property p1 = new Property();
+    p1.setName("Id");
+    p1.setType("Int64");
+    p1.setValue(ValueType.PRIMITIVE, Long.valueOf(123));
+    en.addProperty(p1);
+    
+    Property p2 = new Property();
+    p2.setName("Name");
+    p2.setType("String");
+    p2.setValue(ValueType.PRIMITIVE, "ABC");
+    en.addProperty(p2);
+    return en;
+  }
+
+  /**
+   * @return
+   */
+  private ClientAnnotation createAnnotation() {
+    final ClientAnnotation messageAnnotation = 
+        new ClientAnnotationImpl("Org.OData.Core.V1.Permissions", new 
ClientPrimitiveValue() {
+      
+      @Override
+      public boolean isPrimitive() {
+        return false;
+      }
+      
+      @Override
+      public boolean isEnum() {
+        return true;
+      }
+      
+      @Override
+      public boolean isComplex() {
+        return false;
+      }
+      
+      @Override
+      public boolean isCollection() {
+        return false;
+      }
+      
+      @Override
+      public String getTypeName() {
+        return "String";
+      }
+      
+      @Override
+      public ClientPrimitiveValue asPrimitive() {
+        return null;
+      }
+      
+      @Override
+      public ClientEnumValue asEnum() {
+        return 
client.getObjectFactory().newEnumValue("Org.OData.Core.V1.Permissions", "Read");
+      }
+      
+      @Override
+      public ClientComplexValue asComplex() {
+        return null;
+      }
+      
+      @Override
+      public <T extends ClientValue> ClientCollectionValue<T> asCollection() {
+        return null;
+      }
+      
+      @Override
+      public Object toValue() {
+        return 
client.getObjectFactory().newEnumValue("Org.OData.Core.V1.Permissions", "Read");
+      }
+      
+      @Override
+      public <T> T toCastValue(Class<T> reference) throws 
EdmPrimitiveTypeException {
+        return null;
+      }
+      
+      @Override
+      public EdmPrimitiveTypeKind getTypeKind() {
+        return null;
+      }
+      
+      @Override
+      public EdmPrimitiveType getType() {
+        return null;
+      }
+    });
+    return messageAnnotation;
+  }
+  
+  @Test
+  public void testEntitySet() throws Exception {
+    final StringWriter writer = new StringWriter();
+    client.getSerializer(ContentType.APPLICATION_ATOM_XML).write(writer, 
+        client.getDeserializer(ContentType.APPLICATION_ATOM_XML).toEntitySet(
+        getClass().getResourceAsStream("Customers.xml")));
+
+    assertNotNull(writer.toString());
+  }
+  
+  private void property(String fileName) throws Exception {
+    final StringWriter writer = new StringWriter();
+    client.getSerializer(ContentType.APPLICATION_ATOM_XML).write(writer, 
+        client.getDeserializer(ContentType.APPLICATION_ATOM_XML).
+        toProperty(getClass().getResourceAsStream(fileName)));
+
+    assertNotNull(writer.toString());
+  }
+  
+  @Test
+  public void testProperties() throws Exception {
+    property("Products_5_SkinColor.xml");
+    property("Products_5_CoverColors.xml");
+    property("Employees_3_HomeAddress.xml");
+    property("Employees_3_HomeAddress.xml");
+  }
+  
+  protected void delta(final String filename) throws Exception {
+    ResWrap<Delta> resDelta = 
client.getDeserializer(ContentType.APPLICATION_ATOM_XML).toDelta(
+        getClass().getResourceAsStream(filename));
+    final Delta delta = resDelta.getPayload();
+    
+    assertNotNull(delta);
+    assertNotNull(delta.getDeltaLink());
+    assertEquals(5, delta.getCount(), 0);
+
+    assertEquals(1, delta.getDeletedEntities().size());
+    
assertTrue(delta.getDeletedEntities().get(0).getId().toASCIIString().endsWith("Customers('ANTON')"));
+
+    assertEquals(1, delta.getAddedLinks().size());
+    
assertTrue(delta.getAddedLinks().get(0).getSource().toASCIIString().endsWith("Customers('BOTTM')"));
+    assertEquals("Orders", delta.getAddedLinks().get(0).getRelationship());
+
+    assertEquals(1, delta.getDeletedLinks().size());
+    
assertTrue(delta.getDeletedLinks().get(0).getSource().toASCIIString().endsWith("Customers('ALFKI')"));
+    assertEquals("Orders", delta.getDeletedLinks().get(0).getRelationship());
+
+    assertEquals(2, delta.getEntities().size());
+    Property property = delta.getEntities().get(0).getProperty("ContactName");
+    assertNotNull(property);
+    assertTrue(property.isPrimitive());
+    property = delta.getEntities().get(1).getProperty("ShippingAddress");
+    assertNotNull(property);
+    assertTrue(property.isComplex());
+  }
+
+  @Test
+  public void deltas() throws Exception {
+    delta("delta.xml");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
index 254e83f..b968c5f 100644
--- 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
+++ 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
@@ -52,6 +52,21 @@ public class EntitySetTest extends AbstractTest {
   }
 
   @Test
+  public void testOperations() throws Exception {
+    final InputStream input = getClass().
+        getResourceAsStream("CustomersWithOperations." + 
getSuffix(ContentType.APPLICATION_JSON));
+    final ClientEntitySet entitySet = client.getBinder().getODataEntitySet(
+        
client.getDeserializer(ContentType.APPLICATION_JSON).toEntitySet(input));
+    assertNotNull(entitySet);
+
+    assertEquals(2, entitySet.getEntities().size());
+    assertNull(entitySet.getNext());
+    assertEquals(1, entitySet.getOperations().size());
+    
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.BAESAllPrimRTETAllPrim",
+        entitySet.getOperations().get(0).getTitle());
+  }
+
+  @Test
   public void fromAtom() throws Exception {
     read(ContentType.APPLICATION_ATOM_XML);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
index b3f1b5e..52e8e70 100644
--- 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
+++ 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
@@ -52,6 +52,9 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 public class EntityTest extends AbstractTest {
+  
+  private static final String SERVICE_URI = "http://services.odata.org/V4/";
+      + "(S(jf0ernw5hgyg1ekhqmzrdsch))/TripPinServiceRW/";
 
   private EdmEnabledODataClient getEdmEnabledClient() {
     return new EdmEnabledODataClientImpl(null, null, null) {
@@ -401,4 +404,17 @@ public class EntityTest extends AbstractTest {
     assertTrue(property.isPrimitive());
     assertEquals(property.getValueType(), ValueType.PRIMITIVE);
   }
+  
+  @Test
+  public void testFindTypeInEdmEnabledClient() throws Exception {
+    final Edm edm = 
client.getReader().readMetadata(getClass().getResourceAsStream("metadata_TripInService.xml"));
+    assertNotNull(edm);
+    final InputStream input = 
getClass().getResourceAsStream("tripinServEntity.json");
+    EdmEnabledODataClient edmClient = 
ODataClientFactory.getEdmEnabledClient(SERVICE_URI, 
ContentType.APPLICATION_JSON);
+    ClientEntity entity = edmClient.getBinder().getODataEntity(
+        
edmClient.getDeserializer(ContentType.APPLICATION_JSON).toEntity(input));
+    assertNotNull(entity);
+    assertEquals(entity.getTypeName().getFullQualifiedNameAsString(), 
+        "Microsoft.OData.SampleService.Models.TripPin.Person");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
index 646c562..e645f16 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
@@ -33,17 +33,29 @@ import java.util.Map;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.data.ResWrap;
+import org.apache.olingo.client.api.domain.ClientAnnotation;
 import org.apache.olingo.client.api.domain.ClientCollectionValue;
 import org.apache.olingo.client.api.domain.ClientComplexValue;
 import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEnumValue;
+import org.apache.olingo.client.api.domain.ClientLink;
+import org.apache.olingo.client.api.domain.ClientOperation;
+import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
 import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
 import org.apache.olingo.client.core.serialization.JsonDeserializer;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+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.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.junit.Test;
@@ -128,6 +140,15 @@ public class JSONTest extends AbstractTest {
     assertEquals(expected, actualNode);
   }
 
+  private void assertJSONSimilar(final String filename, final String actual) 
throws Exception {
+    final JsonNode expected = 
OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
+        replace(Constants.JSON_NAVIGATION_LINK, 
Constants.JSON_BIND_LINK_SUFFIX));
+    cleanup((ObjectNode) expected);
+    final ObjectNode actualNode = (ObjectNode) OBJECT_MAPPER.readTree(new 
ByteArrayInputStream(actual.getBytes()));
+    cleanup(actualNode);
+    assertEquals(expected, actualNode);
+  }
+  
   protected void entitySet(final String filename, final ContentType 
contentType) throws Exception {
     final StringWriter writer = new StringWriter();
     client.getSerializer(contentType).write(writer, 
client.getDeserializer(contentType).toEntitySet(
@@ -497,4 +518,337 @@ public class JSONTest extends AbstractTest {
     assertTrue(value.asEnum() == null);
 
   }
+  
+  @Test
+  public void issue2OLINGO1073_WithEntitySet() throws Exception {
+    final ClientEntity message = createClientEntity();
+    
+    InputStream inputStream = client.getWriter().writeEntity(message, 
ContentType.APPLICATION_JSON);
+    ResWrap<Entity> entity = new JsonDeserializer(false).toEntity(inputStream);
+    assertNotNull(entity);
+    
+    StringWriter writer = new StringWriter();
+    setNavigationBindingLinkOnEntity(entity);
+    
+    client.getSerializer(ContentType.APPLICATION_JSON).write(writer, entity);
+    assertNotNull(writer.toString());
+    writer = new StringWriter();
+    client.getSerializer(ContentType.APPLICATION_JSON).write(writer, 
+        new 
ResWrap<URI>(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/"), null, 
+            
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')")));
+    assertNotNull(writer.toString());
+    assertEquals("{\"@odata.context\":\"http://services.odata.org/V4/("
+        + "S(fe5rsnxo3fkkkk2bvmh1nl1y))/TripPinServiceRW/\",\"@odata.id\":"
+        + 
"\"http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/TripPinServiceRW/"
+        + "People('russellwhyte')\"}", writer.toString());
+    
+    writer = new StringWriter();
+    Link linkPayload = new Link();
+    linkPayload.setBindingLink("Photos");
+    linkPayload.setMediaETag("xyz");
+    linkPayload.setInlineEntity(createEntity());
+    linkPayload.setTitle("Photos");
+    
linkPayload.setHref("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/Photos");
+    client.getSerializer(ContentType.APPLICATION_JSON).write(writer, 
+        new 
ResWrap<Link>(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/"), linkPayload.getMediaETag(), linkPayload));
+    assertNotNull(writer.toString());
+    assertEquals("{\"url\":\"http://services.odata.org/V4/";
+        + "(S(fe5rsnxo3fkkkk2bvmh1nl1y))/TripPinServiceRW/Photos\"}", 
writer.toString());
+  }
+
+  /**
+   * @return
+   */
+  private ClientEntity createClientEntity() {
+    final ClientEntity message = client.getObjectFactory().
+        newEntity(new 
FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person"));
+    
+    final ClientComplexValue cityComplexType = getCityComplexType();
+    
+    final ClientComplexValue locationComplexType = client.getObjectFactory().
+        
newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location");
+    
locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln.")));
+    
locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
+
+    final ClientComplexValue eventLocationComplexType = 
client.getObjectFactory().
+        
newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation");
+    
eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln12.")));
+    
eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln12.")));
+    
eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
+    
+    final ClientComplexValue airportLocationComplexType = 
client.getObjectFactory().
+        
newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation");
+    
airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 
Suffolk Ln123.")));
+    
airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
+    
+    final ClientCollectionValue<ClientValue> collectionAddressInfo = 
client.getObjectFactory().
+        
newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location");
+    collectionAddressInfo.add(locationComplexType);
+    collectionAddressInfo.add(eventLocationComplexType);
+    collectionAddressInfo.add(airportLocationComplexType);
+    
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte")));
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell")));
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte")));
+    final ClientLink messageLink1 = 
client.getObjectFactory().newEntityNavigationLink("Photo", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Photo"));
+    final ClientAnnotation messageLink1Annotation = createAnnotation();
+    messageLink1.getAnnotations().add(messageLink1Annotation);
+    
+    final ClientLink messageLink2 = 
client.getObjectFactory().newEntitySetNavigationLink("Friends", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Friends"));
+    final ClientAnnotation messageLink2Annotation = createAnnotation();
+    messageLink2.getAnnotations().add(messageLink2Annotation);
+    
+    final ClientLink messageLink3 = 
client.getObjectFactory().newEntitySetNavigationLink("Trips", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Trips"));
+    final ClientAnnotation messageLink3Annotation = createAnnotation();
+    messageLink3.getAnnotations().add(messageLink3Annotation);
+        
+    message.getNavigationLinks().add(messageLink1);
+    message.getNavigationLinks().add(messageLink2);
+    message.getNavigationLinks().add(messageLink3);
+    
+    final ClientAnnotation messageAnnotation = createAnnotation();
+    message.getAnnotations().add(messageAnnotation);
+    
+    final ClientCollectionValue<ClientValue> emailCollectionValue = 
client.getObjectFactory().
+        newCollectionValue("String");
+    
emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("russ...@example.com"));
+    
emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("russ...@contoso.com"));
+    
message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails",
 emailCollectionValue));
+    
+    
message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo",
 collectionAddressInfo));
+    
message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", 
+        client.getObjectFactory().newEnumValue(
+            "Microsoft.OData.SampleService.Models.TripPin.PersonGender", 
"Male")));
+    
message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747"))));
+    
message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')"));
+    message.setETag("W/\"08D491CCBE417AAB\"");
+    
message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')"));
+    
+    final ClientEntity innerEntity = client.getObjectFactory().
+        newEntity(new 
FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Photo"));
+    
innerEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Id",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf(123))));
+    
innerEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Name",
 
+        
client.getObjectFactory().newPrimitiveValueBuilder().buildString("ABC")));
+    innerEntity.getAnnotations().add(createAnnotation());
+    final ClientLink link = 
client.getObjectFactory().newDeepInsertEntity("Photos", innerEntity);
+    final ClientAnnotation linkAnnotation = createAnnotation();
+    link.getAnnotations().add(linkAnnotation);
+    message.getNavigationLinks().add(link);
+    
+    final ClientLink assoLink = 
client.getObjectFactory().newAssociationLink("Photos", 
+        
URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/People('russellwhyte')/Photo"));
+    final ClientAnnotation assoLinkAnnotation = createAnnotation();
+    assoLink.getAnnotations().add(assoLinkAnnotation);
+
+    message.getAssociationLinks().add(assoLink);
+    final ClientOperation operation = new ClientOperation();
+    
operation.setTarget(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
+        + "TripPinServiceRW/Photos"));
+    operation.setTitle("Photos");
+    message.getOperations().add(operation);
+    return message;
+  }
+
+  /**
+   * @param entity
+   */
+  private void setNavigationBindingLinkOnEntity(ResWrap<Entity> entity) {
+    Link entityLink = new Link();
+    Entity en = createEntity();
+    
+    entityLink.setBindingLink("Photos");
+    entityLink.setInlineEntity(en);
+    entityLink.setType("Microsoft.OData.SampleService.Models.TripPin.Photos");
+    
+    Link entityColLink = new Link();
+    EntityCollection enCol = new EntityCollection();
+    enCol.getEntities().add(en);
+    
+    entityColLink.setBindingLink("Friends");
+    entityColLink.setInlineEntitySet(enCol);
+    
entityColLink.setType("Microsoft.OData.SampleService.Models.TripPin.Friends");
+    
+    Link link = new Link();
+    link.setBindingLink("Trips");
+    link.setType("Microsoft.OData.SampleService.Models.TripPin.Trips");
+    
+    entity.getPayload().getNavigationBindings().add(entityLink);
+    entity.getPayload().getNavigationBindings().add(entityColLink);
+    entity.getPayload().getNavigationBindings().add(link);
+  }
+
+  /**
+   * @return
+   */
+  private Entity createEntity() {
+    Entity en = new Entity();
+    Property p1 = new Property();
+    p1.setName("Id");
+    p1.setType("Int64");
+    p1.setValue(ValueType.PRIMITIVE, Long.valueOf(123));
+    en.addProperty(p1);
+    
+    Property p2 = new Property();
+    p2.setName("Name");
+    p2.setType("String");
+    p2.setValue(ValueType.PRIMITIVE, "ABC");
+    en.addProperty(p2);
+    return en;
+  }
+
+  /**
+   * @return
+   */
+  private ClientAnnotation createAnnotation() {
+    final ClientAnnotation messageAnnotation = 
+        new ClientAnnotationImpl("Org.OData.Core.V1.Permissions", new 
ClientPrimitiveValue() {
+      
+      @Override
+      public boolean isPrimitive() {
+        return false;
+      }
+      
+      @Override
+      public boolean isEnum() {
+        return true;
+      }
+      
+      @Override
+      public boolean isComplex() {
+        return false;
+      }
+      
+      @Override
+      public boolean isCollection() {
+        return false;
+      }
+      
+      @Override
+      public String getTypeName() {
+        return "String";
+      }
+      
+      @Override
+      public ClientPrimitiveValue asPrimitive() {
+        return null;
+      }
+      
+      @Override
+      public ClientEnumValue asEnum() {
+        return 
client.getObjectFactory().newEnumValue("Org.OData.Core.V1.Permissions", "Read");
+      }
+      
+      @Override
+      public ClientComplexValue asComplex() {
+        return null;
+      }
+      
+      @Override
+      public <T extends ClientValue> ClientCollectionValue<T> asCollection() {
+        return null;
+      }
+      
+      @Override
+      public Object toValue() {
+        return 
client.getObjectFactory().newEnumValue("Org.OData.Core.V1.Permissions", "Read");
+      }
+      
+      @Override
+      public <T> T toCastValue(Class<T> reference) throws 
EdmPrimitiveTypeException {
+        return null;
+      }
+      
+      @Override
+      public EdmPrimitiveTypeKind getTypeKind() {
+        return null;
+      }
+      
+      @Override
+      public EdmPrimitiveType getType() {
+        return null;
+      }
+    });
+    return messageAnnotation;
+  }
+  
+  protected void property1(final String filename) throws Exception {
+    final StringWriter writer = new StringWriter();
+    client.getSerializer(ContentType.APPLICATION_JSON).write(writer, 
+        client.getDeserializer(ContentType.APPLICATION_JSON).
+        toProperty(getClass().getResourceAsStream(filename + ".json")));
+
+    assertJSONSimilar(filename + ".json", writer.toString());
+  }
+
+  @Test
+  public void properties1() throws Exception {
+    property1("Products_5_SkinColor");
+    property1("Products_5_CoverColors");
+    property1("Employees_3_HomeAddress");
+    property1("Employees_3_HomeAddress");
+  }
+  
+  protected void entity1(final String filename) throws Exception {
+    final StringWriter writer = new StringWriter();
+    client.getSerializer(ContentType.APPLICATION_JSON).write(writer, 
client.getDeserializer(
+        ContentType.APPLICATION_JSON).toEntity(
+        getClass().getResourceAsStream(filename + ".json")));
+    assertJSONSimilar(filename + ".json", writer.toString());
+  }
+
+  @Test
+  public void additionalEntities1() throws Exception {
+    entity1("entity.minimal");
+    entity1("entity.primitive");
+    entity1("entity.complex");
+    entity1("entity.collection.primitive");
+    entity1("entity.collection.complex");
+  }
+
+  @Test
+  public void entities1() throws Exception {
+    entity1("Products_5");
+    entity1("VipCustomer");
+    entity1("Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7");
+    entity1("entityReference");
+    entity1("entity.withcomplexnavigation");
+    entity1("annotated");
+  }
+  
+  protected void entitySet1(final String filename) throws Exception {
+    final StringWriter writer = new StringWriter();
+    client.getSerializer(ContentType.APPLICATION_JSON).write(writer, 
+        client.getDeserializer(ContentType.APPLICATION_JSON).toEntitySet(
+        getClass().getResourceAsStream(filename + ".json")));
+
+    assertJSONSimilar(filename + ".json", writer.toString());
+  }
+
+  @Test
+  public void entitySets1() throws Exception {
+    entitySet1("Customers");
+    entitySet1("collectionOfEntityReferences");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
index d624968..1288b08 100644
--- 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
+++ 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
@@ -258,7 +258,7 @@ public class MetadataTest extends AbstractTest {
 
     EdmEntityContainer demoService = schema.getEntityContainer();
     assertNotNull(demoService);
-    for (EdmFunction function : schema.getFunctions()) {
+    EdmFunction function = schema.getFunctions().get(0);
       final EdmFunctionImport fi = 
demoService.getFunctionImport(function.getName());
       assertNotNull(fi);
       assertEquals(demoService.getEntitySet("Products"), 
fi.getReturnedEntitySet());
@@ -276,7 +276,6 @@ public class MetadataTest extends AbstractTest {
           
fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getName());
       assertEquals(edmFunction.getReturnType().getType().getNamespace(),
           
fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getNamespace());
-    }
 
     final EdmTypeDefinition weight = edm.getTypeDefinition(new 
FullQualifiedName("ODataDemo", "Weight"));
     assertNotNull(weight);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
index 22ad452..0bd5510 100644
--- 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
+++ 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
@@ -21,7 +21,6 @@ package org.apache.olingo.client.core.uri;
 import static org.junit.Assert.assertEquals;
 
 import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
 import java.util.Calendar;
 import java.util.TimeZone;
 
@@ -29,7 +28,6 @@ import org.apache.olingo.client.api.uri.FilterArgFactory;
 import org.apache.olingo.client.api.uri.FilterFactory;
 import org.apache.olingo.client.api.uri.URIFilter;
 import org.apache.olingo.client.core.AbstractTest;
-import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.provider.CsdlEnumType;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
index f25c82f..9698365 100644
--- 
a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
+++ 
b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
@@ -26,7 +26,6 @@ import java.util.Calendar;
 import java.util.Collections;
 import java.util.TimeZone;
 
-import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/resources/org/apache/olingo/client/core/CustomersWithOperations.json
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/CustomersWithOperations.json
 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/CustomersWithOperations.json
new file mode 100644
index 0000000..15abbde
--- /dev/null
+++ 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/CustomersWithOperations.json
@@ -0,0 +1,61 @@
+{
+  "@odata.context": 
"http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#Customers";,
+  "@odata.count": 2,
+  "value": [{
+      "@odata.id": 
"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)",
+      "@odata.editLink": 
"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)",
+      "PersonID": 1,
+      "FirstName": "Bob",
+      "LastName": "Cat",
+      "MiddleName": null,
+      "HomeAddress": {
+        "@odata.type": 
"#Microsoft.Test.OData.Services.ODataWCFService.HomeAddress",
+        "Street": "1 Microsoft Way",
+        "City": "London",
+        "PostalCode": "98052",
+        "FamilyName": "Cats"
+      },
+      "Home": {
+        "type": "Point",
+        "coordinates": [23.1, 32.1],
+        "crs": {
+          "type": "name",
+          "properties": {
+            "name": "EPSG:4326"
+          }
+        }
+      },
+      "Numbers": ["111-111-1111"],
+      "Emails": ["a...@abc.com"],
+      "City": "London",
+      "Birthday": "1957-04-03T00:00:00Z",
+      "TimeBetweenLastTwoOrders": "PT0.0000001S"
+    }, {
+      "@odata.id": 
"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=2)",
+      "@odata.editLink": 
"http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=2)",
+      "PersonID": 2,
+      "FirstName": "Jill",
+      "LastName": "Jones",
+      "MiddleName": null,
+      "HomeAddress": null,
+      "Home": {
+        "type": "Point",
+        "coordinates": [161.8, 15.0],
+        "crs": {
+          "type": "name",
+          "properties": {
+            "name": "EPSG:4326"
+          }
+        }
+      },
+      "Numbers": [],
+      "Emails": [],
+      "City": "Sydney",
+      "Birthday": "1983-01-15T00:00:00Z",
+      "TimeBetweenLastTwoOrders": "PT0.0000002S"
+    }],
+    "#Microsoft.Test.OData.Services.ODataWCFService.BAESAllPrimRTETAllPrim": {
+        "title": 
"Microsoft.Test.OData.Services.ODataWCFService.BAESAllPrimRTETAllPrim",
+        "target": 
"Customers/Microsoft.Test.OData.Services.ODataWCFService.BAESAllPrimRTETAllPrim"
+    }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/resources/org/apache/olingo/client/core/VOC_Core.xml
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/VOC_Core.xml 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/VOC_Core.xml
index 4e30cad..d3a296d 100644
--- 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/VOC_Core.xml
+++ 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/VOC_Core.xml
@@ -28,12 +28,12 @@
 
       <!--Documentation -->
 
-      <Term Name="Description" Type="Edm.String">
+      <Term Name="Description" Type="Edm.String" MaxLength="500" SRID="1" 
Nullable="true">
         <Annotation Term="Core.Description" String="A brief description of a 
model element" />
         <Annotation Term="Core.IsLanguageDependent" />
       </Term>
 
-      <Term Name="LongDescription" Type="Edm.String">
+      <Term Name="LongDescription" Type="Edm.String" BaseTerm="Description">
         <Annotation Term="Core.Description" String="A lengthy description of a 
model element" />
         <Annotation Term="Core.IsLanguageDependent" />
       </Term>
@@ -105,7 +105,7 @@
         <Annotation Term="Core.IsMediaType" />
       </Term>
 
-      <Term Name="MediaType" Type="Edm.String" AppliesTo="Property">
+      <Term Name="MediaType" Type="Edm.String" AppliesTo="Property" 
Precision="500" Scale="0">
         <Annotation Term="Core.IsMediaType" />
         <Annotation Term="Core.RequiresType" String="Edm.Binary" />
       </Term>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc1-metadata.xml
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc1-metadata.xml
 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc1-metadata.xml
index 74a71d4..59e2cee 100644
--- 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc1-metadata.xml
+++ 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc1-metadata.xml
@@ -28,12 +28,13 @@
   </edmx:Reference>
   <edmx:DataServices>
     <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
Namespace="ODataDemo">
-      <TypeDefinition Name="Length" UnderlyingType="Edm.Int32">
+      <TypeDefinition Name="Length" UnderlyingType="Edm.Int32" Precision="10" 
SCale="5" Nullable="true">
         <Annotation Term="Org.OData.Measures.V1.Unit" String="Centimeters"/>
       </TypeDefinition>
       <TypeDefinition Name="Weight" UnderlyingType="Edm.Int32">
         <Annotation Term="Org.OData.Measures.V1.Unit" String="Kilograms"/>
       </TypeDefinition>
+      <TypeDefinition Name="Name" UnderlyingType="Edm.String" MaxLength="100" 
SRID="1" Unicode="true"/>
       <ComplexType Name="Size">
         <Property Name="Height" Type="Self.Length" />
         <Property Name="Weight" Type="Self.Weight" />
@@ -96,8 +97,20 @@
         </NavigationProperty>
       </ComplexType>
       <Function Name="ProductsByRating">
-        <Parameter Name="Rating" Type="Edm.Int32"/>
-        <ReturnType Type="Collection(ODataDemo.Product)"/>
+        <Parameter Name="Rating" Type="Edm.Int32" Precision="20" Scale="0" 
Nullable="false"/>
+        <ReturnType Type="Collection(ODataDemo.Product)" Nullable="true"/>
+      </Function>
+      <Function Name="ProductsByName">
+        <Parameter Name="Productname" Type="Edm.String" MaxLength="200" 
SRID="1"/>
+        <ReturnType Type="ODataDemo.Product"/>
+      </Function>
+      <Function Name="ProductsIdByRating">
+        <Parameter Name="Rating" Type="Edm.Int32" Precision="20" Scale="0" 
Nullable="false"/>
+        <ReturnType Type="Collection(Edm.Int32)" Nullable="true" Precision="5" 
Scale="5"/>
+      </Function>
+      <Function Name="ProductsNameByName">
+        <Parameter Name="Productname" Type="Edm.String" MaxLength="200" 
SRID="1"/>
+        <ReturnType Type="Edm.String" MaxLength="50" SRID="1"/>
       </Function>
       <EntityContainer Name="DemoService">
         <EntitySet Name="Products" EntityType="ODataDemo.Product">
@@ -120,6 +133,9 @@
         </Singleton>
         <EntitySet Name="Countries" EntityType="ODataDemo.Country"/>
         <FunctionImport Name="ProductsByRating" EntitySet="Products" 
Function="ODataDemo.ProductsByRating"/>
+        <FunctionImport Name="ProductsByName" EntitySet="Products" 
Function="ODataDemo.ProductsByName"/>
+        <FunctionImport Name="ProductsIdByRating" 
Function="ODataDemo.ProductsIdByRating"/>
+        <FunctionImport Name="ProductsNameByName" 
Function="ODataDemo.ProductsNameByName"/>
       </EntityContainer>
     </Schema>
   </edmx:DataServices>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc3-metadata.xml
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc3-metadata.xml
 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc3-metadata.xml
index 36e5216..8a7623a 100644
--- 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc3-metadata.xml
+++ 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/fromdoc3-metadata.xml
@@ -57,11 +57,18 @@
           </Apply>
         </Annotation>
         <Annotation Term="org.example.display.Threshold">
-          <Cast Type="Edm.Decimal">
+          <Cast Type="Edm.Decimal" Precision="10" Scale="2">
             <Path>Average</Path>
+            <Annotation Term="TestCast">
+                 <TestCast>
+                   <Path>Testing Cast of Average Field</Path>
+                 </TestCast>        
+               </Annotation>
           </Cast>
         </Annotation>
         <Annotation Term="Vocabulary1.Tags">
+        <Cast Type="Edm.String" MaxLength="500" SRID="1">
+          </Cast>
           <Collection>
             <String>MasterData</String>
           </Collection>
@@ -81,8 +88,13 @@
           </If>
         </Annotation>
         <Annotation Term="Self.IsPreferredCustomer">
-          <IsOf Type="Self.PreferredCustomer">
+          <IsOf Type="Self.PreferredCustomer" MaxLength="200" Precision="200" 
Scale="0" SRID="1">
             <Path>Customer</Path>
+            <Annotation Term="Test">
+                 <Test>
+                   <Path>IsPreferred</Path>
+                 </Test>        
+               </Annotation>
           </IsOf>
         </Annotation>
         <Annotation Term="org.example.display.DisplayName">

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/dd09d61a/lib/client-core/src/test/resources/org/apache/olingo/client/core/tripinServEntity.json
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/test/resources/org/apache/olingo/client/core/tripinServEntity.json
 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/tripinServEntity.json
new file mode 100644
index 0000000..7983f11
--- /dev/null
+++ 
b/lib/client-core/src/test/resources/org/apache/olingo/client/core/tripinServEntity.json
@@ -0,0 +1,60 @@
+{
+  "@odata.context": "$metadata#People/$entity",
+  "@odata.id": 
"http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/TripPinServiceRW/People('russellwhyte')",
+  "usern...@odata.type": "String",
+  "UserName": "russellwhyte",
+  "firstn...@odata.type": "String",
+  "FirstName": "Russell",
+  "lastn...@odata.type": "String",
+  "LastName": "Whyte",
+  "AddressInfo": [
+    {
+      "@odata.type": "#Microsoft.OData.SampleService.Models.TripPin.Location",
+      "addr...@odata.type": "String",
+      "Address": "187 Suffolk Ln.",
+      "City": {
+        "@odata.type": "#Microsoft.OData.SampleService.Models.TripPin.City",
+        "countryreg...@odata.type": "String",
+        "CountryRegion": "United States",
+        "n...@odata.type": "String",
+        "Name": "Boise",
+        "reg...@odata.type": "String",
+        "Region": "ID"
+      }
+    },
+    {
+      "@odata.type": 
"#Microsoft.OData.SampleService.Models.TripPin.EventLocation",
+      "buildingi...@odata.type": "String",
+      "BuildingInfo": "187 Suffolk Ln12.",
+      "addr...@odata.type": "String",
+      "Address": "187 Suffolk Ln12.",
+      "City": {
+        "@odata.type": "#Microsoft.OData.SampleService.Models.TripPin.City",
+        "countryreg...@odata.type": "String",
+        "CountryRegion": "United States",
+        "n...@odata.type": "String",
+        "Name": "Boise",
+        "reg...@odata.type": "String",
+        "Region": "ID"
+      }
+    },
+    {
+      "@odata.type": 
"#Microsoft.OData.SampleService.Models.TripPin.AirportLocation",
+         "addr...@odata.type": "String",
+      "Address": "187 Suffolk Ln123.",
+      "City": {
+        "@odata.type": "#Microsoft.OData.SampleService.Models.TripPin.City",
+        "countryreg...@odata.type": "String",
+        "CountryRegion": "United States",
+        "n...@odata.type": "String",
+        "Name": "Boise",
+        "reg...@odata.type": "String",
+        "Region": "ID"
+      }
+    }
+  ],
+  "gen...@odata.type": 
"#Microsoft.OData.SampleService.Models.TripPin.PersonGender",
+  "Gender": "Male",
+  "concurre...@odata.type": "Int64",
+  "Concurrency": 636293755917400747
+}
\ No newline at end of file

Reply via email to