Search in sources :

Example 21 with RestListRequest

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

the class EntityManagerControllerTest method getEntityManagers_2.

@Test
public void getEntityManagers_2() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    when(this.entityManagerService.getEntityManagers(any(RestListRequest.class))).thenReturn(new PagedMetadata<>());
    ResultActions result = mockMvc.perform(get("/entityManagers").param("page", "1").param("pageSize", "4").param("filter[0].attribute", "code").param("filter[0].value", "UserProfileManager").header("Authorization", "Bearer " + accessToken));
    result.andExpect(status().isOk());
    RestListRequest restListReq = new RestListRequest();
    restListReq.setPage(1);
    restListReq.setPageSize(4);
    restListReq.addFilter(new Filter("code", "UserProfileManager"));
    Mockito.verify(this.entityManagerService, Mockito.times(1)).getEntityManagers(restListReq);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) Filter(org.entando.entando.web.common.model.Filter) RestListRequest(org.entando.entando.web.common.model.RestListRequest) ResultActions(org.springframework.test.web.servlet.ResultActions) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Example 22 with RestListRequest

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

the class EntityManagerControllerTest method getEntityManagers_1.

@Test
public void getEntityManagers_1() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    when(this.entityManagerService.getEntityManagers(any(RestListRequest.class))).thenReturn(new PagedMetadata<>());
    ResultActions result = mockMvc.perform(get("/entityManagers").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(this.entityManagerService, Mockito.times(1)).getEntityManagers(restListReq);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) RestListRequest(org.entando.entando.web.common.model.RestListRequest) ResultActions(org.springframework.test.web.servlet.ResultActions) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Example 23 with RestListRequest

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

the class GuiFragmentControllerTest method should_load_the_list_of_fragments.

@Test
public void should_load_the_list_of_fragments() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    when(this.guiFragmentService.getGuiFragments(any(RestListRequest.class))).thenReturn(new PagedMetadata<>());
    ResultActions result = mockMvc.perform(get("/fragments").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(this.guiFragmentService, Mockito.times(1)).getGuiFragments(restListReq);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) RestListRequest(org.entando.entando.web.common.model.RestListRequest) ResultActions(org.springframework.test.web.servlet.ResultActions) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Example 24 with RestListRequest

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

the class GuiFragmentControllerTest method should_load_the_list_of_fragments_2.

@Test
public void should_load_the_list_of_fragments_2() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    when(this.guiFragmentService.getGuiFragments(any(RestListRequest.class))).thenReturn(new PagedMetadata<>());
    ResultActions result = mockMvc.perform(get("/fragments").param("page", "1").param("pageSize", "4").param("filter[0].attribute", "code").param("filter[0].value", "userprofile_editCurrentUser_profile").header("Authorization", "Bearer " + accessToken));
    result.andExpect(status().isOk());
    RestListRequest restListReq = new RestListRequest();
    restListReq.setPage(1);
    restListReq.setPageSize(4);
    restListReq.addFilter(new Filter("code", "userprofile_editCurrentUser_profile"));
    Mockito.verify(this.guiFragmentService, Mockito.times(1)).getGuiFragments(restListReq);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) Filter(org.entando.entando.web.common.model.Filter) RestListRequest(org.entando.entando.web.common.model.RestListRequest) ResultActions(org.springframework.test.web.servlet.ResultActions) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Example 25 with RestListRequest

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

the class PageModelControllerTest method should_load_the_list_of_pageModels_1.

@Test
public void should_load_the_list_of_pageModels_1() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    PageModelDto singleDto = new PageModelDto();
    List<PageModelDto> dtos = new ArrayList<>();
    dtos.add(singleDto);
    PageModel model = new PageModel();
    List<PageModel> models = new ArrayList<>();
    models.add(model);
    SearcherDaoPaginatedResult<PageModel> sdpr = new SearcherDaoPaginatedResult<>(1, models);
    PagedMetadata<PageModelDto> meta = new PagedMetadata<>(new RestListRequest(), sdpr);
    meta.setBody(dtos);
    when(pageModelService.getPageModels(any(RestListRequest.class))).thenReturn(meta);
    ResultActions result = mockMvc.perform(get("/pagemodels").header("Authorization", "Bearer " + accessToken));
    System.out.println(result.andReturn().getResponse().getContentAsString());
    result.andExpect(status().isOk());
    RestListRequest restListReq = new RestListRequest();
    Mockito.verify(pageModelService, Mockito.times(1)).getPageModels(restListReq);
}
Also used : PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) ArrayList(java.util.ArrayList) RestListRequest(org.entando.entando.web.common.model.RestListRequest) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PageModelDto(org.entando.entando.aps.system.services.pagemodel.model.PageModelDto) UserDetails(com.agiletec.aps.system.services.user.UserDetails) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ResultActions(org.springframework.test.web.servlet.ResultActions) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) 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