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