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 2016/08/29 19:41:33 UTC

olingo-odata2 git commit: [OLINGO-1014] Fixed unit test so it is deterministic

Repository: olingo-odata2
Updated Branches:
  refs/heads/master 798f898ed -> 8b6b25733


[OLINGO-1014] Fixed unit test so it is deterministic

Signed-off-by: mibo <mi...@apache.org>


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

Branch: refs/heads/master
Commit: 8b6b25733aed4da83c89ef02f182ed0700b13189
Parents: 798f898
Author: Michael Strasser <michael>
Authored: Mon Aug 29 09:56:12 2016 +1000
Committer: mibo <mi...@apache.org>
Committed: Mon Aug 29 21:41:02 2016 +0200

----------------------------------------------------------------------
 .../datasource/AnnotationsInMemoryDsTest.java   | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/8b6b2573/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java b/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
index 9abd18b..fe75049 100644
--- a/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
+++ b/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
@@ -710,16 +710,26 @@ public class AnnotationsInMemoryDsTest {
   public void ensureTwoKeyEntityKeysAreUnique() throws Exception {
     EdmEntitySet edmEntitySet = createMockedEdmEntitySet("Photos");
 
+    final String nameKeyName = "Name";
+    final String typeKeyName = "ImageFormat";
     final String nameKeyValue = "Big Picture";
     final String typeKeyValue = "PNG";
 
+    final String generatedValue1 = "1";
+    final String generatedValue2 = "2";
+
+    final String imageUri1 = "https://localhost/big_picture.png";
+    final String imageUri2 = "https://localhost/bigger_picture.png";
+
+    // Add photo 1
     Photo photo1 = new Photo();
     photo1.setName(nameKeyValue);
     photo1.setType(typeKeyValue);
-    photo1.setImageUri("https://localhost/big_picture.png");
+    photo1.setImageUri(imageUri1);
     photo1.setImageType("image/png");
     datasource.createData(edmEntitySet, photo1);
 
+    // Add photo 2 (same key values)
     Photo photo2 = new Photo();
     photo2.setName(nameKeyValue);
     photo2.setType(typeKeyValue);
@@ -728,15 +738,21 @@ public class AnnotationsInMemoryDsTest {
     datasource.createData(edmEntitySet, photo2);
 
     List photos = datasource.readData(edmEntitySet);
-
     Assert.assertEquals(2, photos.size());
-    Photo readPhoto = (Photo) photos.get(0);
-    Assert.assertEquals(nameKeyValue + ":" + typeKeyValue,
-            readPhoto.getName() + ":" + readPhoto.getType());
 
-    readPhoto = (Photo) photos.get(1);
-    Assert.assertEquals("1:2",
-            readPhoto.getName() + ":" + readPhoto.getType());
+    // Check photo 1 has specified key values.
+    Map<String, Object> keys1 = new HashMap<String, Object>();
+    keys1.put(nameKeyName, nameKeyValue);
+    keys1.put(typeKeyName, typeKeyValue);
+    Photo readPhoto = (Photo) datasource.readData(edmEntitySet, keys1);
+    Assert.assertEquals(imageUri1, readPhoto.getImageUri());
+
+    // Check photo 2 has generated key values.
+    Map<String, Object> keys2 = new HashMap<String, Object>();
+    keys2.put(nameKeyName, generatedValue1);
+    keys2.put(typeKeyName, generatedValue2);
+    Photo readPhoto2 = (Photo) datasource.readData(edmEntitySet, keys2);
+    Assert.assertEquals(imageUri2, readPhoto2.getImageUri());
   }
 
   @Test