Search in sources :

Example 11 with RestListRequest

use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.

the class RestListRequestTest method should_create_default_pagination.

@SuppressWarnings("rawtypes")
@Test
public void should_create_default_pagination() {
    RestListRequest request = new RestListRequest();
    // filters
    List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
    assertThat(filters.size(), is(2));
    // pagination
    assertThat(filters.get(0).getKey(), is(nullValue()));
    assertThat(filters.get(0).getLimit(), is(not(nullValue())));
    assertThat(filters.get(0).getOffset(), is(not(nullValue())));
}
Also used : RestListRequest(org.entando.entando.web.common.model.RestListRequest) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Test(org.junit.Test)

Example 12 with RestListRequest

use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.

the class EntityManagerServiceIntegrationTest method testGetManagers.

@Test
public void testGetManagers() {
    RestListRequest restListRequest = new RestListRequest();
    restListRequest.setPageSize(5);
    PagedMetadata<String> res = this.entityManagerService.getEntityManagers(restListRequest);
    assertThat(res.getPage(), is(1));
    assertThat(res.getPageSize(), is(5));
    assertThat(res.getLastPage(), is(1));
    assertThat(res.getTotalItems(), is(3));
    List<String> result = res.getBody();
    assertNotNull(result);
    assertEquals(3, result.size());
}
Also used : RestListRequest(org.entando.entando.web.common.model.RestListRequest) Test(org.junit.Test)

Example 13 with RestListRequest

use of org.entando.entando.web.common.model.RestListRequest in project entando-core by entando.

the class EntityManagerServiceIntegrationTest method testGetEntityTypes_2.

@Test
public void testGetEntityTypes_2() {
    RestListRequest restListRequest = new RestListRequest();
    PagedMetadata<EntityTypeShortDto> dtos = this.entityManagerService.getShortEntityTypes(JacmsSystemConstants.CONTENT_MANAGER, restListRequest);
    assertNotNull(dtos);
    assertEquals(4, dtos.getBody().size());
}
Also used : EntityTypeShortDto(org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto) RestListRequest(org.entando.entando.web.common.model.RestListRequest) Test(org.junit.Test)

Example 14 with RestListRequest

use of org.entando.entando.web.common.model.RestListRequest 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));
}
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 15 with RestListRequest

use of org.entando.entando.web.common.model.RestListRequest 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)

Aggregations

RestListRequest (org.entando.entando.web.common.model.RestListRequest)26 Test (org.junit.Test)19 UserDetails (com.agiletec.aps.system.services.user.UserDetails)11 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)10 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)9 Filter (org.entando.entando.web.common.model.Filter)9 ResultActions (org.springframework.test.web.servlet.ResultActions)9 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)7 ArrayList (java.util.ArrayList)7 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)7 GroupDto (org.entando.entando.aps.system.services.group.model.GroupDto)6 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)5 List (java.util.List)5 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)5 RestServerError (org.entando.entando.aps.system.exception.RestServerError)5 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)4 Map (java.util.Map)3