Search in sources :

Example 16 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.

the class AbstractLaunchMergeStrategy method createResultedLaunch.

/**
 * Create launch that will be the result of merge
 *
 * @param projectId       {@link Project#getId()}
 * @param userId          {@link ReportPortalUser#getUserId()}
 * @param mergeLaunchesRQ {@link MergeLaunchesRQ}
 * @param launches        {@link List} of the {@link Launch}
 * @return launch
 */
private Launch createResultedLaunch(Long projectId, Long userId, MergeLaunchesRQ mergeLaunchesRQ, List<Launch> launches) {
    Date startTime = ofNullable(mergeLaunchesRQ.getStartTime()).orElse(EntityUtils.TO_DATE.apply(launches.stream().min(Comparator.comparing(Launch::getStartTime)).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Invalid launches")).getStartTime()));
    Date endTime = ofNullable(mergeLaunchesRQ.getEndTime()).orElse(EntityUtils.TO_DATE.apply(launches.stream().max(Comparator.comparing(Launch::getEndTime)).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Invalid launches")).getEndTime()));
    expect(endTime, time -> !time.before(startTime)).verify(FINISH_TIME_EARLIER_THAN_START_TIME, TO_LOCAL_DATE_TIME.apply(endTime), startTime, projectId);
    StartLaunchRQ startRQ = new StartLaunchRQ();
    startRQ.setMode(ofNullable(mergeLaunchesRQ.getMode()).orElse(Mode.DEFAULT));
    startRQ.setDescription(ofNullable(mergeLaunchesRQ.getDescription()).orElse(launches.stream().map(Launch::getDescription).collect(joining("\n\n"))));
    startRQ.setName(ofNullable(mergeLaunchesRQ.getName()).orElse("Merged: " + launches.stream().map(Launch::getName).distinct().collect(joining(", "))));
    startRQ.setStartTime(startTime);
    Launch launch = new LaunchBuilder().addStartRQ(startRQ).addProject(projectId).addStatus(IN_PROGRESS.name()).addUserId(userId).addEndTime(endTime).get();
    launch.setHasRetries(launches.stream().anyMatch(Launch::isHasRetries));
    launchRepository.save(launch);
    launchRepository.refresh(launch);
    mergeAttributes(mergeLaunchesRQ.getAttributes(), launches, launch);
    return launch;
}
Also used : TestItemTypeEnum(com.epam.ta.reportportal.entity.enums.TestItemTypeEnum) java.util(java.util) TestItemUniqueIdGenerator(com.epam.ta.reportportal.core.item.identity.TestItemUniqueIdGenerator) Project(com.epam.ta.reportportal.entity.project.Project) TestItem(com.epam.ta.reportportal.entity.item.TestItem) TO_LOCAL_DATE_TIME(com.epam.ta.reportportal.commons.EntityUtils.TO_LOCAL_DATE_TIME) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) Supplier(java.util.function.Supplier) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) EntityUtils(com.epam.ta.reportportal.commons.EntityUtils) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder) LogRepository(com.epam.ta.reportportal.dao.LogRepository) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) MergeLaunchesRQ(com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) AttachmentRepository(com.epam.ta.reportportal.dao.AttachmentRepository) BusinessRule.expect(com.epam.ta.reportportal.commons.validation.BusinessRule.expect) Optional.ofNullable(java.util.Optional.ofNullable) IdentityUtil(com.epam.ta.reportportal.core.item.identity.IdentityUtil) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Collectors.joining(java.util.stream.Collectors.joining) Collectors.toList(java.util.stream.Collectors.toList) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) FINISH_TIME_EARLIER_THAN_START_TIME(com.epam.ta.reportportal.ws.model.ErrorType.FINISH_TIME_EARLIER_THAN_START_TIME) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) FROM_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.ItemAttributeConverter.FROM_RESOURCE) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) IN_PROGRESS(com.epam.ta.reportportal.entity.enums.StatusEnum.IN_PROGRESS) LaunchMergeStrategy(com.epam.ta.reportportal.core.item.merge.LaunchMergeStrategy) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder)

Example 17 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.

the class AbstractImportStrategy method startLaunch.

protected String startLaunch(ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, String launchName) {
    StartLaunchRQ startLaunchRQ = new StartLaunchRQ();
    startLaunchRQ.setStartTime(initialStartTime);
    startLaunchRQ.setName(launchName);
    startLaunchRQ.setMode(Mode.DEFAULT);
    return startLaunchHandler.startLaunch(user, projectDetails, startLaunchRQ).getId();
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)

Example 18 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project agent-java-junit5 by reportportal.

the class ReportPortalExtension method buildStartLaunchRq.

/**
 * Extension point to customize launch creation event/request
 *
 * @param parameters Launch Configuration parameters
 * @return Request to ReportPortal
 */
protected StartLaunchRQ buildStartLaunchRq(ListenerParameters parameters) {
    StartLaunchRQ rq = new StartLaunchRQ();
    rq.setMode(parameters.getLaunchRunningMode());
    rq.setDescription(parameters.getDescription());
    rq.setName(parameters.getLaunchName());
    Set<ItemAttributesRQ> attributes = new HashSet<>(parameters.getAttributes());
    attributes.addAll(collectSystemAttributes(parameters.getSkippedAnIssue()));
    rq.setAttributes(attributes);
    rq.setStartTime(Calendar.getInstance().getTime());
    rq.setRerun(parameters.isRerun());
    rq.setRerunOf(StringUtils.isEmpty(parameters.getRerunOf()) ? null : parameters.getRerunOf());
    return rq;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)

Example 19 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project agent-java-soapui by reportportal.

the class StepBasedSoapUIServiceImpl method startLaunch.

public void startLaunch() {
    StartLaunchRQ rq = new StartLaunchRQ();
    rq.setName(this.parameters.getLaunchName());
    rq.setStartTime(Calendar.getInstance().getTime());
    rq.setTags(parameters.getTags());
    rq.setMode(parameters.getLaunchRunningMode());
    rq.setDescription(parameters.getDescription());
    this.reportPortal = ReportPortal.builder().withParameters(parameters).build();
    this.launch = reportPortal.newLaunch(rq);
    context.setLaunchFailed(false);
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)

Example 20 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project seleniumRobot by bhecquet.

the class ReportPortalService method buildStartLaunch.

private static StartLaunchRQ buildStartLaunch(ListenerParameters parameters) {
    StartLaunchRQ rq = new StartLaunchRQ();
    rq.setName(parameters.getLaunchName());
    rq.setStartTime(Calendar.getInstance().getTime());
    rq.setAttributes(parameters.getAttributes());
    rq.setMode(parameters.getLaunchRunningMode());
    if (!Strings.isNullOrEmpty(parameters.getDescription())) {
        rq.setDescription(parameters.getDescription());
    }
    return rq;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)

Aggregations

StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)35 Test (org.junit.jupiter.api.Test)20 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)10 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)9 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)7 Launch (com.epam.ta.reportportal.entity.launch.Launch)7 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)6 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)5 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)4 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 LaunchBuilder (com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder)3 Date (java.util.Date)3 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)3 ReportPortal (com.epam.reportportal.service.ReportPortal)2 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)2 IdentityUtil (com.epam.ta.reportportal.core.item.identity.IdentityUtil)2 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)2 TestItem (com.epam.ta.reportportal.entity.item.TestItem)2 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)2