### Question:
Scope extends MapWrapper<String, Object> { @SuppressWarnings("unchecked") public void addValue(String key, String name, Object value) { Object oldValue = get(key); List<Object> list; if (oldValue == null) { list = new ArrayList<>(); } else if (oldValue instanceof List) { list = (List<Object>) oldValue; } else { list = new ArrayList<>(); list.add(oldValue); } list.add(value); put(key, list); names.put(value, name); } Scope(Scope parent, Map<String, Object> values);  Scope(Scope parent); Scope getParent(); @SuppressWarnings("unchecked") S getClosest(Class<S> scopeClass); RootScope getRootScope(); FileScope getFileScope(); Object find(Node node, String key); @SuppressWarnings("unchecked") void addValue(String key, String name, Object value); String getName(Object value); Node getLocation(String key); void putLocation(String key, Node node); @SuppressWarnings("unchecked") S getSettings(Class<S> settingsClass); LoadingCache<Class<? extends Settings>, Settings> getSettingsByClass();  }### Answer:
@Test void addValueNull() { Scope scope = new Scope(null); scope.addValue("foo", null, "bar"); assertThat(scope.get("foo")) .asList() .containsExactly("bar"); }
@Test void addValueList() { Scope scope = new Scope(null); scope.put("foo", new ArrayList<>(Collections.singletonList("bar"))); scope.addValue("foo", null, "qux"); assertThat(scope.get("foo")) .asList() .containsExactly("bar", "qux"); }
@Test void addValueScalar() { Scope scope = new Scope(null); scope.put("foo", "bar"); scope.addValue("foo", null, "qux"); assertThat(scope.get("foo")) .asList() .containsExactly("bar", "qux"); }