Search in sources :

Example 6 with ItemType

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

the class ReportPortalExtension method buildStartStepRq.

/**
 * Extension point to customize test step creation event/request
 *
 * @param context     JUnit's test context
 * @param arguments   a test arguments list
 * @param itemType    a test method item type
 * @param description a test method description
 * @param startTime   a start time of the test
 * @return Request to ReportPortal
 */
@Nonnull
protected StartTestItemRQ buildStartStepRq(@Nonnull final ExtensionContext context, @Nonnull final List<Object> arguments, @Nonnull final ItemType itemType, @Nonnull final String description, @Nonnull final Date startTime) {
    StartTestItemRQ rq = new StartTestItemRQ();
    rq.setStartTime(startTime);
    rq.setName(createStepName(context));
    rq.setDescription(description);
    rq.setUniqueId(context.getUniqueId());
    rq.setType(itemType == TEMPLATE ? SUITE.name() : itemType.name());
    String codeRef = getCodeRef(context);
    rq.setCodeRef(codeRef);
    rq.setAttributes(context.getTags().stream().map(it -> new ItemAttributesRQ(null, it)).collect(Collectors.toSet()));
    if (SUITE == itemType) {
        context.getTestClass().ifPresent(c -> rq.getAttributes().addAll(getAttributes(c)));
    }
    Optional<Method> testMethod = getTestMethod(context);
    TestCaseIdEntry caseId = testMethod.map(m -> {
        rq.getAttributes().addAll(getAttributes(m));
        rq.setParameters(getParameters(m, arguments));
        return getTestCaseId(m, codeRef, arguments, context.getTestInstance().orElse(null));
    }).orElseGet(() -> TestCaseIdUtils.getTestCaseId(codeRef, arguments));
    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) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Method(java.lang.reflect.Method) TestCaseIdEntry(com.epam.reportportal.service.item.TestCaseIdEntry) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)5 ParameterKey (com.epam.reportportal.annotations.ParameterKey)4 TestCaseId (com.epam.reportportal.annotations.TestCaseId)4 Attributes (com.epam.reportportal.annotations.attribute.Attributes)4 ItemType (com.epam.reportportal.junit5.ItemType)4 SystemAttributesFetcher.collectSystemAttributes (com.epam.reportportal.junit5.SystemAttributesFetcher.collectSystemAttributes)4 ItemTreeUtils.createItemTreeKey (com.epam.reportportal.junit5.utils.ItemTreeUtils.createItemTreeKey)4 ItemStatus (com.epam.reportportal.listeners.ItemStatus)4 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)4 Launch (com.epam.reportportal.service.Launch)4 ReportPortal (com.epam.reportportal.service.ReportPortal)4 TestCaseIdEntry (com.epam.reportportal.service.item.TestCaseIdEntry)4 TestItemTree (com.epam.reportportal.service.tree.TestItemTree)4 TestItemTree.createTestItemLeaf (com.epam.reportportal.service.tree.TestItemTree.createTestItemLeaf)4 AttributeParser (com.epam.reportportal.utils.AttributeParser)4 ParameterUtils (com.epam.reportportal.utils.ParameterUtils)4 TestCaseIdUtils (com.epam.reportportal.utils.TestCaseIdUtils)4 com.epam.ta.reportportal.ws.model (com.epam.ta.reportportal.ws.model)4 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)4 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4