Search in sources :

Example 21 with ItemCreatedRS

use of com.epam.ta.reportportal.ws.model.item.ItemCreatedRS 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()));
}
Also used : java.util(java.util) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) ArgumentMatchers(org.mockito.ArgumentMatchers) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Maybe(io.reactivex.Maybe) Answer(org.mockito.stubbing.Answer) BatchSaveOperatingRS(com.epam.ta.reportportal.ws.model.BatchSaveOperatingRS) ArgumentCaptor(org.mockito.ArgumentCaptor) Pair(org.apache.commons.lang3.tuple.Pair) Constants(com.epam.ta.reportportal.ws.model.Constants) TestNG(org.testng.TestNG) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Triple(org.apache.commons.lang3.tuple.Triple) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) Buffer(okio.Buffer) Predicate(java.util.function.Predicate) Optional.ofNullable(java.util.Optional.ofNullable) ITestNGListener(org.testng.ITestNGListener) CommonUtils(com.epam.reportportal.util.test.CommonUtils) IOException(java.io.IOException) SaveLogRQ(com.epam.ta.reportportal.ws.model.log.SaveLogRQ) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) MultipartBody(okhttp3.MultipartBody) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) LogLevel(com.epam.reportportal.listeners.LogLevel) HttpRequestUtils(com.epam.reportportal.utils.http.HttpRequestUtils) Maybe(io.reactivex.Maybe) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

ItemCreatedRS (com.epam.ta.reportportal.ws.model.item.ItemCreatedRS)21 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)11 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)11 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)11 StartLaunchRS (com.epam.ta.reportportal.ws.model.launch.StartLaunchRS)11 Maybe (io.reactivex.Maybe)11 java.util (java.util)10 Collectors (java.util.stream.Collectors)10 Pair (org.apache.commons.lang3.tuple.Pair)10 ArgumentCaptor (org.mockito.ArgumentCaptor)10 ArgumentMatchers (org.mockito.ArgumentMatchers)10 Mockito.when (org.mockito.Mockito.when)10 Answer (org.mockito.stubbing.Answer)10 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)9 CommonUtils (com.epam.reportportal.util.test.CommonUtils)8 BatchSaveOperatingRS (com.epam.ta.reportportal.ws.model.BatchSaveOperatingRS)8 SaveLogRQ (com.epam.ta.reportportal.ws.model.log.SaveLogRQ)7 Optional.ofNullable (java.util.Optional.ofNullable)7 HttpRequestUtils (com.epam.reportportal.utils.http.HttpRequestUtils)6 Constants (com.epam.ta.reportportal.ws.model.Constants)6