Search in sources :

Example 1 with DataObjectModelValidator

use of org.entando.entando.web.dataobjectmodel.validator.DataObjectModelValidator in project entando-core by entando.

the class DataObjectModelControllerTest 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();
    DataObjectModelRequest group = new DataObjectModelRequest();
    group.setModelId("2l");
    group.setDescr("Description");
    group.setType("AAA");
    group.setModel("<p>Test</p>");
    String payload = mapper.writeValueAsString(group);
    this.controller.setDataObjectModelValidator(new DataObjectModelValidator());
    ResultActions result = mockMvc.perform(put("/dataModels/{dataModelId}", "67").content(payload).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
    result.andExpect(status().isBadRequest());
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) DataObjectModelValidator(org.entando.entando.web.dataobjectmodel.validator.DataObjectModelValidator) ResultActions(org.springframework.test.web.servlet.ResultActions) DataObjectModelRequest(org.entando.entando.web.dataobjectmodel.model.DataObjectModelRequest) 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 DataObjectModelRequest (org.entando.entando.web.dataobjectmodel.model.DataObjectModelRequest)1 DataObjectModelValidator (org.entando.entando.web.dataobjectmodel.validator.DataObjectModelValidator)1 Test (org.junit.Test)1 ResultActions (org.springframework.test.web.servlet.ResultActions)1