use of org.entando.entando.aps.system.services.group.model.GroupDto in project entando-core by entando.
the class GroupControllerUnitTest method testSeachGroups.
@Test
public void testSeachGroups() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(groupService.getGroups(any(RestListRequest.class))).thenReturn(new PagedMetadata<GroupDto>());
ResultActions result = mockMvc.perform(get("/groups").param("page", "1").param("pageSize", "4").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
restListReq.setPage(1);
restListReq.setPageSize(4);
Mockito.verify(groupService, Mockito.times(1)).getGroups(restListReq);
}
use of org.entando.entando.aps.system.services.group.model.GroupDto in project entando-core by entando.
the class GroupControllerUnitTest method testSearchGroupsWithFilters.
@Test
public void testSearchGroupsWithFilters() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(groupService.getGroups(any(RestListRequest.class))).thenReturn(new PagedMetadata<GroupDto>());
ResultActions result = mockMvc.perform(get("/groups").param("page", "1").param("pageSize", "4").param("filter[0].attribute", "code").param("filter[0].value", "free").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
restListReq.setPage(1);
restListReq.setPageSize(4);
restListReq.addFilter(new Filter("code", "free"));
Mockito.verify(groupService, Mockito.times(1)).getGroups(restListReq);
}
use of org.entando.entando.aps.system.services.group.model.GroupDto in project entando-core by entando.
the class GroupServiceIntegrationTest method testGetGroups.
@Test
public void testGetGroups() throws JsonProcessingException {
RestListRequest restListRequest = new RestListRequest();
restListRequest.setPageSize(5);
PagedMetadata<GroupDto> res = this.groupService.getGroups(restListRequest);
assertThat(res.getPage(), is(1));
assertThat(res.getPageSize(), is(5));
assertThat(res.getLastPage(), is(2));
assertThat(res.getTotalItems(), is(6));
//
restListRequest.setPageSize(2);
res = this.groupService.getGroups(restListRequest);
assertThat(res.getPage(), is(1));
assertThat(res.getPageSize(), is(2));
assertThat(res.getLastPage(), is(3));
assertThat(res.getTotalItems(), is(6));
//
restListRequest.setPageSize(4);
res = this.groupService.getGroups(restListRequest);
assertThat(res.getPage(), is(1));
assertThat(res.getPageSize(), is(4));
assertThat(res.getLastPage(), is(2));
assertThat(res.getTotalItems(), is(6));
//
restListRequest.setPageSize(4);
restListRequest.setPage(1);
res = this.groupService.getGroups(restListRequest);
assertThat(res.getPage(), is(1));
assertThat(res.getPageSize(), is(4));
assertThat(res.getLastPage(), is(2));
assertThat(res.getTotalItems(), is(6));
//
restListRequest.setPageSize(4);
restListRequest.setPage(1000);
res = this.groupService.getGroups(restListRequest);
assertThat(res.getPage(), is(1000));
assertThat(res.getPageSize(), is(4));
assertThat(res.getLastPage(), is(2));
assertThat(res.getTotalItems(), is(6));
}
use of org.entando.entando.aps.system.services.group.model.GroupDto in project entando-core by entando.
the class GroupController method addGroup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addGroup(@Valid @RequestBody GroupRequest groupRequest, BindingResult bindingResult) throws ApsSystemException {
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
getGroupValidator().validate(groupRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationConflictException(bindingResult);
}
GroupDto dto = this.getGroupService().addGroup(groupRequest);
return new ResponseEntity<>(new RestResponse(dto), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.group.model.GroupDto in project entando-core by entando.
the class GroupServiceIntegrationTest method testGetGroups_filter.
@Test
public void testGetGroups_filter() throws JsonProcessingException {
RestListRequest restListRequest = new RestListRequest();
restListRequest.addFilter(new Filter("groupname", "fr"));
PagedMetadata<GroupDto> res = this.groupService.getGroups(restListRequest);
assertThat(res.getPage(), is(1));
assertThat(res.getPageSize(), is(100));
assertThat(res.getLastPage(), is(1));
assertThat(res.getTotalItems(), is(1));
}
Aggregations