Search in sources :

Example 6 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project service-api by reportportal.

the class LaunchControllerValidationTest method prepareLaunch.

private StartLaunchRQ prepareLaunch() {
    StartLaunchRQ startLaunchRQ = new StartLaunchRQ();
    startLaunchRQ.setDescription("some description");
    startLaunchRQ.setStartTime(new Date());
    startLaunchRQ.setMode(DEFAULT);
    startLaunchRQ.setAttributes(Sets.newHashSet(new ItemAttributesRQ("key", "value")));
    return startLaunchRQ;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Date(java.util.Date)

Example 7 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project service-api by reportportal.

the class DemoDataLaunchService method startLaunch.

@Transactional
public Launch startLaunch(String name, User user, ReportPortalUser.ProjectDetails projectDetails) {
    StartLaunchRQ rq = new StartLaunchRQ();
    rq.setMode(Mode.DEFAULT);
    rq.setDescription(ContentUtils.getLaunchDescription());
    LocalDateTime now = LocalDateTime.now();
    rq.setName(name);
    rq.setStartTime(Date.from(now.atZone(ZoneId.systemDefault()).toInstant()));
    rq.setUuid(UUID.randomUUID().toString());
    Set<ItemAttributesRQ> attributes = Sets.newHashSet(new ItemAttributesRQ("platform", platformValues[new Random().nextInt(platformValues.length)]), new ItemAttributesRQ(null, "demo"), new ItemAttributesRQ("build", "3." + now.getDayOfMonth() + "." + now.getHour() + "." + now.getMinute() + "." + now.getSecond()));
    Launch launch = new LaunchBuilder().addStartRQ(rq).addAttributes(attributes).addProject(projectDetails.getProjectId()).get();
    launch.setUserId(user.getId());
    launchRepository.save(launch);
    launchRepository.refresh(launch);
    return launch;
}
Also used : LocalDateTime(java.time.LocalDateTime) Random(java.util.Random) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project examples-java by reportportal.

the class SaucelabsAttributeTest method addSaucelabsAttribute.

private static void addSaucelabsAttribute() {
    FinishTestItemRQ request = new FinishTestItemRQ();
    request.setEndTime(Calendar.getInstance().getTime());
    request.setStatus("PASSED");
    request.setAttributes(Sets.newHashSet(new ItemAttributesRQ("SLID", "0586c1c90fcd4a499591109692426d54")));
    ItemTreeReporter.finishItem(ReportPortalListener.getReportPortal().getClient(), request, ParallelRunningContext.getCurrent().getItemTree().getLaunchId(), testItemLeaves.get(0)).cache().ignoreElement().blockingAwait();
}
Also used : ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ)

Example 9 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project examples-java by reportportal.

the class SaucelabsAttributeTest method addSaucelabsAttribute.

private static void addSaucelabsAttribute(TestItemTree.TestItemLeaf leaf) {
    FinishTestItemRQ request = new FinishTestItemRQ();
    request.setStatus("passed");
    request.setEndTime(Calendar.getInstance().getTime());
    request.setAttributes(Sets.newHashSet(new ItemAttributesRQ("SLID", "0586c1c90fcd4a499591109692426d54")));
    ItemTreeReporter.finishItem(REPORT_PORTAL.getClient(), request, TEST_ITEM_TREE.getLaunchId(), leaf).cache().subscribe();
}
Also used : ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ)

Example 10 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ 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)

Aggregations

ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)33 Test (org.junit.jupiter.api.Test)19 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)13 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)11 Collectors (java.util.stream.Collectors)10 ReportPortal (com.epam.reportportal.service.ReportPortal)9 List (java.util.List)8 Set (java.util.Set)8 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)7 TestNgListener (com.epam.reportportal.testng.util.TestNgListener)7 TestUtils (com.epam.reportportal.testng.util.TestUtils)7 Collections (java.util.Collections)7 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)7 Matchers.hasSize (org.hamcrest.Matchers.hasSize)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 ArgumentCaptor (org.mockito.ArgumentCaptor)7 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)7 ArgumentMatchers.same (org.mockito.ArgumentMatchers.same)7 Mockito.mock (org.mockito.Mockito.mock)7 Mockito.verify (org.mockito.Mockito.verify)7