Search in sources :

Example 81 with StartTestItemRQ

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

Example 82 with StartTestItemRQ

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

Example 83 with StartTestItemRQ

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

Example 84 with StartTestItemRQ

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

Example 85 with StartTestItemRQ

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

Aggregations

StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)159 Test (org.junit.jupiter.api.Test)124 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)30 List (java.util.List)21 TestNG (org.testng.TestNG)21 Launch (com.epam.reportportal.service.Launch)20 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)19 BeforeEach (org.junit.jupiter.api.BeforeEach)19 TestNgListener (com.epam.reportportal.testng.util.TestNgListener)18 Collectors (java.util.stream.Collectors)17 ArgumentCaptor (org.mockito.ArgumentCaptor)17 ReportPortal (com.epam.reportportal.service.ReportPortal)16 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)15 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)15 ArgumentMatchers.same (org.mockito.ArgumentMatchers.same)14 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)13 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)13 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)12 Set (java.util.Set)12 Nonnull (javax.annotation.Nonnull)12