Search in sources :

Example 21 with TestItemResults

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);
}
Also used : TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Example 22 with TestItemResults

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));
}
Also used : IssueGroup(com.epam.ta.reportportal.entity.item.issue.IssueGroup) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) ItemFinishedEvent(com.epam.ta.reportportal.core.events.item.ItemFinishedEvent) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) Launch(com.epam.ta.reportportal.entity.launch.Launch) Date(java.util.Date) TestItem(com.epam.ta.reportportal.entity.item.TestItem) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) Test(org.junit.jupiter.api.Test)

Example 23 with TestItemResults

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;
}
Also used : Parameter(com.epam.ta.reportportal.entity.item.Parameter) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Example 24 with TestItemResults

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());
}
Also used : ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) User(com.epam.ta.reportportal.entity.user.User) ReportPortalUserUtil.getRpUser(com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser) Log(com.epam.ta.reportportal.entity.log.Log) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 25 with TestItemResults

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());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Aggregations

TestItemResults (com.epam.ta.reportportal.entity.item.TestItemResults)34 TestItem (com.epam.ta.reportportal.entity.item.TestItem)29 Test (org.junit.jupiter.api.Test)18 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)14 Launch (com.epam.ta.reportportal.entity.launch.Launch)13 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)10 IssueEntity (com.epam.ta.reportportal.entity.item.issue.IssueEntity)8 ReportPortalUserUtil.getRpUser (com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser)7 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)7 User (com.epam.ta.reportportal.entity.user.User)7 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)6 ItemAttribute (com.epam.ta.reportportal.entity.ItemAttribute)5 IssueGroup (com.epam.ta.reportportal.entity.item.issue.IssueGroup)5 Statistics (com.epam.ta.reportportal.entity.statistics.Statistics)5 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)5 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)5 TestItemIssueGroup (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup)4 Parameter (com.epam.ta.reportportal.entity.item.Parameter)4 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)3 StatusChangingStrategy (com.epam.ta.reportportal.core.item.impl.status.StatusChangingStrategy)3