Search in sources :

Example 1 with MilestoneReleaseResultRest

use of org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest 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 MilestoneReleaseResultRest

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

the class ProductMilestoneReleaseManager method triggerRelease.

@Deprecated
private ProductMilestoneRelease triggerRelease(ProductMilestone milestone, String accessToken, Long milestoneReleaseId) {
    ProductMilestoneRelease release = new ProductMilestoneRelease();
    release.setId(milestoneReleaseId);
    release.setStartingDate(new Date());
    release.setMilestone(milestone);
    try {
        MilestoneReleaseTask releaseTask = new MilestoneReleaseTask(milestone, accessToken);
        Integer id = milestone.getId();
        releaseTask.<MilestoneReleaseResultRest>addListener(BpmEventType.BREW_IMPORT, r -> onPushResult(id, r));
        release.setStatus(MilestoneCloseStatus.IN_PROGRESS);
        bpmManager.startTask(releaseTask);
        userLog.info("Release process started.");
        productMilestoneCloseResultEvent.fire(mapper.toDTO(release));
        return release;
    } catch (CoreException e) {
        log.error("Error trying to start brew push task for milestone: {}", milestone.getId(), e);
        userLog.error("Release process creation failed.", e);
        release.setStatus(MilestoneCloseStatus.SYSTEM_ERROR);
        release.setEndDate(new Date());
        productMilestoneCloseResultEvent.fire(mapper.toDTO(release));
        return release;
    }
}
Also used : MilestoneReleaseResultRest(org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest) CoreException(org.jboss.pnc.spi.exception.CoreException) MilestoneReleaseTask(org.jboss.pnc.bpm.task.MilestoneReleaseTask) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease) Date(java.util.Date)

Example 3 with MilestoneReleaseResultRest

use of org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest 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

MilestoneReleaseResultRest (org.jboss.pnc.bpm.model.causeway.MilestoneReleaseResultRest)3 ArrayList (java.util.ArrayList)2 BuildImportResultRest (org.jboss.pnc.bpm.model.causeway.BuildImportResultRest)2 Date (java.util.Date)1 MilestoneReleaseTask (org.jboss.pnc.bpm.task.MilestoneReleaseTask)1 ProductMilestoneRelease (org.jboss.pnc.model.ProductMilestoneRelease)1 CoreException (org.jboss.pnc.spi.exception.CoreException)1 Test (org.junit.Test)1