Example #1
0
 @Test
 public void loadBuildTypeList_starts_a_request_to_controller_with_correct_path()
     throws Exception {
   // Setup
   // Exercise
   _apiController.loadBuildTypeList();
   // Verify
   verify(_mockRequestController).sendRequest(getApiVersion(), "buildTypes", BuildTypeList.class);
 }
Example #2
0
 @Test
 public void loadBuildTypeList_callback_registers_exception_on_ack_future() throws Exception {
   // Setup
   when(_mockRequestController.sendRequest(getApiVersion(), "buildTypes", BuildTypeList.class))
       .thenReturn(
           Futures.immediateFailedFuture(new RuntimeException("Unexpected test exception")));
   // Exercise
   final ListenableFuture<Void> ackFuture = _apiController.loadBuildTypeList();
   // Verify
   try {
     ackFuture.get();
   } catch (ExecutionException e) {
     if (e.getCause().getClass() == RuntimeException.class
         && e.getCause().getMessage().equals("Unexpected test exception")) return;
   }
   TestCase.fail();
 }
Example #3
0
  @Test
  public void loadBuildTypeList_callback_dispatches_parent_project_on_event_bus() throws Exception {
    // Setup
    final ProjectData project = new ProjectData("p1", "pname", Optional.<String>empty());
    final ProjectData project2 = new ProjectData("p2", "pname", Optional.<String>empty());
    _projectManager.registerProjects(ImmutableList.of(project, project2));

    final BuildTypeList buildTypelist = new BuildTypeList();
    buildTypelist.addBuildType(new BuildType("bt1", "btName", "pname", "p2"));

    when(_mockRequestController.sendRequest(getApiVersion(), "buildTypes", BuildTypeList.class))
        .thenReturn(Futures.immediateFuture(buildTypelist));
    // Exercise
    _apiController.loadBuildTypeList();
    // Verify
    assertThat(_dispatchedObjects, not(hasItem(project)));
    assertThat(_dispatchedObjects, hasItem(project2));
  }
Example #4
0
  @Test
  public void
      loadBuildTypeList_callback_registers_project_to_BuildTypeManager_and_dispatch_it_on_event_bus()
          throws Exception {
    // Setup
    final BuildTypeList buildTypelist = new BuildTypeList();
    buildTypelist.addBuildType(new BuildType("bt1", "btName", "btProjectName", "btProjectId"));
    buildTypelist.addBuildType(new BuildType("bt2", "btName", "btProjectName", "btProjectId"));

    when(_mockRequestController.sendRequest(getApiVersion(), "buildTypes", BuildTypeList.class))
        .thenReturn(Futures.immediateFuture(buildTypelist));
    // Exercise
    final ListenableFuture<Void> ackFuture = _apiController.loadBuildTypeList();
    // Verify
    assertThat(_buildTypeManager.getBuildTypes().size(), is(2));
    assertThat(_buildTypeManager.getBuildTypes().get(0).getId(), is("bt1"));
    assertThat(_buildTypeManager.getBuildTypes().get(1).getId(), is("bt2"));
    assertThat(_dispatchedObjects, hasItem(_buildTypeManager));
    assertThat(ackFuture.isDone(), is(true));
  }