use of com.epam.ta.reportportal.core.events.activity.LaunchFinishForcedEvent in project service-api by reportportal.
the class StopLaunchHandlerImpl method stopLaunch.
@Override
public OperationCompletionRS stopLaunch(Long launchId, FinishExecutionRQ finishLaunchRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
Launch launch = launchRepository.findById(launchId).orElseThrow(() -> new ReportPortalException(ErrorType.LAUNCH_NOT_FOUND, launchId));
validateRoles(launch, user, projectDetails);
validate(launch, finishLaunchRQ);
launch = new LaunchBuilder(launch).addDescription(ofNullable(finishLaunchRQ.getDescription()).orElse(ofNullable(launch.getDescription()).orElse("")).concat(LAUNCH_STOP_DESCRIPTION)).addStatus(ofNullable(finishLaunchRQ.getStatus()).orElse(STOPPED.name())).addEndTime(ofNullable(finishLaunchRQ.getEndTime()).orElse(new Date())).addAttributes(finishLaunchRQ.getAttributes()).addAttribute(new ItemAttributeResource("status", "stopped")).get();
launchRepository.save(launch);
testItemRepository.interruptInProgressItems(launch.getId());
messageBus.publishActivity(new LaunchFinishForcedEvent(TO_ACTIVITY_RESOURCE.apply(launch), user.getUserId(), user.getUsername()));
eventPublisher.publishEvent(new LaunchFinishedEvent(TO_ACTIVITY_RESOURCE.apply(launch), user.getUserId(), user.getUsername()));
return new OperationCompletionRS("Launch with ID = '" + launchId + "' successfully stopped.");
}
Aggregations