Search in sources :

Example 6 with FinishExecutionRQ

use of com.epam.ta.reportportal.ws.model.FinishExecutionRQ in project service-api by reportportal.

the class FinishLaunchHandlerImplTest method finishWithIncorrectStatus.

@Test
void finishWithIncorrectStatus() {
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    final ReportPortalUser rpUser = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    when(launchRepository.findByUuid("1")).thenReturn(getLaunch(StatusEnum.PASSED, LaunchModeEnum.DEFAULT));
    assertThrows(ReportPortalException.class, () -> handler.finishLaunch("1", finishExecutionRQ, extractProjectDetails(rpUser, "test_project"), rpUser, null));
}
Also used : ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) Test(org.junit.jupiter.api.Test)

Example 7 with FinishExecutionRQ

use of com.epam.ta.reportportal.ws.model.FinishExecutionRQ in project service-api by reportportal.

the class FinishLaunchHandlerImplTest method bulkStopLaunch.

@Test
void bulkStopLaunch() {
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    Map<Long, FinishExecutionRQ> entities = new HashMap<>();
    entities.put(1L, finishExecutionRQ);
    BulkRQ<Long, FinishExecutionRQ> bulkRq = new BulkRQ<>();
    bulkRq.setEntities(entities);
    ReportPortalUser rpUser = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    when(launchRepository.findById(1L)).thenReturn(getLaunch(StatusEnum.IN_PROGRESS, LaunchModeEnum.DEFAULT));
    final List<OperationCompletionRS> response = stopLaunchHandler.stopLaunch(bulkRq, extractProjectDetails(rpUser, "test_project"), rpUser);
    assertNotNull(response);
    assertEquals(1, response.size());
}
Also used : BulkRQ(com.epam.ta.reportportal.ws.model.BulkRQ) HashMap(java.util.HashMap) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) Test(org.junit.jupiter.api.Test)

Example 8 with FinishExecutionRQ

use of com.epam.ta.reportportal.ws.model.FinishExecutionRQ in project service-api by reportportal.

the class FinishLaunchHandlerImplTest method finishLaunchWithLink.

@Test
void finishLaunchWithLink() {
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    ReportPortalUser rpUser = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    when(launchRepository.findByUuid("1")).thenReturn(getLaunch(StatusEnum.IN_PROGRESS, LaunchModeEnum.DEFAULT));
    final FinishLaunchRS finishLaunchRS = handler.finishLaunch("1", finishExecutionRQ, extractProjectDetails(rpUser, "test_project"), rpUser, "http://example.com");
    verify(finishHierarchyHandler, times(1)).finishDescendants(any(), any(), any(), any(), any());
    assertNotNull(finishLaunchRS);
    assertEquals("http://example.com/ui/#test_project/launches/all/1", finishLaunchRS.getLink());
}
Also used : ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) FinishLaunchRS(com.epam.ta.reportportal.ws.model.launch.FinishLaunchRS) Test(org.junit.jupiter.api.Test)

Example 9 with FinishExecutionRQ

use of com.epam.ta.reportportal.ws.model.FinishExecutionRQ in project service-api by reportportal.

the class FinishLaunchHandlerImplTest method finishLaunch.

@Test
void finishLaunch() {
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    ReportPortalUser rpUser = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    when(launchRepository.findByUuid("1")).thenReturn(getLaunch(StatusEnum.IN_PROGRESS, LaunchModeEnum.DEFAULT));
    FinishLaunchRS response = handler.finishLaunch("1", finishExecutionRQ, extractProjectDetails(rpUser, "test_project"), rpUser, null);
    verify(finishHierarchyHandler, times(1)).finishDescendants(any(), any(), any(), any(), any());
    assertNotNull(response);
}
Also used : ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) FinishLaunchRS(com.epam.ta.reportportal.ws.model.launch.FinishLaunchRS) Test(org.junit.jupiter.api.Test)

Example 10 with FinishExecutionRQ

use of com.epam.ta.reportportal.ws.model.FinishExecutionRQ in project service-api by reportportal.

the class LaunchValidatorTest method validate.

@Test
void validate() {
    Launch launch = new Launch();
    launch.setStatus(StatusEnum.IN_PROGRESS);
    launch.setStartTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(1575551458336L), ZoneOffset.UTC));
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(TO_DATE.apply(LocalDateTime.ofInstant(Instant.ofEpochMilli(1575551458334L), ZoneOffset.UTC)));
    ReportPortalException reportPortalException = assertThrows(ReportPortalException.class, () -> LaunchValidator.validate(launch, finishExecutionRQ));
    assertEquals(Suppliers.formattedSupplier(FINISH_TIME_EARLIER_THAN_START_TIME.getDescription(), TO_LOCAL_DATE_TIME.apply(finishExecutionRQ.getEndTime()), launch.getStartTime(), launch.getId()).get(), reportPortalException.getMessage());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Launch(com.epam.ta.reportportal.entity.launch.Launch) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) Test(org.junit.jupiter.api.Test)

Aggregations

FinishExecutionRQ (com.epam.ta.reportportal.ws.model.FinishExecutionRQ)15 Test (org.junit.jupiter.api.Test)13 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)9 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)3 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)3 Launch (com.epam.ta.reportportal.entity.launch.Launch)2 BulkRQ (com.epam.ta.reportportal.ws.model.BulkRQ)2 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)2 FinishLaunchRS (com.epam.ta.reportportal.ws.model.launch.FinishLaunchRS)2 DeleteBulkRQ (com.epam.ta.reportportal.ws.model.DeleteBulkRQ)1 HashMap (java.util.HashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1