예제 #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()));
  }
예제 #2
0
  @Test
  public void requestLastBuildStatus_callback_starts_requests_to_retreive_last_build_status()
      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);
    final Build b12247 =
        new Build(
            12247,
            new BuildType("bt1", "btname", "btprojectName", "btProjectid"),
            BuildStatus.FAILURE,
            BuildState.finished,
            false);
    final Build b12248 =
        new Build(
            12248,
            new BuildType("bt1", "btname", "btprojectName", "btProjectid"),
            BuildStatus.FAILURE,
            BuildState.finished,
            false);
    final Build b12249 =
        new Build(
            12249,
            new BuildType("bt1", "btname", "btprojectName", "btProjectid"),
            BuildStatus.FAILURE,
            BuildState.finished,
            false);
    buildList.addBuild(b12249);
    buildList.addBuild(b12248);
    buildList.addBuild(b12247);
    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));
    when(_mockRequestController.sendRequest(getApiVersion(), "builds/id:12247", Build.class))
        .thenReturn(Futures.immediateFuture(b12247));
    when(_mockRequestController.sendRequest(getApiVersion(), "builds/id:12248", Build.class))
        .thenReturn(Futures.immediateFuture(b12248));
    when(_mockRequestController.sendRequest(getApiVersion(), "builds/id:12249", Build.class))
        .thenReturn(Futures.immediateFuture(b12249));
    // Exercise
    _apiController.requestLastBuildStatus(bt1);
    // Verify
    verify(_mockRequestController)
        .sendRequest(
            getApiVersion(),
            "builds/?locator=buildType:bt1,running:any,branch:(default:any),count:"
                + ApiController.MAX_BUILDS_TO_CONSIDER,
            BuildList.class);
    verify(_mockRequestController, atLeastOnce())
        .sendRequest(getApiVersion(), "builds/id:12249", Build.class);
    verify(_mockRequestController, atLeastOnce())
        .sendRequest(getApiVersion(), "builds/id:12248", Build.class);
    verify(_mockRequestController, atLeastOnce())
        .sendRequest(getApiVersion(), "builds/id:12247", Build.class);
    verify(_mockRequestController, never())
        .sendRequest(getApiVersion(), "builds/id:12246", Build.class);
  }