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