Search in sources :

Example 1 with Launch

use of com.epam.reportportal.service.Launch in project agent-java-testNG by reportportal.

the class TestNGService method startTest.

@Override
public void startTest(ITestContext testContext) {
    if (hasMethodsToRun(testContext)) {
        StartTestItemRQ rq = buildStartTestItemRq(testContext);
        Launch myLaunch = launch.get();
        final Maybe<String> testID = myLaunch.startTestItem(this.getAttribute(testContext.getSuite(), RP_ID), rq);
        if (myLaunch.getParameters().isCallbackReportingEnabled()) {
            addToTree(testContext, testID);
        }
        testContext.setAttribute(RP_ID, testID);
    }
}
Also used : Launch(com.epam.reportportal.service.Launch)

Example 2 with Launch

use of com.epam.reportportal.service.Launch in project agent-java-testNG by reportportal.

the class TestNGService method startTestMethod.

@Override
public void startTestMethod(@Nonnull ITestResult testResult) {
    StartTestItemRQ rq = buildStartStepRq(testResult);
    if (Boolean.TRUE == rq.isRetry()) {
        testResult.setAttribute(RP_RETRY, Boolean.TRUE);
    }
    Launch myLaunch = launch.get();
    Maybe<String> stepMaybe = myLaunch.startTestItem(getAttribute(testResult.getTestContext(), RP_ID), rq);
    testResult.setAttribute(RP_ID, stepMaybe);
    if (myLaunch.getParameters().isCallbackReportingEnabled()) {
        addToTree(testResult, stepMaybe);
    }
}
Also used : Launch(com.epam.reportportal.service.Launch)

Example 3 with Launch

use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.

the class TestUtils method getBasicMockedLaunch.

public static Launch getBasicMockedLaunch() {
    Launch result = mock(Launch.class);
    when(result.startTestItem(any())).thenAnswer((Answer<Maybe<String>>) invocation -> createMaybeUuid());
    when(result.startTestItem(any(), any())).thenAnswer((Answer<Maybe<String>>) invocation -> createMaybeUuid());
    return result;
}
Also used : java.util(java.util) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) ArgumentMatchers(org.mockito.ArgumentMatchers) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Launch(com.epam.reportportal.service.Launch) Maybe(io.reactivex.Maybe) Answer(org.mockito.stubbing.Answer) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) BatchSaveOperatingRS(com.epam.ta.reportportal.ws.model.BatchSaveOperatingRS) ArgumentCaptor(org.mockito.ArgumentCaptor) Pair(org.apache.commons.lang3.tuple.Pair) LauncherFactory(org.junit.platform.launcher.core.LauncherFactory) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) DiscoverySelectors(org.junit.platform.engine.discovery.DiscoverySelectors) CommonUtils.createMaybeUuid(com.epam.reportportal.util.test.CommonUtils.createMaybeUuid) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) CommonUtils(com.epam.reportportal.util.test.CommonUtils) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) LauncherConfig(org.junit.platform.launcher.core.LauncherConfig) Stream(java.util.stream.Stream) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) LauncherDiscoveryRequestBuilder(org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) Mockito.mock(org.mockito.Mockito.mock) Maybe(io.reactivex.Maybe) Launch(com.epam.reportportal.service.Launch)

Example 4 with Launch

use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.

the class ReportPortalExtension method finishTestItem.

/**
 * Finishes a test item in RP with a custom request
 *
 * @param context JUnit's test context
 * @param rq      a test item finish request
 */
protected void finishTestItem(@Nonnull final ExtensionContext context, @Nonnull final FinishTestItemRQ rq) {
    Launch launch = getLaunch(context);
    Maybe<String> id = idMapping.remove(context);
    Maybe<OperationCompletionRS> finishResponse = launch.finishTestItem(id, rq);
    if (getReporter().getParameters().isCallbackReportingEnabled()) {
        ofNullable(TEST_ITEM_TREE.getTestItems().get(createItemTreeKey(context))).ifPresent(itemLeaf -> itemLeaf.setFinishResponse(finishResponse));
    }
}
Also used : Launch(com.epam.reportportal.service.Launch)

Example 5 with Launch

use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.

the class ReportPortalExtension method startTestItem.

/**
 * Starts a test item of arbitrary type
 *
 * @param context     JUnit's test context
 * @param arguments   a list of test parameters
 * @param itemType    a type of the item
 * @param description the test description
 * @param startTime   the test start time
 */
