Search in sources :

Example 1 with BuildImportResultRest

use of org.jboss.pnc.bpm.model.causeway.BuildImportResultRest in project pnc by project-ncl.

the class ProductMilestoneReleaseManagerTest method shouldStorePartialImport.

@Test
public void shouldStorePartialImport() {
    // given
    ProductMilestone milestone = createMilestone();
    BuildRecord buildRecord1 = buildRecord(milestone);
    BuildRecord buildRecord2 = buildRecord(milestone);
    MilestoneReleaseResultRest result = new MilestoneReleaseResultRest();
    List<BuildImportResultRest> buildResults = new ArrayList<>();
    buildResults.add(buildImportResultRest(BuildImportStatus.SUCCESSFUL, buildRecord1.getId(), 1));
    buildResults.add(buildImportResultRest(BuildImportStatus.FAILED, buildRecord2.getId(), 2));
    result.setBuilds(buildResults);
    result.setReleaseStatus(ReleaseStatus.IMPORT_ERROR);
    // when
    release(milestone, result);
    // then
    BuildRecordPushResult pushResult1 = buildRecordPushResultRepository.getLatestForBuildRecord(buildRecord1.getId());
    assertThat(pushResult1).isNotNull();
    assertThat(pushResult1.getStatus()).isEqualTo(BuildPushStatus.SUCCESS);
    BuildRecordPushResult pushResult2 = buildRecordPushResultRepository.getLatestForBuildRecord(buildRecord2.getId());
    assertThat(pushResult2).isNotNull();
    assertThat(pushResult2.getStatus()).isEqualTo(BuildPushStatus.FAILED);
    List<ProductMilestoneRelease> releases = productMilestoneReleaseRepository.queryAll();
    assertThat(releases).hasSize(1).first().extracting(ProductMilestoneRelease::getStatus).isEqualTo(MilestoneCloseStatus.FAILED);
}
Also used : MilestoneReleaseResultRest(org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest) BuildImportResultRest(org.jboss.pnc.bpm.model.causeway.BuildImportResultRest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with BuildImportResultRest

use of org.jboss.pnc.bpm.model.causeway.BuildImportResultRest in project pnc by project-ncl.

the class ProductMilestoneReleaseManager method storeResult.

private void storeResult(ProductMilestone milestone, MilestoneReleaseResultRest result) {
    ProductMilestoneRelease productMilestoneRelease = updateRelease(milestone, result.getReleaseStatus().getMilestoneReleaseStatus()).orElseThrow(() -> new NoEntityException("ProductMilestoneRelease not found."));
    for (BuildImportResultRest buildRest : ofNullableCollection(result.getBuilds())) {
        storeBuildRecordPush(buildRest, productMilestoneRelease);
    }
    if (result.getReleaseStatus().getMilestoneReleaseStatus() == MilestoneCloseStatus.SUCCEEDED) {
        // set milestone end date to now when the release process is successful
        milestone.setEndDate(new Date());
        milestoneRepository.save(milestone);
        removeCurrentFlagFromMilestone(milestone);
    }
    productMilestoneCloseResultEvent.fire(mapper.toDTO(productMilestoneRelease));
}
Also used : BuildImportResultRest(org.jboss.pnc.bpm.model.causeway.BuildImportResultRest) NoEntityException(org.jboss.pnc.bpm.NoEntityException) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease) Date(java.util.Date)

Example 3 with BuildImportResultRest

use of org.jboss.pnc.bpm.model.causeway.BuildImportResultRest in project pnc by project-ncl.

the class ProductMilestoneReleaseManagerTest method successfulReleaseResult.

private MilestoneReleaseResultRest successfulReleaseResult(int brewBuildId, BuildRecord... records) {
    MilestoneReleaseResultRest result = new MilestoneReleaseResultRest();
    List<BuildImportResultRest> buildResults = new ArrayList<>();
    for (int i = 0; i < records.length; i++) {
        Base32LongID recordId = records[i].getId();
        buildResults.add(buildImportResultRest(BuildImportStatus.SUCCESSFUL, recordId, brewBuildId + i));
    }
    result.setBuilds(buildResults);
    result.setReleaseStatus(ReleaseStatus.SUCCESS);
    return result;
}
Also used : MilestoneReleaseResultRest(org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest) BuildImportResultRest(org.jboss.pnc.bpm.model.causeway.BuildImportResultRest) ArrayList(java.util.ArrayList)

Aggregations

BuildImportResultRest (org.jboss.pnc.bpm.model.causeway.BuildImportResultRest)3 ArrayList (java.util.ArrayList)2 MilestoneReleaseResultRest (org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest)2 Date (java.util.Date)1 NoEntityException (org.jboss.pnc.bpm.NoEntityException)1 ProductMilestoneRelease (org.jboss.pnc.model.ProductMilestoneRelease)1 Test (org.junit.Test)1