use of org.jboss.pnc.model.ProductMilestone in project pnc by project-ncl.
the class ProductReleaseProviderTest method createNewProductReleaseDTO.
private org.jboss.pnc.dto.ProductRelease createNewProductReleaseDTO(String version, Integer id) {
// when
ProductMilestone milestone = prepareNewProductMilestone();
when(productRepository.queryById(milestone.getProductVersion().getProduct().getId())).thenReturn(milestone.getProductVersion().getProduct());
when(productVersionRepository.queryById(milestone.getProductVersion().getId())).thenReturn(milestone.getProductVersion());
when(productMilestoneRepository.queryById(milestone.getId())).thenReturn(milestone);
ProductMilestoneRef ref = productMilestoneMapper.toRef(milestone);
ProductVersionRef productVersionRef = productVersionMapper.toRef(milestone.getProductVersion());
org.jboss.pnc.dto.ProductRelease.Builder releaseDTO = org.jboss.pnc.dto.ProductRelease.builder().version(version).productVersion(productVersionRef).productMilestone(ref);
if (id != null) {
return releaseDTO.id(id.toString()).build();
} else {
return releaseDTO.build();
}
}
use of org.jboss.pnc.model.ProductMilestone in project pnc by project-ncl.
the class ProductVersionProviderTest method testShouldThrowWhenCurrentMilestoneIsClosed.
@Test
public void testShouldThrowWhenCurrentMilestoneIsClosed() {
String newVersion = "19.0";
org.jboss.pnc.dto.ProductVersion withClosedMilestone = provider.getSpecific("2");
ProductMilestoneRef closedMilestone = withClosedMilestone.getProductMilestones().values().iterator().next();
org.jboss.pnc.dto.ProductVersion updated = withClosedMilestone.toBuilder().currentProductMilestone(closedMilestone).build();
ProductMilestone closedReturn = new ProductMilestone();
closedReturn.setId(Integer.parseInt(closedMilestone.getId()));
closedReturn.setEndDate(new Date());
when(milestoneRepository.queryById(anyInt())).thenReturn(closedReturn);
assertThatThrownBy(() -> provider.update(withClosedMilestone.getId(), updated)).isInstanceOf(InvalidEntityException.class);
}
use of org.jboss.pnc.model.ProductMilestone in project pnc by project-ncl.
the class ProductMilestoneReleaseManager method onPushResult.
private void onPushResult(Integer milestoneId, MilestoneReleaseResultRest result) {
log.debug("Storing milestone release result: {}", result);
ProductMilestone milestone = milestoneRepository.queryById(milestoneId);
if (milestone == null) {
log.error("No milestone found for milestone id {}", milestoneId);
return;
}
storeResult(milestone, result);
userLog.info("Milestone release result stored.");
}
use of org.jboss.pnc.model.ProductMilestone in project pnc by project-ncl.
the class ProductMilestoneReleaseManager method cancel.
public void cancel(ProductMilestone milestoneInDb, String accessToken, boolean useRHPAM) {
if (!useRHPAM) {
Collection<BpmTask> activeTasks = bpmManager.getActiveTasks();
Optional<MilestoneReleaseTask> milestoneReleaseTask = activeTasks.stream().map(task -> (MilestoneReleaseTask) task).filter(task -> task.getMilestone().getId().equals(milestoneInDb.getId())).findAny();
if (milestoneReleaseTask.isPresent()) {
bpmManager.cancelTask(milestoneReleaseTask.get());
}
} else {
RestConnector restConnector = new RestConnector(bpmConfig);
restConnector.cancelByCorrelation(Numbers.decimalToBase32(milestoneInDb.getId()), accessToken);
}
ProductMilestoneRelease milestoneRelease = productMilestoneReleaseRepository.findLatestByMilestone(milestoneInDb);
milestoneRelease.setStatus(MilestoneCloseStatus.CANCELED);
productMilestoneReleaseRepository.save(milestoneRelease);
}
use of org.jboss.pnc.model.ProductMilestone in project pnc by project-ncl.
the class OperationsManagerImpl method newDeliverableAnalyzerOperation.
@Override
public DeliverableAnalyzerOperation newDeliverableAnalyzerOperation(String milestoneId, Map<String, String> inputParams) {
ProductMilestone milestone = productMilestoneRepository.queryById(ProductMilestoneMapper.idMapper.toEntity(milestoneId));
if (milestone == null) {
throw new EmptyEntityException("Milestone with id " + milestoneId + " doesn't exist");
}
String operationId = Sequence.nextBase32Id();
MDCUtils.addProcessContext(operationId);
org.jboss.pnc.model.DeliverableAnalyzerOperation operation = org.jboss.pnc.model.DeliverableAnalyzerOperation.Builder.newBuilder().progressStatus(ProgressStatus.NEW).submitTime(Date.from(Instant.now())).productMilestone(milestone).operationParameters(inputParams).user(userService.currentUser()).id(operationId).build();
repository.save(operation);
analysisStatusChangedEventNotifier.fire(new OperationChangedEvent(operation, null));
return operation;
}
Aggregations