StackWizardSettings implements WizardSettings { public void rollBack() { _pageStack.pop(); } StackWizardSettings(); Set<String> keySet(); boolean containsKey(String key); void rollBack(); void commit(); void newPage(String id); Object put(String key, Object value); @Override Object get(String key); @Override String toString(); @Override void clear(); @Override boolean containsValue(Object value); @Override boolean isEmpty(); @Override void putAll(Map<? extends String, ? extends Object> m); @Override Object remove(String key); void removeAll(Object key); @Override int size(); boolean settingsEquals(WizardSettings ws);  }
@Test public void testRollBack() { WizardSettings s = new StackWizardSettings(); final String key1 = "key1"; final String key2 = "key2"; final String key3 = "key3"; final String value1 = "value1"; final String value2 = "value2"; final String value3 = "value3"; final String value4 = "value4"; final String page1 = "page1"; final String page2 = "page2"; s.newPage(page1); s.put(key1, value1); s.put(key2, value2); s.newPage(page2); s.put(key3, value3); Assert.assertEquals("Wrong value", s.get(key1), value1); s.put(key1, value4); Assert.assertEquals("Wrong value", s.get(key1), value4); Assert.assertEquals("Wrong value", s.get(key2), value2); Assert.assertEquals("Wrong value", s.get(key3), value3); s.rollBack(); Assert.assertNull("key should not exist", s.get(key3)); Assert.assertEquals("Wrong value", s.get(key1), value1); Assert.assertEquals("Wrong value", s.get(key2), value2); }