Search in sources :

Example 11 with GroupDto

use of org.entando.entando.aps.system.services.group.model.GroupDto in project entando-core by entando.

the class GroupServiceIntegrationTest method testGetGroups_filter_and_pagination.

@Test
public void testGetGroups_filter_and_pagination() throws JsonProcessingException {
    RestListRequest restListRequest = new RestListRequest();
    restListRequest.setPageSize(2);
    restListRequest.addFilter(new Filter("groupname", "s"));
    PagedMetadata<GroupDto> res = this.groupService.getGroups(restListRequest);
    assertThat(res.getPage(), is(1));
    assertThat(res.getPageSize(), is(2));
    assertThat(res.getLastPage(), is(2));
    assertThat(res.getTotalItems(), is(3));
    restListRequest.setPage(1);
    res = this.groupService.getGroups(restListRequest);
    assertThat(res.getPage(), is(1));
    assertThat(res.getPageSize(), is(2));
    assertThat(res.getLastPage(), is(2));
    assertThat(res.getTotalItems(), is(3));
    restListRequest.setPage(2);
    res = this.groupService.getGroups(restListRequest);
    assertThat(res.getPage(), is(2));
    assertThat(res.getPageSize(), is(2));
    assertThat(res.getLastPage(), is(2));
    assertThat(res.getTotalItems(), is(3));
}
Also used : Filter(org.entando.entando.web.common.model.Filter) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupDto(org.entando.entando.aps.system.services.group.model.GroupDto) Test(org.junit.Test)

Example 12 with GroupDto

use of org.entando.entando.aps.system.services.group.model.GroupDto in project entando-core by entando.

the class GroupControllerIntegrationTest method testGetInvalidGroup.

@Test
public void testGetInvalidGroup() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    GroupDto group = this.groupService.getGroup(Group.FREE_GROUP_NAME);
    GroupRequest groupRequest = new GroupRequest();
    groupRequest.setCode(group.getCode());
    groupRequest.setName(group.getName());
    ResultActions result = mockMvc.perform(get("/groups/{code}", "invalid_code").header("Authorization", "Bearer " + accessToken));
    // System.out.println(result.andReturn().getResponse().getContentAsString());
    result.andExpect(status().isNotFound());
    result.andExpect(jsonPath("$.errors[0].code", is(GroupValidator.ERRCODE_GROUP_NOT_FOUND)));
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) GroupRequest(org.entando.entando.web.group.model.GroupRequest) GroupDto(org.entando.entando.aps.system.services.group.model.GroupDto) ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Aggregations

GroupDto (org.entando.entando.aps.system.services.group.model.GroupDto)12 Test (org.junit.Test)7 RestListRequest (org.entando.entando.web.common.model.RestListRequest)6 UserDetails (com.agiletec.aps.system.services.user.UserDetails)4 ResultActions (org.springframework.test.web.servlet.ResultActions)4 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)3 Filter (org.entando.entando.web.common.model.Filter)3 RestResponse (org.entando.entando.web.common.model.RestResponse)3 GroupRequest (org.entando.entando.web.group.model.GroupRequest)3 ResponseEntity (org.springframework.http.ResponseEntity)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Group (com.agiletec.aps.system.services.group.Group)2 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)2 AbstractControllerIntegrationTest (org.entando.entando.web.AbstractControllerIntegrationTest)2 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)2 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)2 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)2 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)1 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)1 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1