Beispiel #1
0
  @Test
  public void
      loadProjectList_callback_registers_project_to_ProjectManager_and_dispatch_it_on_event_bus()
          throws Exception {
    // Setup
    final ProjectList projectList = new ProjectList();
    projectList.addProject(new Project("pId1", "pName", "pParentId"));
    projectList.addProject(new Project("pId2", "pName", "pParentId"));

    when(_mockRequestController.sendRequest(getApiVersion(), "projects", ProjectList.class))
        .thenReturn(Futures.immediateFuture(projectList));
    // Exercise
    final ListenableFuture<Void> ackFuture = _apiController.loadProjectList();
    // Verify
    assertThat(_projectManager.getProjects().size(), is(2));
    assertThat(_projectManager.getProjects().get(0).getId(), is("pId1"));
    assertThat(_projectManager.getProjects().get(1).getId(), is("pId2"));
    assertThat(_dispatchedObjects, hasItem(_projectManager));
    assertThat(ackFuture.isDone(), is(true));
  }