AbstractContextStore implements ContextStore { protected void save(Map<String, Serializable> contextStore, String key, Serializable value, Collection<String> entries) { if (entries.contains(key)) { contextStore.put(key, value); } } AbstractContextStore(String... entries); @Override Collection<String> getSupportedEntries();  }
@Test void save() { Map<String, Serializable> contextStore = new HashMap<>(); this.component.save(contextStore, "key", "value", Arrays.asList()); assertFalse(contextStore.containsKey("key")); this.component.save(contextStore, "key", null, Arrays.asList("key")); assertTrue(contextStore.containsKey("key")); assertNull(contextStore.get("key")); }
@Test void saveSubContext() { SubContextStore subStore = mock(SubContextStore.class); this.component.save(subStore, "prefix", Arrays.asList()); verifyNoMoreInteractions(subStore); this.component.save(subStore, "prefix", Arrays.asList("prefix")); verify(subStore).save("prefix", ""); this.component.save(subStore, "prefix.", Arrays.asList("prefix.subkey")); verify(subStore).save("prefix.subkey", "subkey"); }