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);
}
}
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);
}
}
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;
}
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));
}
}
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;
});
}
Aggregations