Package com.google.testing.testify.risk.frontend.shared.rpc

Examples of com.google.testing.testify.risk.frontend.shared.rpc.ProjectRpcAsync


  // Check the handshake between Presenter and View
  @SuppressWarnings("unchecked")
  public void testInitialization() {
    // Test setup
    ProjectRpcAsync projServiceObserver = EasyMock.createMock(ProjectRpcAsync.class);
    ProjectSettingsView viewObserver = EasyMock.createMock(ProjectSettingsView.class);
    ComponentsView.Presenter mockParent = EasyMock.createMock(ComponentsView.Presenter.class);

    ComponentView mockComponentView = EasyMock.createMock(ComponentView.class);
    Component targetComponent = new Component(0L);
View Full Code Here


  // 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);
View Full Code Here

public class ProjectSettingsPresenterTest extends TestCase {

  @SuppressWarnings("unchecked")
  public void testSetPresenter() {
    UserRpcAsync securityService = EasyMock.createMock(UserRpcAsync.class);
    ProjectRpcAsync projServiceObserver = EasyMock.createMock(ProjectRpcAsync.class);
    ProjectSettingsView viewObserver = EasyMock.createMock(ProjectSettingsView.class);
    Project project = new Project();
    project.setProjectId(42L);

    securityService.getAccessLevel(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
View Full Code Here

  // Check the handshake between Presenter and View
  @SuppressWarnings("unchecked")
  public void testInitialization() {

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

    List<Component> components = new ArrayList<Component>();
    List<Signoff> signoffs = new ArrayList<Signoff>();
    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.getProjectComponents(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(components);
    dataService.getSignoffsByType(EasyMock.eq(42L), EasyMock.eq(AccElementType.COMPONENT),
        EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(signoffs);
    mockProjService.getLabels(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(labels);
    mockView.enableEditing();
    mockView.setPresenter((Presenter) EasyMock.anyObject());
    mockView.setProjectComponents(components);
    mockView.setSignoffs(signoffs);
View Full Code Here

  // Check the handshake between Presenter and View
  @SuppressWarnings("unchecked")
  public void testInitialization() {

    // Test setup
    ProjectRpcAsync projServiceObserver = EasyMock.createMock(ProjectRpcAsync.class);
    AttributesView.Presenter mockParent = EasyMock.createMock(AttributesView.Presenter.class);

    AttributeView mockAttributeView = EasyMock.createMock(AttributeView.class);
    Attribute targetAttribute = new Attribute();
    targetAttribute.setParentProjectId(0L);
View Full Code Here

  // Check the handshake between Presenter and View
  @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);
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);
View Full Code Here

    EasyMock.verify(mockEventBus, mockProjService, mockView, securityService, dataService);
  }

  @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);

    ArrayList<Attribute> attributes = new ArrayList<Attribute>();
    Attribute att = new Attribute();
    att.setAttributeId(42L);
    attributes.add(att);
    ArrayList<Signoff> signoffs = new ArrayList<Signoff>();
    Collection<String> labels = Lists.newArrayList();

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

    securityService.hasEditAccess(EasyMock.eq(42L), EasyMock.isA(AsyncCallback.class));
    EasyMockUtils.setLastAsyncCallbackSuccessWithResult(true);
    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);
    EasyMock.replay(mockEventBus, mockProjService, securityService, dataService);

    AttributesPresenter testPresenter = new AttributesPresenter(
        parentProject, mockProjService, securityService, dataService, mockView,
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>();
    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));
    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);

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

    testPresenter.createAttribute(newAttribute);
View Full Code Here

TOP

Related Classes of com.google.testing.testify.risk.frontend.shared.rpc.ProjectRpcAsync

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.