Browse Source

updated

security/10.0
rinoux 3 years ago
parent
commit
24f93e7d99
  1. 4
      designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java
  2. 57
      designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java

4
designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java

@ -1,5 +1,7 @@
package com.fr.design.data; package com.fr.design.data;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@ -20,7 +22,7 @@ public final class MapCompareUtils {
* @param <K> K * @param <K> K
* @param <V> V * @param <V> V
*/ */
public static <K, V> void contrastMapEntries(Map<K, V> orig, Map<K, V> other, EventHandler<K, V> eventHandler) { public static <K, V> void contrastMapEntries(@NotNull Map<K, V> orig, @NotNull Map<K, V> other, @NotNull EventHandler<K, V> eventHandler) {
Map<K, V> copiedOrig = new LinkedHashMap<>(orig); Map<K, V> copiedOrig = new LinkedHashMap<>(orig);

57
designer-base/src/test/java/com/fr/design/data/MapCompareUtilsTest.java

@ -0,0 +1,57 @@
package com.fr.design.data;
import org.junit.Assert;
import org.junit.Test;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author rinoux
* @version 10.0
* Created by rinoux on 2022/3/28
*/
public class MapCompareUtilsTest {
@Test
public void contrastMapEntries() {
Map<String, String> orig = new LinkedHashMap<>();
orig.put("aaa", "aaa");
orig.put("bbb", "bbb");
orig.put("ccc", "ccc");
orig.put("ddd", "ddd");
Map<String, String> other = new LinkedHashMap<>();
other.put("aaa", "111");
other.put("bbb", "bbb");
other.put("ccc", "ccc");
other.put("eee", "eee");
MapCompareUtils.contrastMapEntries(orig, other, new MapCompareUtils.EventHandler<String, String>() {
@Override
public void on(MapCompareUtils.EntryEventKind entryEventKind, String s, String s2) {
switch (entryEventKind) {
case UPDATED:
Assert.assertEquals(s, "aaa");
Assert.assertEquals(s2, "111");
break;
case REMOVED:
Assert.assertEquals(s, "ddd");
break;
case ADDED:
Assert.assertEquals(s, "eee");
Assert.assertEquals(s2, "eee");
break;
default:
Assert.fail();
}
}
});
}
}
Loading…
Cancel
Save