use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class StartTestItemHandlerImplTest method startChildItemEarlierThanParent.
@Test
void startChildItemEarlierThanParent() {
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.setStartTime(LocalDateTime.now().plusHours(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)).when(validator).validate(any(StartTestItemRQ.class), any(TestItem.class));
assertThrows(ReportPortalException.class, () -> handler.startChildItem(rpUser, extractProjectDetails(rpUser, "test_project"), startTestItemRQ, "1"));
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class StartTestItemHandlerImplTest method startRootItemUnderFinishedLaunch.
@Test
@Disabled
void startRootItemUnderFinishedLaunch() {
final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L);
StartTestItemRQ startTestItemRQ = new StartTestItemRQ();
startTestItemRQ.setLaunchUuid("1");
when(launchRepository.findByUuid("1")).thenReturn(Optional.of(getLaunch(1L, StatusEnum.PASSED)));
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.startRootItem(rpUser, extractProjectDetails(rpUser, "test_project"), startTestItemRQ));
assertEquals("Start test item is not allowed. Launch '1' is not in progress", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ 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());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class StartTestItemHandlerImplTest method startChildItemUnderNotExistedParent.
@Test
void startChildItemUnderNotExistedParent() {
final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L);
StartTestItemRQ rq = new StartTestItemRQ();
rq.setLaunchUuid("1");
when(launchRepository.findByUuid("1")).thenReturn(Optional.of(getLaunch(1L, StatusEnum.IN_PROGRESS)));
when(testItemRepository.findByUuid("1")).thenReturn(Optional.empty());
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.startChildItem(rpUser, extractProjectDetails(rpUser, "test_project"), rq, "1"));
assertEquals("Test Item '1' not found. Did you use correct Test Item ID?", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class StartTestItemHandlerImplTest method startRootItemEarlierThanLaunch.
@Test
void startRootItemEarlierThanLaunch() {
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()));
final Launch launch = getLaunch(1L, StatusEnum.IN_PROGRESS);
launch.setStartTime(LocalDateTime.now().plusHours(1));
when(launchRepository.findByUuid("1")).thenReturn(Optional.of(launch));
assertThrows(ReportPortalException.class, () -> handler.startRootItem(rpUser, extractProjectDetails(rpUser, "test_project"), startTestItemRQ));
}
Aggregations