Search in sources :

Example 91 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.

the class WidgetControllerIntegrationTest method testGetWidget_1.

@Test
public void testGetWidget_1() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").withAuthorization(Group.FREE_GROUP_NAME, "managePages", Permission.MANAGE_PAGES).build();
    String accessToken = mockOAuthInterceptor(user);
    // @formatter:off
    ResultActions result = this.executeWidgetGet("1", accessToken, status().isNotFound());
    String response = result.andReturn().getResponse().getContentAsString();
    assertNotNull(response);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 92 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.

the class WidgetControllerIntegrationTest method testGetWidgetInfo.

@Test
public void testGetWidgetInfo() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    // @formatter:off
    ResultActions result = mockMvc.perform(get("/widgets/login_form/info").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken));
    String response = result.andReturn().getResponse().getContentAsString();
    assertNotNull(response);
    result.andExpect(jsonPath("$.payload.publishedUtilizers", Matchers.hasSize(2)));
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 93 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.

the class WidgetControllerIntegrationTest method testUpdateStockLocked.

@Test
public void testUpdateStockLocked() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    String code = "login_form";
    WidgetType widgetType = this.widgetTypeManager.getWidgetType(code);
    WidgetRequest request = new WidgetRequest();
    request.setCode(code);
    request.setGroup(Group.FREE_GROUP_NAME);
    request.setTitles((Map) widgetType.getTitles());
    ResultActions result = this.executeWidgetPut(request, code, accessToken, status().isOk());
    result.andExpect(jsonPath("$.payload.code", is("login_form")));
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) WidgetRequest(org.entando.entando.web.widget.model.WidgetRequest) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 94 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.

the class WidgetControllerIntegrationTest method testDeleteWidgetLocked.

@Test
public void testDeleteWidgetLocked() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    String code = "login_form";
    ResultActions result = this.executeWidgetDelete(code, accessToken, status().isBadRequest());
    result.andExpect(jsonPath("$.errors[0].code", is(WidgetValidator.ERRCODE_OPERATION_FORBIDDEN_LOCKED)));
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 95 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.

the class WidgetControllerIntegrationTest method testGetWidgetsWithAdminPermission.

@Test
public void testGetWidgetsWithAdminPermission() throws Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    ResultActions result = mockMvc.perform(get("/widgets").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken));
    result.andExpect(status().isOk());
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Aggregations

ResultActions (org.springframework.test.web.servlet.ResultActions)624 Test (org.junit.Test)547 UserDetails (com.agiletec.aps.system.services.user.UserDetails)297 AbstractControllerIntegrationTest (org.entando.entando.web.AbstractControllerIntegrationTest)221 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)101 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)65 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)61 MvcResult (org.springframework.test.web.servlet.MvcResult)43 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)39 RequestBuilder (org.springframework.test.web.servlet.RequestBuilder)32 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)26 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)23 UUID (java.util.UUID)22 InputStream (java.io.InputStream)21 Map (java.util.Map)19 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)17 HashMap (java.util.HashMap)17 Test (org.junit.jupiter.api.Test)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)16 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)14