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);
}
Aggregations