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));
}
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)));
}
Aggregations