public class CapabilitiesPresenterTest extends TestCase {
// Unit test the handshake between View and Presenter.
@SuppressWarnings("unchecked")
public void testInitialization() {
CapabilitiesView mockView = EasyMock.createMock(CapabilitiesView.class);
ProjectRpcAsync projectService = EasyMock.createMock(ProjectRpcAsync.class);
UserRpcAsync securityService = EasyMock.createMock(UserRpcAsync.class);
SimpleEventBus mockEventBus = EasyMock.createMock(SimpleEventBus.class);
Project testProject = new Project();
testProject.setProjectId(42L);
ArrayList<Component> components = Lists.newArrayList();
ArrayList<Attribute> attributes = Lists.newArrayList();
ArrayList<Capability> capabilities = Lists.newArrayList();
Collection<String> labels = Lists.newArrayList();
// Verify the initialization steps, ensure the async callbacks return the expected collections.
securityService.hasEditAccess(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(true);
projectService.getProjectAttributes(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(capabilities);
projectService.getProjectComponents(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(components);
projectService.getProjectCapabilities(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(capabilities);
projectService.getLabels(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(labels);
mockView.setEditable(true);
mockView.setPresenter(EasyMock.isA(CapabilitiesPresenter.class));
mockView.setComponents(components);
mockView.setAttributes(attributes);
mockView.setCapabilities(capabilities);
mockView.setProjectLabels(labels);
EasyMock.replay(mockView, projectService, securityService);
CapabilitiesPresenter testPresenter = null;
testPresenter = new CapabilitiesPresenter(testProject, projectService, securityService,