Beispiel #1
0
  @Test
  public void requestLastBuildStatus_callback_records_build_on_build_type() throws Exception {
    // Setup
    final BuildTypeData bt1 = new BuildTypeData("bt1", "btName", "pname", "pId");
    _buildTypeManager.registerBuildTypes(ImmutableList.of(bt1));
    _buildTypeManager.activateMonitoring(bt1);

    final BuildList buildList = new BuildList();
    final Build b12246 =
        new Build(
            12246,
            new BuildType("bt1", "btname", "btprojectName", "btProjectid"),
            BuildStatus.FAILURE,
            BuildState.finished,
            false);
    buildList.addBuild(b12246);

    when(_mockRequestController.sendRequest(
            getApiVersion(),
            "builds/?locator=buildType:bt1,running:any,branch:(default:any),count:"
                + ApiController.MAX_BUILDS_TO_CONSIDER,
            BuildList.class))
        .thenReturn(Futures.immediateFuture(buildList));
    when(_mockRequestController.sendRequest(getApiVersion(), "builds/id:12246", Build.class))
        .thenReturn(Futures.immediateFuture(b12246));
    // Exercise
    _apiController.requestLastBuildStatus(bt1);
    // Verify
    assertThat(bt1.getBuildById(12246), is(notNullValue()));
  }
Beispiel #2
0
  @Test
  public void
      requestQueuedBuilds_callback_reccords_queued_status_and_dispatches_modified_build_type_on_event_bus()
          throws Exception {
    // Setup
    final BuildTypeData bt1 = new BuildTypeData("bt1", "btName", "pname", "pId");
    final BuildTypeData bt2 = new BuildTypeData("bt2", "btName", "pname", "pId");
    final BuildTypeData bt3 = new BuildTypeData("bt3", "btName", "pname", "pId");
    bt3.setQueued(true);
    final BuildTypeData bt4 = new BuildTypeData("bt4", "btName", "pname", "pId");
    bt4.setQueued(true);
    _buildTypeManager.registerBuildTypes(ImmutableList.of(bt1, bt2, bt3, bt4));

    _buildTypeManager.activateMonitoring(bt1);
    _buildTypeManager.activateMonitoring(bt2);
    _buildTypeManager.activateMonitoring(bt3);
    _buildTypeManager.activateMonitoring(bt4);

    final QueuedBuildList queuedBuildList = new QueuedBuildList();
    queuedBuildList.addBuildType(new QueueBuild("bt2"));
    queuedBuildList.addBuildType(new QueueBuild("bt3"));
    when(_mockRequestController.sendRequest(getApiVersion(), "buildQueue", QueuedBuildList.class))
        .thenReturn(Futures.immediateFuture(queuedBuildList));
    // Exercise
    _apiController.requestQueuedBuilds();
    // Verify
    assertThat(bt1.isQueued(), is(false));
    assertThat(bt2.isQueued(), is(true));
    assertThat(bt3.isQueued(), is(true));
    assertThat(bt4.isQueued(), is(false));
    assertThat(_dispatchedObjects, not(hasItem(bt1)));
    assertThat(_dispatchedObjects, hasItem(bt2));
    assertThat(_dispatchedObjects, not(hasItem(bt3)));
    assertThat(_dispatchedObjects, hasItem(bt4));
  }