Search in sources :

Example 1 with StartLaunchRQ

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

the class TestNGService 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.setName(parameters.getLaunchName());
    rq.setStartTime(Calendar.getInstance().getTime());
    Set<ItemAttributesRQ> attributes = new HashSet<>(parameters.getAttributes());
    rq.setAttributes(attributes);
    rq.setMode(parameters.getLaunchRunningMode());
    rq.setRerun(parameters.isRerun());
    if (isNotBlank(parameters.getRerunOf())) {
        rq.setRerunOf(parameters.getRerunOf());
    }
    if (isNotBlank(parameters.getDescription())) {
        rq.setDescription(parameters.getDescription());
    }
    if (null != parameters.getSkippedAnIssue()) {
        ItemAttributesRQ skippedIssueAttribute = new ItemAttributesRQ();
        skippedIssueAttribute.setKey(SKIPPED_ISSUE_KEY);
        skippedIssueAttribute.setValue(parameters.getSkippedAnIssue().toString());
        skippedIssueAttribute.setSystem(true);
        attributes.add(skippedIssueAttribute);
    }
    attributes.addAll(SystemAttributesExtractor.extract(AGENT_PROPERTIES_FILE, TestNGService.class.getClassLoader()));
    return rq;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)

Example 2 with StartLaunchRQ

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

the class BuildTestTest method testSkippedIssue.

@Test
public void testSkippedIssue() {
    ItemAttributesRQ itemAttributeResource = new ItemAttributesRQ();
    itemAttributeResource.setKey(SKIPPED_ISSUE_KEY);
    itemAttributeResource.setValue(String.valueOf(true));
    itemAttributeResource.setSystem(true);
    ListenerParameters parameters = new ListenerParameters();
    parameters.setSkippedAnIssue(true);
    parameters.setAttributes(new HashSet<>());
    StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(parameters);
    assertTrue(startLaunchRQ.getAttributes().contains(itemAttributeResource));
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Test(org.junit.jupiter.api.Test)

Example 3 with StartLaunchRQ

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

the class BuildTestTest method testStartLaunchRq_NullDescription.

@Test
public void testStartLaunchRq_NullDescription() {
    ListenerParameters parameters = new ListenerParameters();
    StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(parameters);
    assertThat("Description should be null", startLaunchRQ.getDescription(), nullValue());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Test(org.junit.jupiter.api.Test)

Example 4 with StartLaunchRQ

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

the class BuildTestTest method testPredefinedAttributes.

@Test
public void testPredefinedAttributes() {
    final ListenerParameters parameters = new ListenerParameters();
    parameters.setSkippedAnIssue(null);
    StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(parameters);
    assertThat(startLaunchRQ.getAttributes().size(), Matchers.is(3));
    Set<String> keys = startLaunchRQ.getAttributes().stream().map(ItemAttributeResource::getKey).collect(toSet());
    predefinedProperties.forEach((predefinedKey, predefinedValue) -> assertTrue(keys.contains(predefinedKey)));
    startLaunchRQ.getAttributes().forEach(attribute -> {
        assertThat(attribute.getValue(), matchesPattern(predefinedProperties.get(attribute.getKey())));
        assertTrue(attribute.isSystem());
    });
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Test(org.junit.jupiter.api.Test)

Example 5 with StartLaunchRQ

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

the class StartLaunchHandlerImpl method startLaunch.

@Override
@Transactional
public StartLaunchRS startLaunch(ReportPortalUser user, ReportPortalUser.ProjectDetails projectDetails, StartLaunchRQ request) {
    validateRoles(projectDetails, request);
    final Launch savedLaunch = Optional.of(request.isRerun()).filter(Boolean::booleanValue).map(rerun -> rerunHandler.handleLaunch(request, projectDetails.getProjectId(), user)).orElseGet(() -> {
        Launch launch = new LaunchBuilder().addStartRQ(request).addAttributes(request.getAttributes()).addProject(projectDetails.getProjectId()).addUserId(user.getUserId()).get();
        launchRepository.save(launch);
        launchRepository.refresh(launch);
        return launch;
    });
    eventPublisher.publishEvent(new StartLaunchEvent(savedLaunch.getId()));
    messageBus.publishActivity(new LaunchStartedEvent(TO_ACTIVITY_RESOURCE.apply(savedLaunch), user.getUserId(), user.getUsername()));
    StartLaunchRS response = new StartLaunchRS();
    response.setId(savedLaunch.getUuid());
    response.setNumber(savedLaunch.getNumber());
    return response;
}
Also used : Primary(org.springframework.context.annotation.Primary) Launch(com.epam.ta.reportportal.entity.launch.Launch) Autowired(org.springframework.beans.factory.annotation.Autowired) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) StartLaunchEvent(com.epam.reportportal.extension.event.StartLaunchEvent) RerunHandler(com.epam.ta.reportportal.core.launch.rerun.RerunHandler) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) LaunchStartedEvent(com.epam.ta.reportportal.core.events.activity.LaunchStartedEvent) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) Service(org.springframework.stereotype.Service) TO_ACTIVITY_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.LaunchConverter.TO_ACTIVITY_RESOURCE) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) Optional(java.util.Optional) StartLaunchHandler(com.epam.ta.reportportal.core.launch.StartLaunchHandler) Transactional(org.springframework.transaction.annotation.Transactional) LaunchStartedEvent(com.epam.ta.reportportal.core.events.activity.LaunchStartedEvent) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) StartLaunchEvent(com.epam.reportportal.extension.event.StartLaunchEvent) Launch(com.epam.ta.reportportal.entity.launch.Launch) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder) Transactional(org.springframework.transaction.annotation.Transactional)

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