Search in sources :

Example 1 with GuiFragmentValidator

use of org.entando.entando.web.guifragment.validator.GuiFragmentValidator in project entando-core by entando.

the class GuiFragmentControllerTest method should_validate_put_path_mismatch.

@Test
public void should_validate_put_path_mismatch() throws ApsSystemException, Exception {
    UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
    String accessToken = mockOAuthInterceptor(user);
    ObjectMapper mapper = new ObjectMapper();
    GuiFragmentRequestBody requestBody = new GuiFragmentRequestBody();
    requestBody.setCode("__new_fragment_");
    requestBody.setGuiCode("<h1>This is the fragment</h1>");
    String payload = mapper.writeValueAsString(requestBody);
    this.controller.setGuiFragmentValidator(new GuiFragmentValidator());
    ResultActions result = mockMvc.perform(put("/fragments/{fragmentCode}", "new_fragment").content(payload).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
    result.andExpect(status().isBadRequest());
    String response = result.andReturn().getResponse().getContentAsString();
    System.out.println(response);
}
Also used : GuiFragmentValidator(org.entando.entando.web.guifragment.validator.GuiFragmentValidator) UserDetails(com.agiletec.aps.system.services.user.UserDetails) GuiFragmentRequestBody(org.entando.entando.web.guifragment.model.GuiFragmentRequestBody) ResultActions(org.springframework.test.web.servlet.ResultActions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Aggregations

UserDetails (com.agiletec.aps.system.services.user.UserDetails)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)1 GuiFragmentRequestBody (org.entando.entando.web.guifragment.model.GuiFragmentRequestBody)1 GuiFragmentValidator (org.entando.entando.web.guifragment.validator.GuiFragmentValidator)1 Test (org.junit.Test)1 ResultActions (org.springframework.test.web.servlet.ResultActions)1