Search in sources :

Example 6 with StartLaunchRS

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRS 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()));
}
Also used : ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) java.util(java.util) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) ArgumentMatchers(org.mockito.ArgumentMatchers) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Launch(com.epam.reportportal.service.Launch) Maybe(io.reactivex.Maybe) ITestNGListener(org.testng.ITestNGListener) CommonUtils(com.epam.reportportal.util.test.CommonUtils) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) Answer(org.mockito.stubbing.Answer) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) ArgumentCaptor(org.mockito.ArgumentCaptor) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) Pair(org.apache.commons.lang3.tuple.Pair) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) TestNG(org.testng.TestNG) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) 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)

Example 7 with StartLaunchRS

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRS 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()));
}
Also used : java.util(java.util) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) ArgumentMatchers(org.mockito.ArgumentMatchers) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Launch(com.epam.reportportal.service.Launch) Maybe(io.reactivex.Maybe) Answer(org.mockito.stubbing.Answer) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) BatchSaveOperatingRS(com.epam.ta.reportportal.ws.model.BatchSaveOperatingRS) ArgumentCaptor(org.mockito.ArgumentCaptor) Pair(org.apache.commons.lang3.tuple.Pair) LauncherFactory(org.junit.platform.launcher.core.LauncherFactory) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) DiscoverySelectors(org.junit.platform.engine.discovery.DiscoverySelectors) CommonUtils.createMaybeUuid(com.epam.reportportal.util.test.CommonUtils.createMaybeUuid) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) CommonUtils(com.epam.reportportal.util.test.CommonUtils) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) LauncherConfig(org.junit.platform.launcher.core.LauncherConfig) Stream(java.util.stream.Stream) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) LauncherDiscoveryRequestBuilder(org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) Mockito.mock(org.mockito.Mockito.mock) 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)

Example 8 with StartLaunchRS

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRS 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

StartLaunchRS (com.epam.ta.reportportal.ws.model.launch.StartLaunchRS)8 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)5 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)5 ItemCreatedRS (com.epam.ta.reportportal.ws.model.item.ItemCreatedRS)5 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)4 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4 Maybe (io.reactivex.Maybe)4 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 Pair (org.apache.commons.lang3.tuple.Pair)4 ArgumentCaptor (org.mockito.ArgumentCaptor)4 ArgumentMatchers (org.mockito.ArgumentMatchers)4 Mockito.when (org.mockito.Mockito.when)4 Answer (org.mockito.stubbing.Answer)4 CommonUtils (com.epam.reportportal.util.test.CommonUtils)3 BatchSaveOperatingRS (com.epam.ta.reportportal.ws.model.BatchSaveOperatingRS)3 SaveLogRQ (com.epam.ta.reportportal.ws.model.log.SaveLogRQ)3 Launch (com.epam.reportportal.service.Launch)2 HttpRequestUtils (com.epam.reportportal.utils.http.HttpRequestUtils)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2