use of com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ in project service-api by reportportal.
the class LaunchAsyncControllerTest method mergeLaunch.
@Test
void mergeLaunch() {
ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
MergeLaunchesRQ mergeLaunchesRQ = new MergeLaunchesRQ();
ArgumentCaptor<ReportPortalUser.ProjectDetails> projectDetailsArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.ProjectDetails.class);
ArgumentCaptor<ReportPortalUser> userArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.class);
ArgumentCaptor<MergeLaunchesRQ> requestArgumentCaptor = ArgumentCaptor.forClass(MergeLaunchesRQ.class);
when(projectExtractor.extractProjectDetails(any(ReportPortalUser.class), anyString())).thenReturn(user.getProjectDetails().get("test_project"));
launchAsyncController.mergeLaunches("test_project", mergeLaunchesRQ, user);
verify(mergeLaunchHandler).mergeLaunches(projectDetailsArgumentCaptor.capture(), userArgumentCaptor.capture(), requestArgumentCaptor.capture());
assertEquals(user, userArgumentCaptor.getValue());
assertEquals(user.getProjectDetails().get("test_project"), projectDetailsArgumentCaptor.getValue());
assertEquals(mergeLaunchesRQ, requestArgumentCaptor.getValue());
}
use of com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ in project service-api by reportportal.
the class LaunchControllerValidationTest method mergeLaunchShouldReturnErrorWhenNameIsNull.
@Test
public void mergeLaunchShouldReturnErrorWhenNameIsNull() throws Exception {
// GIVEN
MergeLaunchesRQ mergeLaunchesRQ = prepareLaunchesMerge();
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + LAUNCH_PATH + MERGE_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(mergeLaunchesRQ)).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()).andReturn();
// THEN
ErrorRS error = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), ErrorRS.class);
assertEquals(INCORRECT_REQUEST, error.getErrorType());
assertEquals(INCORRECT_REQUEST_MESSAGE + FIELD_NAME_IS_NULL_MESSAGE, error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ in project service-api by reportportal.
the class LaunchControllerValidationTest method prepareLaunchesMerge.
private MergeLaunchesRQ prepareLaunchesMerge() {
MergeLaunchesRQ mergeLaunchesRQ = new MergeLaunchesRQ();
HashSet<Long> set = new HashSet<>();
set.add(1L);
set.add(2L);
mergeLaunchesRQ.setLaunches(set);
mergeLaunchesRQ.setMergeStrategyType("BASIC");
mergeLaunchesRQ.setStartTime(new Date());
mergeLaunchesRQ.setEndTime(new Date());
return mergeLaunchesRQ;
}
Aggregations