// =====================================================================
// Create Test Objects
// =====================================================================
final ListProxyImpl listProxy = (ListProxyImpl) createProxy(parentProxyMock);
listProxy.addListener(listenerMock, false);
// =====================================================================
// Set Expectations
// =====================================================================
addExpectationsForAddItemProxy(listProxy, itemProxyMock);
parentProxyMock.expects.isReadOnly().returns(false);
// The item should be detached from the list.
itemProxyMock.expects.detach();
// Should cause an event to be sent to listeners on the object.
RemovedFromListEvent event =
new RemovedFromListEvent(listProxy, 0, 0, true);
listenerMock.expects.removedFromList(event);
// Should also cause an event to be sent to the parent proxy.
parentProxyMock.expects.fireEvent(event);
// Parent should supply the underlying model object.
parentProxyMock.expects.getEmbeddedModelObject(listProxy, false)
.returns(MODEL_LIST).any();
// =====================================================================
// Test Expectations
// =====================================================================
final Proxy itemProxy = listProxy.addItemProxy();
assertEquals("Item Proxy", itemProxyMock, itemProxy);
checkModificationCountIncremented(
listProxy, new Modifier() {
public void modify() {
listProxy.removeItemProxy(itemProxy);
}
});
}