You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2013/10/09 10:03:26 UTC

git commit: Minor fix for OLINGO-30

Updated Branches:
  refs/heads/master 7327a0b41 -> 7ef5a9baa


Minor fix for OLINGO-30


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/7ef5a9ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/7ef5a9ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/7ef5a9ba

Branch: refs/heads/master
Commit: 7ef5a9baa954e5a8b3bf98f2ef61d5763e04497f
Parents: 7327a0b
Author: Michael Bolz <mi...@apache.org>
Authored: Wed Oct 9 10:03:04 2013 +0200
Committer: Michael Bolz <mi...@apache.org>
Committed: Wed Oct 9 10:03:04 2013 +0200

----------------------------------------------------------------------
 .../api/ep/EntityProviderWriteProperties.java   |  9 ++-
 .../ep/ODataEntityProviderPropertiesTest.java   | 79 ++++++++++++++++++--
 2 files changed, 76 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/7ef5a9ba/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
index 99f9bc1..227e1ef 100644
--- a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
+++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
@@ -219,6 +219,8 @@ public class EntityProviderWriteProperties {
 
     public ODataEntityProviderPropertiesBuilder fromProperties(final EntityProviderWriteProperties properties) {
       this.properties.mediaResourceMimeType = properties.getMediaResourceMimeType();
+      this.properties.mediaResourceTypeKey = properties.getMediaResourceTypeKey();
+      this.properties.mediaResourceSourceKey = properties.getMediaResourceSourceKey();
       this.properties.inlineCountType = properties.getInlineCountType();
       this.properties.inlineCount = properties.getInlineCount();
       this.properties.nextLink = properties.getNextLink();
@@ -230,9 +232,8 @@ public class EntityProviderWriteProperties {
   }
 
   public static ODataEntityProviderPropertiesBuilder fromProperties(final EntityProviderWriteProperties properties) {
-    final ODataEntityProviderPropertiesBuilder b = EntityProviderWriteProperties.serviceRoot(properties
-        .getServiceRoot());
-    b.fromProperties(properties);
-    return b;
+    final ODataEntityProviderPropertiesBuilder builder = 
+        EntityProviderWriteProperties.serviceRoot(properties.getServiceRoot());
+    return builder.fromProperties(properties);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/7ef5a9ba/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java
index 8a904d5..04ecea1 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ODataEntityProviderPropertiesTest.java
@@ -19,12 +19,18 @@
 package org.apache.olingo.odata2.core.ep;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
 
+import org.apache.olingo.odata2.api.ODataCallback;
 import org.apache.olingo.odata2.api.commons.InlineCount;
 import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.core.ep.producer.MyCallback;
+import org.apache.olingo.odata2.core.uri.ExpandSelectTreeNodeImpl;
 import org.apache.olingo.odata2.testutil.fit.BaseTest;
 import org.junit.Test;
 
@@ -50,14 +56,34 @@ public class ODataEntityProviderPropertiesTest extends BaseTest {
 
   @Test
   public void buildPropertiesDefaults() throws Exception {
-    URI baseUri = new URI("http://localhost:80/");
-    EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(baseUri).build();
+    URI serviceRoot = new URI("http://localhost:80/");
+    Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
+    callbacks.put("aCallback", new MyCallback(null, null));
+    ExpandSelectTreeNode expandSelectTree = new ExpandSelectTreeNodeImpl();
+    URI selfLink = new URI("http://some.uri");
+    final EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(serviceRoot)
+        .callbacks(callbacks)
+        .expandSelectTree(expandSelectTree)
+        .inlineCount(1)
+        .inlineCountType(InlineCount.ALLPAGES)
+        .mediaResourceTypeKey("~typeKey")
+        .mediaResourceSourceKey("~srcKey")
+        .mediaResourceMimeType("image/png")
+        .nextLink("http://localhost")
+        .selfLink(selfLink)
+        .build();
 
-    assertEquals("http://localhost:80/", properties.getServiceRoot().toASCIIString());
-    assertNull(properties.getInlineCountType());
-    assertNull(properties.getInlineCount());
-    assertNull(properties.getMediaResourceMimeType());
-    assertNull(properties.getNextLink());
+    assertEquals("Wrong amount of callbacks.", 1, properties.getCallbacks().size());
+    assertTrue("No callback found.", properties.getCallbacks().containsKey("aCallback"));
+    assertEquals("Wrong expand select tree.", expandSelectTree, properties.getExpandSelectTree());
+    assertEquals("Wrong self link.", selfLink, properties.getSelfLink());
+    assertEquals("Wrong media resource mime type.", "image/png", properties.getMediaResourceMimeType());
+    assertEquals("Wrong media resource type key.", "~typeKey", properties.getMediaResourceTypeKey());
+    assertEquals("Wrong media resource src key.", "~srcKey", properties.getMediaResourceSourceKey());
+    assertEquals("Wrong base uri.", "http://localhost:80/", properties.getServiceRoot().toASCIIString());
+    assertEquals("Wrong inline count type.", InlineCount.ALLPAGES, properties.getInlineCountType());
+    assertEquals("Wrong inline count.", Integer.valueOf(1), properties.getInlineCount());
+    assertEquals("Wrong nextLink", "http://localhost", properties.getNextLink());
   }
 
   @Test
@@ -69,4 +95,41 @@ public class ODataEntityProviderPropertiesTest extends BaseTest {
         .build();
     assertEquals("Wrong mime type.", "text/html", properties.getMediaResourceMimeType());
   }
+  
+  @Test
+  public void buildEntryPropertiesFromExisting() throws Exception {
+    URI serviceRoot = new URI("http://localhost:80/");
+    Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
+    callbacks.put("aCallback", new MyCallback(null, null));
+    ExpandSelectTreeNode expandSelectTree = new ExpandSelectTreeNodeImpl();
+    URI selfLink = new URI("http://some.uri");
+    final EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(serviceRoot)
+        .callbacks(callbacks)
+        .expandSelectTree(expandSelectTree)
+        .inlineCount(1)
+        .inlineCountType(InlineCount.ALLPAGES)
+        .mediaResourceTypeKey("~typeKey")
+        .mediaResourceSourceKey("~srcKey")
+        .mediaResourceMimeType("image/png")
+        .nextLink("http://localhost")
+        .selfLink(selfLink)
+        .build();
+
+    //
+    final EntityProviderWriteProperties fromProperties = 
+        EntityProviderWriteProperties.fromProperties(properties).build();
+    
+    //
+    assertEquals(1, fromProperties.getCallbacks().size());
+    assertTrue(fromProperties.getCallbacks().containsKey("aCallback"));
+    assertEquals(expandSelectTree, fromProperties.getExpandSelectTree());
+    assertEquals(selfLink, fromProperties.getSelfLink());
+    assertEquals("image/png", fromProperties.getMediaResourceMimeType());
+    assertEquals("~typeKey", fromProperties.getMediaResourceTypeKey());
+    assertEquals("~srcKey", fromProperties.getMediaResourceSourceKey());
+    assertEquals("Wrong base uri.", "http://localhost:80/", fromProperties.getServiceRoot().toASCIIString());
+    assertEquals("Wrong inline count type.", InlineCount.ALLPAGES, fromProperties.getInlineCountType());
+    assertEquals("Wrong inline count.", Integer.valueOf(1), fromProperties.getInlineCount());
+    assertEquals("Wrong nextLink", "http://localhost", fromProperties.getNextLink());
+  }
 }