use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UpdateUserFilterHandlerTest method updateUserFilterWithTheSameName.
@Test
void updateUserFilterWithTheSameName() {
final ReportPortalUser rpUser = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, 1L);
UpdateUserFilterRQ updateUserFilterRQ = getUpdateRequest(SAME_NAME);
ReportPortalUser.ProjectDetails projectDetails = extractProjectDetails(rpUser, "test_project");
when(getShareableEntityHandler.getAdministrated(1L, projectDetails)).thenReturn(userFilter);
when(userFilter.getId()).thenReturn(1L);
when(userFilter.getName()).thenReturn(SAME_NAME);
when(userFilter.getProject()).thenReturn(project);
when(project.getId()).thenReturn(1L);
doNothing().when(aclHandler).initAcl(userFilter, "user", 1L, updateUserFilterRQ.getShare());
doNothing().when(messageBus).publishActivity(any(ActivityEvent.class));
OperationCompletionRS operationCompletionRS = updateUserFilterHandler.updateUserFilter(1L, updateUserFilterRQ, projectDetails, rpUser);
assertEquals("User filter with ID = '" + userFilter.getId() + "' successfully updated.", operationCompletionRS.getResultMessage());
}
use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UpdateUserFilterHandlerTest method updateUserFilterWithAnotherNamePositive.
@Test
void updateUserFilterWithAnotherNamePositive() {
final ReportPortalUser rpUser = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, 1L);
UpdateUserFilterRQ updateUserFilterRQ = getUpdateRequest(ANOTHER_NAME);
ReportPortalUser.ProjectDetails projectDetails = extractProjectDetails(rpUser, "test_project");
when(getShareableEntityHandler.getAdministrated(1L, projectDetails)).thenReturn(userFilter);
when(userFilter.getId()).thenReturn(1L);
when(userFilter.getName()).thenReturn(SAME_NAME);
when(userFilter.getProject()).thenReturn(project);
when(project.getId()).thenReturn(1L);
when(userFilterRepository.existsByNameAndOwnerAndProjectId(updateUserFilterRQ.getName(), "user", 1L)).thenReturn(Boolean.FALSE);
doNothing().when(aclHandler).initAcl(userFilter, "user", 1L, updateUserFilterRQ.getShare());
doNothing().when(messageBus).publishActivity(any(ActivityEvent.class));
OperationCompletionRS operationCompletionRS = updateUserFilterHandler.updateUserFilter(1L, updateUserFilterRQ, projectDetails, rpUser);
assertEquals("User filter with ID = '" + userFilter.getId() + "' successfully updated.", operationCompletionRS.getResultMessage());
}
use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UpdateUserFilterHandlerTest method updateUserFilterWithAnotherNameNegative.
@Test
void updateUserFilterWithAnotherNameNegative() {
final ReportPortalUser rpUser = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, 1L);
UpdateUserFilterRQ updateUserFilterRQ = getUpdateRequest(ANOTHER_NAME);
ReportPortalUser.ProjectDetails projectDetails = extractProjectDetails(rpUser, "test_project");
when(getShareableEntityHandler.getAdministrated(1L, projectDetails)).thenReturn(userFilter);
when(userFilter.getId()).thenReturn(1L);
when(userFilter.getName()).thenReturn(SAME_NAME);
when(userFilter.getProject()).thenReturn(project);
when(userFilter.getOwner()).thenReturn("user");
when(project.getId()).thenReturn(1L);
when(userFilterRepository.existsByNameAndOwnerAndProjectId(updateUserFilterRQ.getName(), userFilter.getOwner(), projectDetails.getProjectId())).thenReturn(Boolean.TRUE);
doNothing().when(aclHandler).initAcl(userFilter, "user", 1L, updateUserFilterRQ.getShare());
doNothing().when(messageBus).publishActivity(any(ActivityEvent.class));
final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> updateUserFilterHandler.updateUserFilter(1L, updateUserFilterRQ, projectDetails, rpUser));
assertEquals(Suppliers.formattedSupplier("User filter with name '{}' already exists for user '{}' under the project '{}'. You couldn't create the duplicate.", ANOTHER_NAME, "user", projectDetails.getProjectName()).get(), exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UpdateUserFilterHandlerTest method getUpdateRequest.
private UpdateUserFilterRQ getUpdateRequest(String name) {
UpdateUserFilterRQ updateUserFilterRQ = new UpdateUserFilterRQ();
updateUserFilterRQ.setName(name);
updateUserFilterRQ.setObjectType("Launch");
updateUserFilterRQ.setShare(false);
Order order = new Order();
order.setIsAsc(true);
order.setSortingColumnName(CRITERIA_NAME);
updateUserFilterRQ.setOrders(Lists.newArrayList(order));
UserFilterCondition condition = new UserFilterCondition(CRITERIA_NAME, "cnt", "we");
updateUserFilterRQ.setConditions(Sets.newHashSet(condition));
return updateUserFilterRQ;
}
use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UserFilterControllerTest method createUserFiltersLongDescription.
@Test
void createUserFiltersLongDescription() throws Exception {
String name = "userFilter";
UpdateUserFilterRQ request = new UpdateUserFilterRQ();
request.setName(name);
request.setObjectType("Launch");
final Order order = new Order();
order.setIsAsc(false);
order.setSortingColumnName("startTime");
request.setOrders(Lists.newArrayList(order));
request.setDescription(StringUtils.leftPad("", 1501, "a"));
request.setConditions(Sets.newHashSet(new UserFilterCondition("name", "cnt", "test")));
mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/filter").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().is4xxClientError());
}
Aggregations