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