Search in sources :

Example 1 with LaunchFinishForcedEvent

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.");
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) LaunchFinishForcedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishForcedEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) LaunchFinishedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent) Launch(com.epam.ta.reportportal.entity.launch.Launch) Date(java.util.Date) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

LaunchFinishForcedEvent (com.epam.ta.reportportal.core.events.activity.LaunchFinishForcedEvent)1 LaunchFinishedEvent (com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 LaunchBuilder (com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)1 Date (java.util.Date)1