@SuppressWarnings("unchecked")
public void testProjectHasNoAttributesEvent() {
// Test setup
ProjectRpcAsync mockProjService = EasyMock.createMock(ProjectRpcAsync.class);
AttributesView mockView = EasyMock.createMock(AttributesView.class);
SimpleEventBus mockEventBus = EasyMock.createMock(SimpleEventBus.class);
UserRpcAsync securityService = EasyMock.createMock(UserRpcAsync.class);
DataRpcAsync dataService = EasyMock.createMock(DataRpcAsync.class);
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
ArrayList<Signoff> signoffs = new ArrayList<Signoff>();
Collection<String> labels = Lists.newArrayList();
Project parentProject = new Project();
parentProject.setProjectId(42L);
// Test #1 - Verify the ProjectHasNoEvents event get fired.
securityService.hasEditAccess(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(false);
mockProjService.getProjectAttributes(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(attributes);
dataService.getSignoffsByType(EasyMock.eq(42L), EasyMock.eq(AccElementType.ATTRIBUTE),
EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(signoffs);
mockProjService.getLabels(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(labels);
mockEventBus.fireEvent(EasyMock.isA(ProjectHasNoElementsEvent.class));
mockView.setPresenter((AttributesView.Presenter) EasyMock.anyObject());
mockView.setProjectAttributes(attributes);
mockView.setSignoffs(signoffs);
mockView.setProjectLabels(labels);
EasyMock.replay(mockEventBus, mockProjService, mockView, dataService);
AttributesPresenter testPresenter = new AttributesPresenter(
parentProject, mockProjService, securityService, dataService, mockView,
mockEventBus);
EasyMock.verify(mockEventBus, mockProjService, mockView, dataService);
// Test #2 - Verify the ProjectHasNoEvents event does not fire.
EasyMock.reset(mockEventBus, mockProjService, mockView, securityService, dataService);
securityService.hasEditAccess(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(false);
mockProjService.getProjectAttributes(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(attributes);
dataService.getSignoffsByType(EasyMock.eq(42L), EasyMock.eq(AccElementType.ATTRIBUTE),
EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(signoffs);
mockProjService.getLabels(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(labels);
Attribute att = new Attribute();
att.setParentProjectId(42L);
attributes.add(att);
mockView.setPresenter((AttributesView.Presenter) EasyMock.anyObject());
mockView.setProjectAttributes(attributes);
mockView.setSignoffs(signoffs);
mockView.setProjectLabels(labels);
EasyMock.replay(mockEventBus, mockProjService, mockView, securityService, dataService);
AttributesPresenter testPresenter2 = new AttributesPresenter(
parentProject, mockProjService, securityService, dataService, mockView,