EasyMock.verify(view, formItem);
}
@Test
public void testOnSaveChanges() throws Exception {
final FBFormItem formItem = EasyMock.createMock(FBFormItem.class);
final Map<String, Object> oldProps = new HashMap<String, Object>();
final Map<String, Object> newProps = new HashMap<String, Object>();
UndoableHandler handler = EasyMock.createMock(UndoableHandler.class);
handler.onEvent(EasyMock.isA(UndoableEvent.class));
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
Object[] params = EasyMock.getCurrentArguments();
UndoableEvent event = (UndoableEvent) params[0];
assertNotNull("oldItems shouldn't be null", event.getData("oldItems"));
assertNotNull("newItems shouldn't be null", event.getData("newItems"));
assertNotNull("itemSelected shouldn't be null", event.getData("itemSelected"));
assertSame("oldProps and oldItems should be the same", oldProps, event.getData("oldItems"));
assertSame("newProps and newItems should be the same", newProps, event.getData("newItems"));
assertSame("formItem and itemSelected should be the same", formItem, event.getData("itemSelected"));
return null;
}
}).once();
bus.addHandler(UndoableEvent.TYPE, handler);
formItem.saveValues(EasyMock.same(newProps));
EasyMock.expectLastCall().once();
EasyMock.replay(view, formItem);
EditionPresenter presenter = new EditionPresenter(view);
presenter.onSaveChanges(oldProps, newProps, formItem);
EasyMock.verify(view, formItem);