public void testAttributeAddedEvent() {
ProjectRpcAsync mockProjService = EasyMock.createMock(ProjectRpcAsync.class);
AttributesView mockView = EasyMock.createMock(AttributesView.class);
// Since HandlerManager is a concrete type, must import 'org.easymock.EasyMock'
SimpleEventBus mockEventBus = EasyMock.createMock(SimpleEventBus.class);
UserRpcAsync securityService = EasyMock.createMock(UserRpcAsync.class);
DataRpcAsync dataService = EasyMock.createMock(DataRpcAsync.class);
ArrayList<Signoff> signoffs = new ArrayList<Signoff>();
Collection<String> labels = Lists.newArrayList();
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
Attribute att = new Attribute();
att.setParentProjectId(42L);
attributes.add(att);
Project parentProject = new Project();
parentProject.setProjectId(42L);
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);
AttributesPresenter testPresenter = new AttributesPresenter(
parentProject, mockProjService, securityService, dataService, mockView,
mockEventBus);
EasyMock.reset(mockEventBus, mockProjService, securityService, dataService);
Attribute newAttribute = new Attribute();
newAttribute.setParentProjectId(42L);
mockProjService.createAttribute(EasyMock.eq(newAttribute), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(1L);
mockEventBus.fireEvent(EasyMock.isA(ProjectElementAddedEvent.class));
// Attributes queried due to the view refresh.
securityService.hasEditAccess(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
EasyMockUtils.setLastAsyncCallbackSuccessWithResult(false);
mockProjService.getProjectAttributes(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));