Esempio n. 1
0
 @Test
 public void loadProjectList_starts_a_request_to_controller_with_correct_path() throws Exception {
   // Setup
   // Exercise
   _apiController.loadProjectList();
   // Verify
   verify(_mockRequestController).sendRequest(getApiVersion(), "projects", ProjectList.class);
 }
Esempio n. 2
0
 @Test
 public void loadProjectList_callback_registers_exception_on_ack_future() throws Exception {
   // Setup
   when(_mockRequestController.sendRequest(getApiVersion(), "projects", ProjectList.class))
       .thenReturn(
           Futures.immediateFailedFuture(new RuntimeException("Unexpected test exception")));
   // Exercise
   final ListenableFuture<Void> ackFuture = _apiController.loadProjectList();
   // Verify
   try {
     ackFuture.get();
   } catch (ExecutionException e) {
     if (e.getCause().getClass() == RuntimeException.class
         && e.getCause().getMessage().equals("Unexpected test exception")) return;
   }
   TestCase.fail();
 }
Esempio n. 3
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));
  }