use of com.epam.reportportal.service.ReportPortalClient in project agent-java-testNG by reportportal.
the class CallbackReportingIntegrationTest method initMocks.
@BeforeEach
@SuppressWarnings("unchecked")
public void initMocks() {
ReportPortalClient reportPortalClient = mock(ReportPortalClient.class);
when(reportPortalClient.startLaunch(any())).thenReturn(Maybe.just(new StartLaunchRS("launchUuid", 1L)));
Maybe<ItemCreatedRS> suiteMaybe = Maybe.just(new ItemCreatedRS(suitedUuid, suitedUuid));
when(reportPortalClient.startTestItem(any())).thenReturn(suiteMaybe);
Maybe<ItemCreatedRS> testClassMaybe = Maybe.just(new ItemCreatedRS(testClassUuid, testClassUuid));
when(reportPortalClient.startTestItem(eq(suiteMaybe.blockingGet().getId()), any())).thenReturn(testClassMaybe);
Maybe<ItemCreatedRS> testMethodMaybe = Maybe.just(new ItemCreatedRS(testMethodUuid, testMethodUuid));
when(reportPortalClient.startTestItem(eq(testClassMaybe.blockingGet().getId()), any())).thenReturn(testMethodMaybe);
Maybe<OperationCompletionRS> finishResponse = Maybe.just(new OperationCompletionRS("finished"));
when(reportPortalClient.finishTestItem(eq(testMethodUuid), any())).thenReturn(finishResponse);
when(reportPortalClient.log(any(List.class))).thenReturn(Maybe.just(new BatchSaveOperatingRS()));
when(reportPortalClient.log(any(SaveLogRQ.class))).thenReturn(Maybe.just(new EntryCreatedAsyncRS("logId")));
ListenerParameters params = standardParameters();
params.setCallbackReportingEnabled(true);
final ReportPortal reportPortal = ReportPortal.create(reportPortalClient, params);
CallbackReportingListener.initReportPortal(reportPortal);
}
use of com.epam.reportportal.service.ReportPortalClient in project agent-java-testNG by reportportal.
the class TestUtils method mockNestedSteps.
@SuppressWarnings("unchecked")
public static void mockNestedSteps(final ReportPortalClient client, final List<Pair<String, String>> parentNestedPairs) {
Map<String, List<String>> responseOrders = parentNestedPairs.stream().collect(Collectors.groupingBy(Pair::getKey, Collectors.mapping(Pair::getValue, Collectors.toList())));
responseOrders.forEach((k, v) -> {
List<Maybe<ItemCreatedRS>> responses = v.stream().map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
Maybe<ItemCreatedRS> first = responses.get(0);
Maybe<ItemCreatedRS>[] other = responses.subList(1, responses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(k), any())).thenReturn(first, other);
});
parentNestedPairs.forEach(p -> when(client.finishTestItem(same(p.getValue()), any())).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> Maybe.just(new OperationCompletionRS())));
}
use of com.epam.reportportal.service.ReportPortalClient in project agent-java-testNG by reportportal.
the class TestUtils method mockLaunch.
@SuppressWarnings("unchecked")
public static void mockLaunch(ReportPortalClient client, String launchUuid, String suiteUuid, String testClassUuid, Collection<String> testMethodUuidList) {
when(client.startLaunch(any())).thenReturn(Maybe.just(new StartLaunchRS(launchUuid, 1L)));
Maybe<ItemCreatedRS> suiteMaybe = Maybe.just(new ItemCreatedRS(suiteUuid, suiteUuid));
when(client.startTestItem(any())).thenReturn(suiteMaybe);
Maybe<ItemCreatedRS> testClassMaybe = Maybe.just(new ItemCreatedRS(testClassUuid, testClassUuid));
when(client.startTestItem(eq(suiteUuid), any())).thenReturn(testClassMaybe);
List<Maybe<ItemCreatedRS>> responses = testMethodUuidList.stream().map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
Maybe<ItemCreatedRS> first = responses.get(0);
Maybe<ItemCreatedRS>[] other = responses.subList(1, responses.size()).toArray(new Maybe[0]);
when(client.startTestItem(eq(testClassUuid), any())).thenReturn(first, other);
new HashSet<>(testMethodUuidList).forEach(testMethodUuid -> when(client.finishTestItem(eq(testMethodUuid), any())).thenReturn(Maybe.just(new OperationCompletionRS())));
Maybe<OperationCompletionRS> testClassFinishMaybe = Maybe.just(new OperationCompletionRS());
when(client.finishTestItem(eq(testClassUuid), any())).thenReturn(testClassFinishMaybe);
Maybe<OperationCompletionRS> suiteFinishMaybe = Maybe.just(new OperationCompletionRS());
when(client.finishTestItem(eq(suiteUuid), any())).thenReturn(suiteFinishMaybe);
when(client.finishLaunch(eq(launchUuid), any())).thenReturn(Maybe.just(new OperationCompletionRS()));
}
use of com.epam.reportportal.service.ReportPortalClient in project examples-java by reportportal.
the class CallbackTest method afterClass.
@AfterClass
public static void afterClass() {
ReportPortalClient client = ReportPortalListener.getReportPortal().getClient();
TestItemTree itemTree = ParallelRunningContext.getCurrent().getItemTree();
attachLog(client, itemTree);
changeStatus(client, itemTree);
}
use of com.epam.reportportal.service.ReportPortalClient in project agent-java-junit5 by reportportal.
the class TestUtils method mockNestedSteps.
@SuppressWarnings("unchecked")
public static void mockNestedSteps(final ReportPortalClient client, final List<Pair<String, String>> parentNestedPairs) {
Map<String, List<String>> responseOrders = parentNestedPairs.stream().collect(Collectors.groupingBy(Pair::getKey, Collectors.mapping(Pair::getValue, Collectors.toList())));
responseOrders.forEach((k, v) -> {
List<Maybe<ItemCreatedRS>> responses = v.stream().map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
Maybe<ItemCreatedRS> first = responses.get(0);
Maybe<ItemCreatedRS>[] other = responses.subList(1, responses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(k), any())).thenReturn(first, other);
});
parentNestedPairs.forEach(p -> when(client.finishTestItem(same(p.getValue()), any())).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> Maybe.just(new OperationCompletionRS())));
}
Aggregations