[java-metadata-aggregator] 02/02: MDA-65 - Catch up on unit tests

Ian Young ian at iay.org.uk
Fri Sep 11 10:54:41 UTC 2020


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch main
in repository java-metadata-aggregator.

View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=03dd623f0b2261a620f94a2ee1c572c8a245ad99

commit 03dd623f0b2261a620f94a2ee1c572c8a245ad99
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Fri Sep 11 11:54:35 2020 +0100

    MDA-65 - Catch up on unit tests
    
    https://issues.shibboleth.net/jira/browse/MDA-65
---
 .../DeduplicatingItemIdMergeStrategyTest.java      | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/DeduplicatingItemIdMergeStrategyTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/DeduplicatingItemIdMergeStrategyTest.java
new file mode 100644
index 0000000..1d0994e
--- /dev/null
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/DeduplicatingItemIdMergeStrategyTest.java
@@ -0,0 +1,35 @@
+
+package net.shibboleth.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class DeduplicatingItemIdMergeStrategyTest {
+
+    @Test
+    public void testWithoutItemIds() {
+        // First collection has an entity with an ID, and another without
+        final List<Item<String>> coll1 = List.of(new MockItem("first"), new MockItem("second"));
+        coll1.get(0).getItemMetadata().put(new ItemId("first-id"));
+
+        // Second collection has an entity with the same ID, and another without
+        final List<Item<String>> coll2 = List.of(new MockItem("third"), new MockItem("fourth"));
+        coll2.get(0).getItemMetadata().put(new ItemId("first-id"));
+
+        final var merge = new DeduplicatingItemIdMergeStrategy();
+        final var result = new ArrayList<Item<String>>();
+        merge.merge(result, List.of(coll1, coll2));
+        
+        Assert.assertEquals(result.size(), 3);
+        final var i1 = result.get(0);
+        final var i2 = result.get(1);
+        final var i3 = result.get(2);
+        Assert.assertEquals(i1.unwrap(), "first");
+        Assert.assertEquals(i2.unwrap(), "second");
+        Assert.assertEquals(i3.unwrap(), "fourth");
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list