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())));
}
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());
}
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());
}
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;
}
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;
}
Aggregations