Search in sources :

Example 6 with ItemCreatedRS

use of com.epam.ta.reportportal.ws.model.item.ItemCreatedRS 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 -> 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(same(k), any())).thenReturn(first, other);
    });
    parentNestedPairs.forEach(p -> when(client.finishTestItem(same(p.getValue()), any())).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> 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) Answer(org.mockito.stubbing.Answer) Maybe(io.reactivex.Maybe) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) Pair(org.apache.commons.lang3.tuple.Pair) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Example 7 with ItemCreatedRS

use of com.epam.ta.reportportal.ws.model.item.ItemCreatedRS in project service-api by reportportal.

the class RerunHandlerImplTest method happyRerunChildItem.

@Test
void happyRerunChildItem() {
    StartTestItemRQ request = new StartTestItemRQ();
    request.setLaunchUuid("launch_uuid");
    request.setType("STEP");
    String itemName = "name";
    request.setName(itemName);
    final String testCaseId = "caseId";
    request.setTestCaseId(testCaseId);
    Launch launch = getLaunch("uuid");
    TestItem parent = new TestItem();
    parent.setItemId(2L);
    parent.setPath("1.2");
    final TestItem item = getItem(itemName, launch);
    when(rerunSearcher.findItem(any(Queryable.class))).thenReturn(Optional.of(item.getItemId()));
    when(testItemRepository.findById(item.getItemId())).thenReturn(Optional.of(item));
    when(testItemRepository.selectPath("uuid")).thenReturn(Optional.of(Pair.of(parent.getItemId(), parent.getPath())));
    when(testItemRepository.findIdByUuidForUpdate("uuid")).thenReturn(Optional.of(parent.getItemId()));
    when(testItemRepository.getOne(parent.getItemId())).thenReturn(parent);
    Optional<ItemCreatedRS> rerunCreatedRS = rerunHandler.handleChildItem(request, launch, "uuid");
    verify(retryHandler, times(1)).handleRetries(any(), any(), any());
    assertTrue(rerunCreatedRS.isPresent());
}
Also used : Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 8 with ItemCreatedRS

use of com.epam.ta.reportportal.ws.model.item.ItemCreatedRS in project service-api by reportportal.

the class RerunHandlerImplTest method returnEmptyOptionalWhenChildItemNotFound.

@Test
void returnEmptyOptionalWhenChildItemNotFound() {
    StartTestItemRQ request = new StartTestItemRQ();
    request.setLaunchUuid("launch_uuid");
    request.setType("STEP");
    String itemName = "name";
    request.setName(itemName);
    final String testCaseId = "caseId";
    request.setTestCaseId(testCaseId);
    Launch launch = getLaunch("uuid");
    TestItem parent = new TestItem();
    parent.setItemId(2L);
    parent.setPath("1.2");
    when(rerunSearcher.findItem(any(Queryable.class))).thenReturn(Optional.empty());
    when(testItemRepository.selectPath("uuid")).thenReturn(Optional.of(Pair.of(parent.getItemId(), parent.getPath())));
    Optional<ItemCreatedRS> rerunCreatedRS = rerunHandler.handleChildItem(request, launch, "uuid");
    assertFalse(rerunCreatedRS.isPresent());
}
Also used : Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 9 with ItemCreatedRS

use of com.epam.ta.reportportal.ws.model.item.ItemCreatedRS in project service-api by reportportal.

the class StartTestItemHandlerAsyncImpl method startChildItem.

@Override
public ItemCreatedRS startChildItem(ReportPortalUser user, ReportPortalUser.ProjectDetails projectDetails, StartTestItemRQ request, String parentId) {
    // todo: may be problem - no access to repository, so no possibility to validateRoles() here
    request.setUuid(Optional.ofNullable(request.getUuid()).orElse(UUID.randomUUID().toString()));
    amqpTemplate.convertAndSend(EXCHANGE_REPORTING, reportingQueueService.getReportingQueueKey(request.getLaunchUuid()), request, message -> {
        Map<String, Object> headers = message.getMessageProperties().getHeaders();
        headers.put(MessageHeaders.REQUEST_TYPE, RequestType.START_TEST);
        headers.put(MessageHeaders.USERNAME, user.getUsername());
        headers.put(MessageHeaders.PROJECT_NAME, projectDetails.getProjectName());
        headers.put(MessageHeaders.PARENT_ITEM_ID, parentId);
        return message;
    });
    ItemCreatedRS response = new ItemCreatedRS();
    response.setId(request.getUuid());
    return response;
}
Also used : ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS)

Example 10 with ItemCreatedRS

use of com.epam.ta.reportportal.ws.model.item.ItemCreatedRS in project service-api by reportportal.

the class StartTestItemHandlerAsyncImpl method startRootItem.

@Override
public ItemCreatedRS startRootItem(ReportPortalUser user, ReportPortalUser.ProjectDetails projectDetails, StartTestItemRQ request) {
    // todo: may be problem - no access to repository, so no possibility to validateRoles() here
    request.setUuid(Optional.ofNullable(request.getUuid()).orElse(UUID.randomUUID().toString()));
    amqpTemplate.convertAndSend(EXCHANGE_REPORTING, reportingQueueService.getReportingQueueKey(request.getLaunchUuid()), request, message -> {
        Map<String, Object> headers = message.getMessageProperties().getHeaders();
        headers.put(MessageHeaders.REQUEST_TYPE, RequestType.START_TEST);
        headers.put(MessageHeaders.USERNAME, user.getUsername());
        headers.put(MessageHeaders.PROJECT_NAME, projectDetails.getProjectName());
        headers.put(MessageHeaders.PARENT_ITEM_ID, "");
        return message;
    });
    ItemCreatedRS response = new ItemCreatedRS();
    response.setId(request.getUuid());
    return response;
}
Also used : ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS)

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