@Test public void post_change_with_unknown_strategy() { String fieldName = "field"; PersistentFieldStrategy strat1 = newPersistentFieldStrategy(); PersistentFieldStrategy strat2 = newPersistentFieldStrategy(); ComponentResources resources = mockComponentResources(); ComponentModel model = mockComponentModel(); Map<String, PersistentFieldStrategy> strategies = newMap(); strategies.put("foo", strat1); strategies.put("bar", strat2); train_getComponentModel(resources, model); train_getFieldPersistenceStrategy(model, fieldName, "braveheart"); replay(); PersistentFieldManager manager = new PersistentFieldManagerImpl(null, strategies); try { manager.postChange("foo.Bar", resources, fieldName, null); unreachable(); } catch (UnknownValueException ex) { assertEquals(ex.getMessage(), "'braveheart' is not a defined persistent strategy."); assertListsEquals(ex.getAvailableValues().getValues(), "bar", "foo"); } verify(); }
public void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue) { String strategyName = findStrategy(resources, fieldName); PersistentFieldStrategy strategy = getStrategy(strategyName); strategy.postChange(pageName, resources.getNestedId(), fieldName, newValue); }
PersistentFieldManagerImpl implements PersistentFieldManager { public void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue) { String strategyName = findStrategy(resources, fieldName); PersistentFieldStrategy strategy = getStrategy(strategyName); strategy.postChange(pageName, resources.getNestedId(), fieldName, newValue); } }
PersistentFieldManagerImpl implements PersistentFieldManager { public void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue) { String strategyName = findStrategy(resources, fieldName); PersistentFieldStrategy strategy = getStrategy(strategyName); strategy.postChange(pageName, resources.getNestedId(), fieldName, newValue); } PersistentFieldManagerImpl(MetaDataLocator locator, Map<String, PersistentFieldStrategy> strategies); }
PersistentFieldManagerImpl implements PersistentFieldManager { public void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue) { String strategyName = findStrategy(resources, fieldName); PersistentFieldStrategy strategy = getStrategy(strategyName); strategy.postChange(pageName, resources.getNestedId(), fieldName, newValue); } PersistentFieldManagerImpl(MetaDataLocator locator, Map<String, PersistentFieldStrategy> strategies); PersistentFieldBundle gatherChanges(String pageName); void discardChanges(String pageName); void discardChanges(String pageName, String strategyName); void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue); }
PersistentFieldManagerImpl implements PersistentFieldManager { public void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue) { String strategyName = findStrategy(resources, fieldName); PersistentFieldStrategy strategy = getStrategy(strategyName); strategy.postChange(pageName, resources.getNestedId(), fieldName, newValue); } PersistentFieldManagerImpl(MetaDataLocator locator, Map<String, PersistentFieldStrategy> strategies); PersistentFieldBundle gatherChanges(String pageName); void discardChanges(String pageName); void discardChanges(String pageName, String strategyName); void postChange(String pageName, ComponentResources resources, String fieldName, Object newValue);  }