use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.
the class FinishLaunchHierarchyHandlerTest method getTestItemsWithChildren.
private List<TestItem> getTestItemsWithChildren(Launch launch) {
TestItem parent = new TestItem();
parent.setItemId(1L);
parent.setType(TestItemTypeEnum.SUITE);
parent.setLaunchId(launch.getId());
parent.setPath("1");
parent.setHasStats(true);
parent.setHasChildren(true);
TestItemResults parentResults = new TestItemResults();
parentResults.setStatus(StatusEnum.IN_PROGRESS);
parent.setItemResults(parentResults);
TestItem child = new TestItem();
child.setItemId(2L);
child.setType(TestItemTypeEnum.TEST);
child.setLaunchId(launch.getId());
child.setPath("1.2");
child.setParentId(parent.getItemId());
child.setHasStats(true);
child.setHasChildren(true);
TestItemResults childResults = new TestItemResults();
childResults.setStatus(StatusEnum.IN_PROGRESS);
child.setItemResults(childResults);
return Lists.newArrayList(child, parent);
}
use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.
the class FinishTestItemHandlerImplTest method updateFinishedItemTest.
@Test
void updateFinishedItemTest() {
final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L);
TestItem item = new TestItem();
item.setItemId(1L);
TestItemResults results = new TestItemResults();
results.setStatus(StatusEnum.PASSED);
item.setItemResults(results);
Launch launch = new Launch();
launch.setId(1L);
launch.setUserId(1L);
launch.setProjectId(1L);
item.setStartTime(LocalDateTime.now().minusSeconds(5L));
item.setLaunchId(launch.getId());
item.setType(TestItemTypeEnum.STEP);
item.setHasStats(true);
item.setHasChildren(false);
when(launchRepository.findById(any())).thenReturn(Optional.of(launch));
when(repository.findByUuid("1")).thenReturn(Optional.of(item));
when(repository.findIdByUuidForUpdate(any())).thenReturn(Optional.of(item.getItemId()));
when(repository.findById(item.getItemId())).thenReturn(Optional.of(item));
IssueType issueType = new IssueType();
issueType.setLocator("123");
issueType.setIssueGroup(new IssueGroup());
issueType.setLongName("123123");
issueType.setHexColor("#1232asd");
issueType.setShortName("short");
when(issueTypeHandler.defineIssueType(any(), any())).thenReturn(issueType);
when(statusChangingStrategyMapping.get(any(StatusEnum.class))).thenReturn(statusChangingStrategy);
FinishTestItemRQ finishExecutionRQ = new FinishTestItemRQ();
finishExecutionRQ.setStatus("FAILED");
finishExecutionRQ.setEndTime(new Date());
OperationCompletionRS operationCompletionRS = handler.finishTestItem(rpUser, extractProjectDetails(rpUser, "test_project"), "1", finishExecutionRQ);
verify(statusChangingStrategy, times(1)).changeStatus(any(), any(), any());
verify(issueEntityRepository, times(1)).save(any());
verify(messageBus, times(1)).publishActivity(any());
verify(eventPublisher, times(1)).publishEvent(any(ItemFinishedEvent.class));
}
use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.
the class ClusterItemDataProviderMockTest method getTestItem.
private TestItem getTestItem(int index) {
final TestItem testItem = new TestItem();
testItem.setItemId((long) index);
testItem.setUuid(String.valueOf(index));
testItem.setUniqueId(String.valueOf(index));
testItem.setTestCaseId(String.valueOf(index));
testItem.setTestCaseHash(index);
testItem.setName("name " + index);
testItem.setCodeRef("ref" + index);
testItem.setDescription("description " + index);
testItem.setHasChildren(false);
testItem.setType(TestItemTypeEnum.STEP);
testItem.setHasRetries(false);
testItem.setHasStats(true);
testItem.setLastModified(LocalDateTime.now(ZoneOffset.UTC));
testItem.setPath(String.valueOf(index));
testItem.setStartTime(LocalDateTime.now(ZoneOffset.UTC));
final Set<Parameter> parameters = getParameters(index);
testItem.setParameters(parameters);
final Set<ItemAttribute> attributes = getItemAttributes(index);
testItem.setAttributes(attributes);
final TestItemResults testItemResults = getTestItemResults((long) index);
testItem.setItemResults(testItemResults);
return testItem;
}
use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.
the class DeleteLogHandlerTest method deleteLogByNotOwner.
@Test
void deleteLogByNotOwner() {
long projectId = 1L;
long logId = 2L;
ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.MEMBER, projectId);
Log log = new Log();
TestItem testItem = new TestItem();
TestItemResults itemResults = new TestItemResults();
itemResults.setStatistics(Sets.newHashSet(new Statistics()));
testItem.setItemResults(itemResults);
Launch launch = new Launch();
launch.setId(1L);
launch.setProjectId(projectId);
User user1 = new User();
user1.setId(1L);
user1.setLogin("owner");
launch.setUserId(2L);
testItem.setLaunchId(launch.getId());
log.setTestItem(testItem);
when(testItemService.getEffectiveLaunch(any(TestItem.class))).thenReturn(launch);
when(projectRepository.existsById(projectId)).thenReturn(true);
when(logRepository.findById(logId)).thenReturn(Optional.of(log));
ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.deleteLog(logId, extractProjectDetails(user, "test_project"), user));
assertEquals("You do not have enough permissions.", exception.getMessage());
}
use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.
the class StartTestItemHandlerImplTest method startChildItemUnderFinishedParent.
@Test
void startChildItemUnderFinishedParent() {
final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L);
StartTestItemRQ startTestItemRQ = new StartTestItemRQ();
startTestItemRQ.setLaunchUuid("1");
startTestItemRQ.setStartTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
TestItem item = new TestItem();
item.setItemId(1L);
TestItemResults results = new TestItemResults();
results.setStatus(StatusEnum.FAILED);
item.setItemResults(results);
item.setStartTime(LocalDateTime.now().minusHours(1));
when(launchRepository.findByUuid("1")).thenReturn(Optional.of(getLaunch(1L, StatusEnum.IN_PROGRESS)));
when(testItemRepository.findByUuid("1")).thenReturn(Optional.of(item));
doThrow(new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, Suppliers.formattedSupplier("Unable to add a not nested step item, because parent item with ID = '{}' is a nested step", 1L).get())).when(validator).validate(any(StartTestItemRQ.class), any(TestItem.class));
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.startChildItem(rpUser, extractProjectDetails(rpUser, "test_project"), startTestItemRQ, "1"));
assertEquals("Error in handled Request. Please, check specified parameters: " + "'Unable to add a not nested step item, because parent item with ID = '1' is a nested step'", exception.getMessage());
}
Aggregations