protected void startTestItem(@Nonnull final ExtensionContext context, @Nonnull final List<Object> arguments, @Nonnull final ItemType itemType, @Nonnull final String description, @Nonnull final Date startTime) {
    idMapping.computeIfAbsent(context, c -> {
        StartTestItemRQ rq = buildStartStepRq(c, arguments, itemType, description, startTime);
        Launch launch = getLaunch(c);
        Maybe<String> itemId = c.getParent().flatMap(parent -> Optional.ofNullable(idMapping.get(parent))).map(parentTest -> {
            Maybe<String> item = launch.startTestItem(parentTest, rq);
            if (getReporter().getParameters().isCallbackReportingEnabled()) {
                TEST_ITEM_TREE.getTestItems().put(createItemTreeKey(rq.getName()), createTestItemLeaf(parentTest, item));
            }
            return item;
        }).orElseGet(() -> {
            Maybe<String> item = launch.startTestItem(rq);
            if (getReporter().getParameters().isCallbackReportingEnabled()) {
                TEST_ITEM_TREE.getTestItems().put(createItemTreeKey(rq.getName()), createTestItemLeaf(item));
            }
            return item;
        });
        if (TEMPLATE == itemType) {
            testTemplates.put(c, itemId);
        }
        return itemId;
    });
}
Also used : java.util(java.util) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Launch(com.epam.reportportal.service.Launch) com.epam.ta.reportportal.ws.model(com.epam.ta.reportportal.ws.model) Maybe(io.reactivex.Maybe) LoggerFactory(org.slf4j.LoggerFactory) ReportPortal(com.epam.reportportal.service.ReportPortal) AttributeParser(com.epam.reportportal.utils.AttributeParser) TestCaseId(com.epam.reportportal.annotations.TestCaseId) TestItemTree(com.epam.reportportal.service.tree.TestItemTree) StringUtils(org.apache.commons.lang3.StringUtils) TestCaseIdEntry(com.epam.reportportal.service.item.TestCaseIdEntry) SystemAttributesFetcher.collectSystemAttributes(com.epam.reportportal.junit5.SystemAttributesFetcher.collectSystemAttributes) Attributes(com.epam.reportportal.annotations.attribute.Attributes) TestCaseIdUtils(com.epam.reportportal.utils.TestCaseIdUtils) Nonnull(javax.annotation.Nonnull) Method(java.lang.reflect.Method) Nullable(javax.annotation.Nullable) ParameterUtils(com.epam.reportportal.utils.ParameterUtils) TestItemTree.createTestItemLeaf(com.epam.reportportal.service.tree.TestItemTree.createTestItemLeaf) Logger(org.slf4j.Logger) Optional.ofNullable(java.util.Optional.ofNullable) TestAbortedException(org.opentest4j.TestAbortedException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ExceptionUtils.getStackTrace(org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace) ItemStatus(com.epam.reportportal.listeners.ItemStatus) SaveLogRQ(com.epam.ta.reportportal.ws.model.log.SaveLogRQ) ParameterKey(com.epam.reportportal.annotations.ParameterKey) Collectors(java.util.stream.Collectors) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) org.junit.jupiter.api(org.junit.jupiter.api) ItemType(com.epam.reportportal.junit5.ItemType) org.junit.jupiter.api.extension(org.junit.jupiter.api.extension) ItemTreeUtils.createItemTreeKey(com.epam.reportportal.junit5.utils.ItemTreeUtils.createItemTreeKey) AnnotatedElement(java.lang.reflect.AnnotatedElement) Maybe(io.reactivex.Maybe) Launch(com.epam.reportportal.service.Launch)

Aggregations

Launch (com.epam.reportportal.service.Launch)33 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)22 Test (org.junit.jupiter.api.Test)18 Maybe (io.reactivex.Maybe)9 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)8 SingleTest (com.epam.reportportal.junit5.features.coderef.SingleTest)5 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)5 Collectors (java.util.stream.Collectors)5 CommonUtils (com.epam.reportportal.util.test.CommonUtils)4 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)4 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4 OneDisabledOneEnabledTest (com.epam.reportportal.junit5.features.disabled.OneDisabledOneEnabledTest)3 OneDisabledTest (com.epam.reportportal.junit5.features.disabled.OneDisabledTest)3 JunitDynamicNestedTest (com.epam.reportportal.junit5.features.nested.JunitDynamicNestedTest)3 AssumptionFailedTest (com.epam.reportportal.junit5.features.skipped.AssumptionFailedTest)3 BeforeEachAssumptionFailedTest (com.epam.reportportal.junit5.features.skipped.BeforeEachAssumptionFailedTest)3 ItemStatus (com.epam.reportportal.listeners.ItemStatus)3 ReportPortal (com.epam.reportportal.service.ReportPortal)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3 Answer (org.mockito.stubbing.Answer)3