Search in sources :

Example 6 with ReportPortal

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

the class ReportPortalExtension method buildStartConfigurationRq.

/**
 * Extension point to customize beforeXXX creation event/request
 *
 * @param method        JUnit's test method reference
 * @param parentContext JUnit's context of a parent item
 * @param context       JUnit's test context
 * @param itemType      a type of the item to build
 * @return Request to ReportPortal
 */
@Nonnull
protected StartTestItemRQ buildStartConfigurationRq(@Nonnull Method method, @Nonnull ExtensionContext parentContext, @Nonnull ExtensionContext context, @Nonnull ItemType itemType) {
    StartTestItemRQ rq = new StartTestItemRQ();
    rq.setStartTime(Calendar.getInstance().getTime());
    Optional<Class<?>> testClass = context.getTestClass();
    if (testClass.isPresent()) {
        rq.setName(createConfigurationName(testClass.get(), method));
        rq.setDescription(createConfigurationDescription(testClass.get(), method));
    } else {
        rq.setName(createConfigurationName(method.getDeclaringClass(), method));
        rq.setDescription(createConfigurationDescription(method.getDeclaringClass(), method));
    }
    String uniqueId = parentContext.getUniqueId() + "/[method:" + method.getName() + "()]";
    rq.setUniqueId(uniqueId);
    ofNullable(context.getTags()).ifPresent(it -> rq.setAttributes(it.stream().map(tag -> new ItemAttributesRQ(null, tag)).collect(Collectors.toSet())));
    rq.setType(itemType.name());
    rq.setRetry(false);
    String codeRef = method.getDeclaringClass().getCanonicalName() + "." + method.getName();
    rq.setCodeRef(codeRef);
    TestCaseIdEntry caseId = ofNullable(method.getAnnotation(TestCaseId.class)).map(TestCaseId::value).map(TestCaseIdEntry::new).orElseGet(() -> TestCaseIdUtils.getTestCaseId(codeRef, Collections.emptyList()));
    rq.setTestCaseId(ofNullable(caseId).map(TestCaseIdEntry::getId).orElse(null));
    return rq;
}
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) TestCaseId(com.epam.reportportal.annotations.TestCaseId) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) TestCaseIdEntry(com.epam.reportportal.service.item.TestCaseIdEntry) Nonnull(javax.annotation.Nonnull)

Example 7 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project allure-java by reportportal.

the class LinkAnnotationTest method initMocks.

@BeforeEach
public void initMocks() {
    ReportPortal reportPortal = ReportPortal.create(client, standardParameters());
    TestNgListener.REPORT_PORTAL_THREAD_LOCAL.set(reportPortal);
}
Also used : ReportPortal(com.epam.reportportal.service.ReportPortal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project allure-java by reportportal.

the class MethodNestedStepsTest method initMocks.

@BeforeEach
public void initMocks() {
    mockLaunch(client, namedUuid("launchUuid"), suitedUuid, testUuid, stepUuid);
    ReportPortal reportPortal = ReportPortal.create(client, standardParameters());
    mockLogging(client);
    TestNgListener.REPORT_PORTAL_THREAD_LOCAL.set(reportPortal);
}
Also used : ReportPortal(com.epam.reportportal.service.ReportPortal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project allure-java by reportportal.

the class MutedAnnotationTest method initMocks.

@BeforeEach
public void initMocks() {
    mockLaunch(client, namedUuid("launchUuid"), suitedUuid, testClassUuid, stepUuids);
    ReportPortal reportPortal = ReportPortal.create(client, standardParameters());
    TestNgListener.REPORT_PORTAL_THREAD_LOCAL.set(reportPortal);
}
Also used : ReportPortal(com.epam.reportportal.service.ReportPortal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with ReportPortal

use of com.epam.reportportal.service.ReportPortal in project allure-java by reportportal.

the class RuntimeUpdatesTest method initMocks.

@BeforeEach
public void initMocks() {
    mockLaunch(client, namedUuid("launchUuid"), suitedUuid, testClassUuid, stepUuid);
    ReportPortal reportPortal = ReportPortal.create(client, standardParameters());
    TestNgListener.REPORT_PORTAL_THREAD_LOCAL.set(reportPortal);
}
Also used : ReportPortal(com.epam.reportportal.service.ReportPortal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ReportPortal (com.epam.reportportal.service.ReportPortal)24 BeforeEach (org.junit.jupiter.api.BeforeEach)17 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)7 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4 SaveLogRQ (com.epam.ta.reportportal.ws.model.log.SaveLogRQ)4 Launch (com.epam.reportportal.service.Launch)3 ParameterKey (com.epam.reportportal.annotations.ParameterKey)2 TestCaseId (com.epam.reportportal.annotations.TestCaseId)2 Attributes (com.epam.reportportal.annotations.attribute.Attributes)2 ItemType (com.epam.reportportal.junit5.ItemType)2 SystemAttributesFetcher.collectSystemAttributes (com.epam.reportportal.junit5.SystemAttributesFetcher.collectSystemAttributes)2 ItemTreeUtils.createItemTreeKey (com.epam.reportportal.junit5.utils.ItemTreeUtils.createItemTreeKey)2 ItemStatus (com.epam.reportportal.listeners.ItemStatus)2 TestCaseIdEntry (com.epam.reportportal.service.item.TestCaseIdEntry)2 TestItemTree (com.epam.reportportal.service.tree.TestItemTree)2 TestItemTree.createTestItemLeaf (com.epam.reportportal.service.tree.TestItemTree.createTestItemLeaf)2 AttributeParser (com.epam.reportportal.utils.AttributeParser)2 ParameterUtils (com.epam.reportportal.utils.ParameterUtils)2 TestCaseIdUtils (com.epam.reportportal.utils.TestCaseIdUtils)2 com.epam.ta.reportportal.ws.model (com.epam.ta.reportportal.ws.model)2