You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/06/15 07:24:02 UTC

[sling-whiteboard] 02/03: [feature-diff] restored FrameworkPropertiesComparatorTest

This is an automated email from the ASF dual-hosted git repository.

simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit a278741937f750ff6acb3af721594c34eaa80d0d
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Sat Jun 15 07:41:45 2019 +0200

    [feature-diff] restored FrameworkPropertiesComparatorTest
---
 .../diff/FrameworkPropertiesComparator.java        |  1 -
 .../diff/FrameworkPropertiesComparatorTest.java    | 78 ++++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java b/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java
index 2f3acb0..f1f1082 100644
--- a/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java
+++ b/feature-diff/src/main/java/org/apache/sling/feature/diff/FrameworkPropertiesComparator.java
@@ -59,5 +59,4 @@ final class FrameworkPropertiesComparator implements FeatureElementComparator {
         }
     }
 
-
 }
diff --git a/feature-diff/src/test/java/org/apache/sling/feature/diff/FrameworkPropertiesComparatorTest.java b/feature-diff/src/test/java/org/apache/sling/feature/diff/FrameworkPropertiesComparatorTest.java
new file mode 100644
index 0000000..2bab91b
--- /dev/null
+++ b/feature-diff/src/test/java/org/apache/sling/feature/diff/FrameworkPropertiesComparatorTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.sling.feature.diff;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class FrameworkPropertiesComparatorTest extends AbstractComparatorTest<FrameworkPropertiesComparator> {
+
+    @Override
+    protected FrameworkPropertiesComparator newComparatorInstance() {
+        return new FrameworkPropertiesComparator();
+    }
+
+    @Test
+    public void checkRemoved() {
+        Map<String, String> previous = new HashMap<>();
+        previous.put("removed", "removed entry");
+
+        Map<String, String> current = new HashMap<>();
+
+        comparator.computeDiff(previous, current, targetFeature);
+
+        assertFalse(targetFeature.getPrototype().getFrameworkPropertiesRemovals().isEmpty());
+        assertFalse(targetFeature.getFrameworkProperties().containsKey("removed"));
+    }
+
+    @Test
+    public void checkAdded() {
+        Map<String, String> previous = new HashMap<>();
+
+        Map<String, String> current = new HashMap<>();
+        current.put("added", "added entry");
+
+        comparator.computeDiff(previous, current, targetFeature);
+
+        assertTrue(targetFeature.getPrototype().getFrameworkPropertiesRemovals().isEmpty());
+        assertFalse(targetFeature.getFrameworkProperties().isEmpty());
+        assertTrue(targetFeature.getFrameworkProperties().containsKey("added"));
+    }
+
+    @Test
+    public void checkUpdated() {
+        Map<String, String> previous = new HashMap<>();
+        previous.put("updated", "regular entry");
+
+        Map<String, String> current = new HashMap<>();
+        current.put("updated", "updated entry");
+
+        comparator.computeDiff(previous, current, targetFeature);
+
+        assertTrue(targetFeature.getPrototype().getFrameworkPropertiesRemovals().isEmpty());
+        assertFalse(targetFeature.getFrameworkProperties().isEmpty());
+        assertTrue(targetFeature.getFrameworkProperties().containsKey("updated"));
+        assertEquals("updated entry", targetFeature.getFrameworkProperties().get("updated"));
+    }
+
+}