use of com.epam.ta.reportportal.ws.model.BulkRQ 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());
}
use of com.epam.ta.reportportal.ws.model.BulkRQ in project service-api by reportportal.
the class LaunchControllerTest method bulkMoveToDebug.
@Test
void bulkMoveToDebug() throws Exception {
final List<Long> ids = launchRepository.findByFilter(Filter.builder().withTarget(Launch.class).withCondition(FilterCondition.builder().eq(CRITERIA_PROJECT_ID, String.valueOf(2L)).build()).build()).stream().filter(it -> it.getMode() == LaunchModeEnum.DEFAULT).map(Launch::getId).collect(Collectors.toList());
final Map<Long, UpdateLaunchRQ> entities = ids.stream().collect(toMap(it -> it, it -> {
final UpdateLaunchRQ updateLaunchRQ = new UpdateLaunchRQ();
updateLaunchRQ.setMode(DEBUG);
return updateLaunchRQ;
}));
final BulkRQ<Long, UpdateLaunchRQ> bulkRQ = new BulkRQ<>();
bulkRQ.setEntities(entities);
mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/update").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(bulkRQ)).contentType(APPLICATION_JSON)).andExpect(status().is(200));
launchRepository.findAllById(ids).forEach(it -> assertSame(it.getMode(), LaunchModeEnum.DEBUG));
}
use of com.epam.ta.reportportal.ws.model.BulkRQ 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());
}
Aggregations