use of com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ in project service-api by reportportal.
the class LaunchControllerTest method updateLaunchPositive.
@Test
void updateLaunchPositive() throws Exception {
UpdateLaunchRQ rq = new UpdateLaunchRQ();
rq.setMode(DEFAULT);
rq.setDescription("description");
rq.setAttributes(Sets.newHashSet(new ItemAttributeResource("test", "test")));
mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/3/update").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().is(200));
}
use of com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ in project service-api by reportportal.
the class UpdateLaunchHandlerImplTest method updateDebugLaunchByCustomer.
@Test
void updateDebugLaunchByCustomer() {
final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.CUSTOMER, 1L);
when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(new Project());
when(launchRepository.findById(1L)).thenReturn(getLaunch(StatusEnum.PASSED, LaunchModeEnum.DEFAULT));
final UpdateLaunchRQ updateLaunchRQ = new UpdateLaunchRQ();
updateLaunchRQ.setMode(Mode.DEBUG);
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateLaunch(1L, extractProjectDetails(rpUser, "test_project"), rpUser, updateLaunchRQ));
assertEquals("You do not have enough permissions.", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ in project service-api by reportportal.
the class UpdateLaunchHandlerImplTest method updateNotOwnLaunch.
@Test
void updateNotOwnLaunch() {
final ReportPortalUser rpUser = getRpUser("not owner", UserRole.USER, ProjectRole.MEMBER, 1L);
rpUser.setUserId(2L);
when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(new Project());
when(launchRepository.findById(1L)).thenReturn(getLaunch(StatusEnum.PASSED, LaunchModeEnum.DEFAULT));
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateLaunch(1L, extractProjectDetails(rpUser, "test_project"), rpUser, new UpdateLaunchRQ()));
assertEquals("You do not have enough permissions.", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ 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));
}
Aggregations