Search in sources :

Example 11 with FinishExecutionRQ

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

the class LaunchAsyncControllerTest method finishLaunch.

@Test
void finishLaunch() {
    ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    String launchId = UUID.randomUUID().toString();
    ArgumentCaptor<String> launchIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<FinishExecutionRQ> requestArgumentCaptor = ArgumentCaptor.forClass(FinishExecutionRQ.class);
    ArgumentCaptor<ReportPortalUser.ProjectDetails> projectDetailsArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.ProjectDetails.class);
    ArgumentCaptor<ReportPortalUser> userArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.class);
    ArgumentCaptor<String> urlArgumentCaptor = ArgumentCaptor.forClass(String.class);
    when(projectExtractor.extractProjectDetails(any(ReportPortalUser.class), anyString())).thenReturn(user.getProjectDetails().get("test_project"));
    when(httpServletRequest.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080"));
    when(httpServletRequest.getHeaderNames()).thenReturn(new Enumerator<>(Lists.newArrayList()));
    launchAsyncController.finishLaunch("test_project", launchId, finishExecutionRQ, user, httpServletRequest);
    verify(finishLaunchHandler).finishLaunch(launchIdArgumentCaptor.capture(), requestArgumentCaptor.capture(), projectDetailsArgumentCaptor.capture(), userArgumentCaptor.capture(), urlArgumentCaptor.capture());
    assertEquals(user, userArgumentCaptor.getValue());
    assertEquals(user.getProjectDetails().get("test_project"), projectDetailsArgumentCaptor.getValue());
    assertEquals(finishExecutionRQ, requestArgumentCaptor.getValue());
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) Test(org.junit.jupiter.api.Test)

Example 12 with FinishExecutionRQ

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

the class LaunchControllerTest method forceFinishLaunch.

@Test
void forceFinishLaunch() throws Exception {
    final FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    finishExecutionRQ.setStatus(StatusEnum.PASSED.name());
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/3/stop").contentType(APPLICATION_JSON).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(finishExecutionRQ))).andExpect(status().is(200));
}
Also used : FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 13 with FinishExecutionRQ

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

the class LaunchControllerTest method bulkForceFinish.

@Test
void bulkForceFinish() throws Exception {
    final BulkRQ<Long, FinishExecutionRQ> bulkRQ = new BulkRQ<>();
    bulkRQ.setEntities(Stream.of(3L, 5L).collect(toMap(it -> it, it -> {
        FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
        finishExecutionRQ.setStatus(StatusEnum.PASSED.name());
        finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
        return finishExecutionRQ;
    })));
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/stop").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(bulkRQ))).andExpect(status().isOk());
}
Also used : DeleteBulkRQ(com.epam.ta.reportportal.ws.model.DeleteBulkRQ) BulkRQ(com.epam.ta.reportportal.ws.model.BulkRQ) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 14 with FinishExecutionRQ

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

the class LaunchControllerTest method finishLaunch.

@Test
void finishLaunch() throws Exception {
    final FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    finishExecutionRQ.setStatus(StatusEnum.PASSED.name());
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/befef834-b2ef-4acf-aea3-b5a5b15fd93c/finish").contentType(APPLICATION_JSON).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(finishExecutionRQ))).andExpect(status().is(200));
}
Also used : FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 15 with FinishExecutionRQ

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

the class AbstractImportStrategy method finishLaunch.

protected void finishLaunch(String launchId, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, ParseResults results, String baseUrl) {
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(results.getEndTime());
    finishLaunchHandler.finishLaunch(launchId, finishExecutionRQ, projectDetails, user, baseUrl);
    Launch launch = launchRepository.findByUuid(launchId).orElseThrow(() -> new ReportPortalException(ErrorType.LAUNCH_NOT_FOUND, launchId));
    launch.setStartTime(results.getStartTime());
    launchRepository.save(launch);
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch)

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