use of com.epam.reportportal.service.ReportPortalClient in project agent-java-junit5 by reportportal.
the class TestUtils method mockLaunch.
@SuppressWarnings("unchecked")
public static void mockLaunch(ReportPortalClient client, String launchUuid, String testClassUuid, Collection<String> testMethodUuidList) {
when(client.startLaunch(any())).thenReturn(Maybe.just(new StartLaunchRS(launchUuid, 1L)));
Maybe<ItemCreatedRS> testClassMaybe = Maybe.just(new ItemCreatedRS(testClassUuid, testClassUuid));
when(client.startTestItem(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);
when(client.finishLaunch(eq(launchUuid), any())).thenReturn(Maybe.just(new OperationCompletionRS()));
}
use of com.epam.reportportal.service.ReportPortalClient in project allure-java by reportportal.
the class BaseTest method mockScenario.
@SuppressWarnings("unchecked")
public static <T extends Collection<String>> void mockScenario(@Nonnull final ReportPortalClient client, @Nonnull final String storyUuid, @Nonnull final Collection<Pair<String, T>> testSteps) {
List<Maybe<ItemCreatedRS>> testResponses = testSteps.stream().map(Pair::getKey).map(uuid -> createMaybe(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
Maybe<ItemCreatedRS> first = testResponses.get(0);
Maybe<ItemCreatedRS>[] other = testResponses.subList(1, testResponses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(storyUuid), any())).thenReturn(first, other);
testSteps.forEach(test -> {
String testClassUuid = test.getKey();
List<Maybe<ItemCreatedRS>> stepResponses = test.getValue().stream().map(uuid -> createMaybe(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
when(client.finishTestItem(same(testClassUuid), any())).thenReturn(createMaybe(new OperationCompletionRS()));
if (!stepResponses.isEmpty()) {
Maybe<ItemCreatedRS> myFirst = stepResponses.get(0);
Maybe<ItemCreatedRS>[] myOther = stepResponses.subList(1, stepResponses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(testClassUuid), any())).thenReturn(myFirst, myOther);
new HashSet<>(test.getValue()).forEach(testMethodUuid -> when(client.finishTestItem(same(testMethodUuid), any())).thenReturn(createMaybe(new OperationCompletionRS())));
}
});
}
use of com.epam.reportportal.service.ReportPortalClient in project allure-java by reportportal.
the class BaseTest 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 -> createMaybe(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(k), any())).thenReturn(first, other);
});
parentNestedPairs.forEach(p -> when(client.finishTestItem(same(p.getValue()), any())).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> createMaybe(new OperationCompletionRS())));
}
use of com.epam.reportportal.service.ReportPortalClient in project allure-java 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 -> createMaybe(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(k), any())).thenReturn(first, other);
});
parentNestedPairs.forEach(p -> when(client.finishTestItem(same(p.getValue()), any())).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> createMaybe(new OperationCompletionRS())));
}
use of com.epam.reportportal.service.ReportPortalClient in project allure-java 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(TestUtils.createMaybe(new StartLaunchRS(launchUuid, 1L)));
Maybe<ItemCreatedRS> suiteMaybe = TestUtils.createMaybe(new ItemCreatedRS(suiteUuid, suiteUuid));
when(client.startTestItem(any())).thenReturn(suiteMaybe);
Maybe<ItemCreatedRS> testClassMaybe = TestUtils.createMaybe(new ItemCreatedRS(testClassUuid, testClassUuid));
when(client.startTestItem(eq(suiteUuid), any())).thenReturn(testClassMaybe);
List<Maybe<ItemCreatedRS>> responses = testMethodUuidList.stream().map(uuid -> TestUtils.createMaybe(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(TestUtils.createMaybe(new OperationCompletionRS())));
Maybe<OperationCompletionRS> testClassFinishMaybe = TestUtils.createMaybe(new OperationCompletionRS());
when(client.finishTestItem(eq(testClassUuid), any())).thenReturn(testClassFinishMaybe);
Maybe<OperationCompletionRS> suiteFinishMaybe = TestUtils.createMaybe(new OperationCompletionRS());
when(client.finishTestItem(eq(suiteUuid), any())).thenReturn(suiteFinishMaybe);
when(client.finishLaunch(eq(launchUuid), any())).thenReturn(TestUtils.createMaybe(new OperationCompletionRS()));
}
Aggregations