void () { Registry.getInstance().reset(); String key = "first.key1"; String firstVal = "first.value1"; String secondValue = "second.value1"; String newKey = "another.key"; String newValue = "another.value"; final AtomicReference<Pair<String, String>> lastChangedPair = new AtomicReference<>(); final List<Pair<String, String>> changedPairs = new ArrayList<>(); Registry.setValueChangeListener(new RegistryValueListener() { @Override public void afterValueChanged(@NotNull RegistryValue value) { if (!(value.getKey().equals(key))) return; Pair<String, String> pair = Pair.create(value.getKey(), value.asString()); lastChangedPair.set(pair); changedPairs.add(pair); } }); Map<String, String> firstMap = new LinkedHashMap<>(); firstMap.put(key, firstVal); Registry.loadState(registryElementFromMap(firstMap), null); assertEquals(firstVal, Registry.get(key).asString()); assertNull(lastChangedPair.get()); Map<String, String> secondMap = new LinkedHashMap<>(); secondMap.put(key, secondValue); secondMap.put(newKey, newValue); Registry.loadState(registryElementFromMap(secondMap), null); assertEquals(secondValue, Registry.get(key).asString()); RegistryValue newRegistryValue = Registry.get(newKey); String loadedNewValue = newRegistryValue.get(newRegistryValue.getKey(), null, false); assertNull(loadedNewValue); assertEquals(1, changedPairs.size()); }