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);
}
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;
}
}
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;
}
Aggregations