Search in sources :

Example 11 with TestItemResults

use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.

the class FinishTestItemHandlerImplTest method finishStepItemWithoutProvidedStatus.

@Test
void finishStepItemWithoutProvidedStatus() {
    final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L);
    TestItem item = new TestItem();
    item.setItemId(1L);
    TestItemResults results = new TestItemResults();
    results.setStatus(StatusEnum.IN_PROGRESS);
    item.setItemResults(results);
    Launch launch = new Launch();
    launch.setId(1L);
    launch.setUserId(1L);
    launch.setProjectId(1L);
    item.setLaunchId(launch.getId());
    item.setHasChildren(false);
    when(repository.findByUuid("1")).thenReturn(Optional.of(item));
    when(launchRepository.findById(any())).thenReturn(Optional.of(launch));
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.finishTestItem(rpUser, extractProjectDetails(rpUser, "test_project"), "1", new FinishTestItemRQ()));
    assertEquals("Test item status is ambiguous. There is no status provided from request and there are no descendants to check statistics for test item id '1'", exception.getMessage());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 12 with TestItemResults

use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.

the class FinishTestItemHandlerImplTest method finishTestItemByNotLaunchOwner.

@Test
void finishTestItemByNotLaunchOwner() {
    final ReportPortalUser rpUser = getRpUser("not owner", UserRole.USER, ProjectRole.MEMBER, 1L);
    TestItem item = new TestItem();
    Launch launch = new Launch();
    launch.setId(1L);
    launch.setProjectId(1L);
    User user = new User();
    user.setId(2L);
    user.setLogin("owner");
    launch.setUserId(user.getId());
    item.setItemId(1L);
    item.setLaunchId(launch.getId());
    item.setHasChildren(false);
    when(repository.findByUuid("1")).thenReturn(Optional.of(item));
    TestItemResults results = new TestItemResults();
    results.setStatus(StatusEnum.IN_PROGRESS);
    item.setItemResults(results);
    item.setItemId(1L);
    when(launchRepository.findById(any())).thenReturn(Optional.of(launch));
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.finishTestItem(rpUser, extractProjectDetails(rpUser, "test_project"), "1", new FinishTestItemRQ()));
    assertEquals("Finish test item is not allowed. You are not a launch owner.", 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) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) TestItem(com.epam.ta.reportportal.entity.item.TestItem) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 13 with TestItemResults

use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.

the class DeleteLogHandlerTest method cleanUpLogDataTest.

@Test
void cleanUpLogDataTest() {
    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(user1.getId());
    testItem.setLaunchId(launch.getId());
    log.setTestItem(testItem);
    Attachment attachment = new Attachment();
    String attachmentPath = "attachmentPath";
    attachment.setFileId(attachmentPath);
    String attachmentThumbnailPath = "attachmentThumbnail";
    attachment.setThumbnailId(attachmentThumbnailPath);
    log.setAttachment(attachment);
    when(testItemService.getEffectiveLaunch(any(TestItem.class))).thenReturn(launch);
    when(projectRepository.existsById(projectId)).thenReturn(true);
    when(logRepository.findById(logId)).thenReturn(Optional.of(log));
    handler.deleteLog(logId, extractProjectDetails(user, "test_project"), user);
    verify(logRepository, times(1)).delete(log);
    verify(logIndexer, times(1)).cleanIndex(projectId, Collections.singletonList(logId));
}
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) Attachment(com.epam.ta.reportportal.entity.attachment.Attachment) 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 14 with TestItemResults

use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.

the class DeleteLogHandlerTest method cleanUpLogDataNegative.

@Test
void cleanUpLogDataNegative() {
    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(user1.getId());
    testItem.setLaunchId(launch.getId());
    log.setTestItem(testItem);
    Attachment attachment = new Attachment();
    String attachmentPath = "attachmentPath";
    attachment.setFileId(attachmentPath);
    String attachmentThumbnailPath = "attachmentThumbnail";
    attachment.setThumbnailId(attachmentThumbnailPath);
    log.setAttachment(attachment);
    when(testItemService.getEffectiveLaunch(any(TestItem.class))).thenReturn(launch);
    when(projectRepository.existsById(projectId)).thenReturn(true);
    when(logRepository.findById(logId)).thenReturn(Optional.of(log));
    doThrow(IllegalArgumentException.class).when(logRepository).delete(log);
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.deleteLog(logId, extractProjectDetails(user, "test_project"), user));
    assertEquals("Error while Log instance deleting.", 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) Attachment(com.epam.ta.reportportal.entity.attachment.Attachment) 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 15 with TestItemResults

use of com.epam.ta.reportportal.entity.item.TestItemResults in project service-api by reportportal.

the class RerunHandlerImplTest method getItem.

private TestItem getItem(String name, Launch launch) {
    TestItem item = new TestItem();
    item.setItemId(1L);
    item.setName(name);
    item.setLaunchId(launch.getId());
    item.setDescription("desc");
    item.setType(TestItemTypeEnum.STEP);
    TestItemResults itemResults = new TestItemResults();
    itemResults.setStatus(StatusEnum.PASSED);
    item.setItemResults(itemResults);
    return item;
}
Also used : TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

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