Package com.google.testing.testify.risk.frontend.client.view

Examples of com.google.testing.testify.risk.frontend.client.view.AttributesView$Presenter


  @SuppressWarnings("unchecked")
  public void testInitialization() {

    // Test setup
    ProjectRpcAsync mockProjService = EasyMock.createMock(ProjectRpcAsync.class);
    AttributesView mockView = EasyMock.createMock(AttributesView.class);
    UserRpcAsync securityService = EasyMock.createMock(UserRpcAsync.class);
    DataRpcAsync dataService = EasyMock.createMock(DataRpcAsync.class);

    ArrayList<Attribute> attributes = Lists.newArrayList();
    ArrayList<Signoff> signoffs = Lists.newArrayList();
    Collection<String> labels = Lists.newArrayList();

    Project parentProject = new Project();
    parentProject.setProjectId(42L);

    // Verify this initialization sequence
    securityService.hasEditAccess(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(true);
    mockProjService.getProjectAttributes(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(attributes);
    mockProjService.getLabels(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(labels);

    dataService.getSignoffsByType(EasyMock.eq(42L), EasyMock.eq(AccElementType.ATTRIBUTE),
        EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(signoffs);
    mockView.setPresenter((AttributesView.Presenter) EasyMock.anyObject());
    mockView.enableEditing();
    mockView.setProjectAttributes(attributes);
    mockView.setSignoffs(signoffs);
    mockView.setProjectLabels(labels);

    EasyMock.replay(mockView, mockProjService, securityService, dataService);

    AttributesPresenter testPresenter = new AttributesPresenter(parentProject, mockProjService,
        securityService, dataService, mockView, new SimpleEventBus());
View Full Code Here


  @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,
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public void testAttributeAddedEventOnInitialization() {
    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);
View Full Code Here

  @SuppressWarnings("unchecked")
  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>();
View Full Code Here

TOP

Related Classes of com.google.testing.testify.risk.frontend.client.view.AttributesView$Presenter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.