@Test public void gather_changes() { Object value1 = new Object(); Object value2 = new Object(); PersistentFieldStrategy strat1 = newPersistentFieldStrategy(); Collection<PersistentFieldChange> changes1 = newList(); changes1.add(new PersistentFieldChangeImpl("component", "field1", value1)); PersistentFieldStrategy strat2 = newPersistentFieldStrategy(); Collection<PersistentFieldChange> changes2 = newList(); changes2.add(new PersistentFieldChangeImpl("component", "field2", value2)); getMocksControl().checkOrder(false); expect(strat1.gatherFieldChanges("foo.Bar")).andReturn(changes1); expect(strat2.gatherFieldChanges("foo.Bar")).andReturn(changes2); replay(); Map<String, PersistentFieldStrategy> strategies = newMap(); strategies.put("alpha", strat1); strategies.put("beta", strat2); PersistentFieldManager manager = new PersistentFieldManagerImpl(null, strategies); PersistentFieldBundle bundle = manager.gatherChanges("foo.Bar"); assertSame(bundle.getValue("component", "field1"), value1); assertSame(bundle.getValue("component", "field2"), value2); verify(); }
public PersistentFieldBundle gatherChanges(String pageName) { Collection<PersistentFieldChange> allChanges = CollectionFactory.newList(); for (PersistentFieldStrategy strategy : strategies.values()) { allChanges.addAll(strategy.gatherFieldChanges(pageName)); } return new PersistentFieldBundleImpl(allChanges); }
PersistentFieldManagerImpl implements PersistentFieldManager { public PersistentFieldBundle gatherChanges(String pageName) { Collection<PersistentFieldChange> allChanges = CollectionFactory.newList(); for (PersistentFieldStrategy strategy : strategies.values()) { allChanges.addAll(strategy.gatherFieldChanges(pageName)); } return new PersistentFieldBundleImpl(allChanges); } }
PersistentFieldManagerImpl implements PersistentFieldManager { public PersistentFieldBundle gatherChanges(String pageName) { Collection<PersistentFieldChange> allChanges = CollectionFactory.newList(); for (PersistentFieldStrategy strategy : strategies.values()) { allChanges.addAll(strategy.gatherFieldChanges(pageName)); } return new PersistentFieldBundleImpl(allChanges); } PersistentFieldManagerImpl(MetaDataLocator locator, Map<String, PersistentFieldStrategy> strategies); }
PersistentFieldManagerImpl implements PersistentFieldManager { public PersistentFieldBundle gatherChanges(String pageName) { Collection<PersistentFieldChange> allChanges = CollectionFactory.newList(); for (PersistentFieldStrategy strategy : strategies.values()) { allChanges.addAll(strategy.gatherFieldChanges(pageName)); } return new PersistentFieldBundleImpl(allChanges); } 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 PersistentFieldBundle gatherChanges(String pageName) { Collection<PersistentFieldChange> allChanges = CollectionFactory.newList(); for (PersistentFieldStrategy strategy : strategies.values()) { allChanges.addAll(strategy.gatherFieldChanges(pageName)); } return new PersistentFieldBundleImpl(allChanges); } 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);  }