use of com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder in project service-api by reportportal.
the class FinishLaunchHandlerImpl method finishLaunch.
@Override
public FinishLaunchRS finishLaunch(String launchId, FinishExecutionRQ finishLaunchRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, String baseUrl) {
Launch launch = launchRepository.findByUuid(launchId).orElseThrow(() -> new ReportPortalException(LAUNCH_NOT_FOUND, launchId));
validateRoles(launch, user, projectDetails);
validate(launch, finishLaunchRQ);
Optional<StatusEnum> status = StatusEnum.fromValue(finishLaunchRQ.getStatus());
Long id = launch.getId();
final int finishedCount = finishHierarchyHandler.finishDescendants(launch, status.orElse(StatusEnum.INTERRUPTED), finishLaunchRQ.getEndTime(), user, projectDetails);
if (finishedCount > 0) {
launch.setStatus(launchRepository.hasRootItemsWithStatusNotEqual(id, StatusEnum.PASSED.name(), StatusEnum.INFO.name(), StatusEnum.WARN.name()) ? FAILED : PASSED);
} else {
launch.setStatus(status.orElseGet(() -> launchRepository.hasRootItemsWithStatusNotEqual(id, StatusEnum.PASSED.name(), StatusEnum.INFO.name(), StatusEnum.WARN.name()) ? FAILED : PASSED));
}
launch = new LaunchBuilder(launch).addDescription(buildDescription(launch.getDescription(), finishLaunchRQ.getDescription())).addAttributes(finishLaunchRQ.getAttributes()).addEndTime(finishLaunchRQ.getEndTime()).get();
LaunchFinishedEvent event = new LaunchFinishedEvent(TO_ACTIVITY_RESOURCE.apply(launch), user, baseUrl);
messageBus.publishActivity(event);
eventPublisher.publishEvent(event);
FinishLaunchRS response = new FinishLaunchRS();
response.setId(launch.getUuid());
response.setNumber(launch.getNumber());
response.setLink(generateLaunchLink(baseUrl, projectDetails.getProjectName(), String.valueOf(launch.getId())));
return response;
}
use of com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder in project service-api by reportportal.
the class DemoDataLaunchService method finishLaunch.
@Transactional
public void finishLaunch(String launchId) {
Launch launch = launchRepository.findByUuid(launchId).orElseThrow(() -> new ReportPortalException(LAUNCH_NOT_FOUND, launchId));
if (testItemRepository.hasItemsInStatusByLaunch(launch.getId(), StatusEnum.IN_PROGRESS)) {
testItemRepository.interruptInProgressItems(launch.getId());
}
launch = new LaunchBuilder(launch).addEndTime(new Date()).get();
StatusEnum fromStatisticsStatus = PASSED;
if (launchRepository.hasRootItemsWithStatusNotEqual(launch.getId(), StatusEnum.PASSED.name(), StatusEnum.INFO.name(), StatusEnum.WARN.name())) {
fromStatisticsStatus = StatusEnum.FAILED;
}
launch.setStatus(fromStatisticsStatus);
launchRepository.save(launch);
}
Aggregations