Search in sources :

Example 6 with UpdateUserFilterRQ

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());
}
Also used : UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ActivityEvent(com.epam.ta.reportportal.core.events.ActivityEvent) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) Test(org.junit.jupiter.api.Test)

Example 7 with UpdateUserFilterRQ

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());
}
Also used : UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ActivityEvent(com.epam.ta.reportportal.core.events.ActivityEvent) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) Test(org.junit.jupiter.api.Test)

Example 8 with UpdateUserFilterRQ

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());
}
Also used : UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ActivityEvent(com.epam.ta.reportportal.core.events.ActivityEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 9 with UpdateUserFilterRQ

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;
}
Also used : Order(com.epam.ta.reportportal.ws.model.filter.Order) UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) UserFilterCondition(com.epam.ta.reportportal.ws.model.filter.UserFilterCondition)

Example 10 with 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());
}
Also used : Order(com.epam.ta.reportportal.ws.model.filter.Order) UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) UserFilterCondition(com.epam.ta.reportportal.ws.model.filter.UserFilterCondition) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

UpdateUserFilterRQ (com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ)19 Test (org.junit.jupiter.api.Test)17 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)13 MvcResult (org.springframework.test.web.servlet.MvcResult)11 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)10 Order (com.epam.ta.reportportal.ws.model.filter.Order)6 UserFilterCondition (com.epam.ta.reportportal.ws.model.filter.UserFilterCondition)6 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)3 ActivityEvent (com.epam.ta.reportportal.core.events.ActivityEvent)3 UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)3 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)2 FilterSort (com.epam.ta.reportportal.entity.filter.FilterSort)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1