use of org.entando.entando.web.pagemodel.model.PageModelFrameReq in project entando-core by entando.
the class PageModelTestUtil method createValidFrameRequest.
private static PageModelFrameReq createValidFrameRequest() {
PageModelFrameReq pageReq = new PageModelFrameReq(0, FRAME_DESCRIPTION);
pageReq.getDefaultWidget().setCode("leftmenu");
pageReq.getDefaultWidget().getProperties().put("navSpec", "code(homepage).subtree(5)");
return pageReq;
}
use of org.entando.entando.web.pagemodel.model.PageModelFrameReq in project entando-core by entando.
the class PageModelTestUtil method createValidPageModelConfigurationRequest.
private static PageModelConfigurationRequest createValidPageModelConfigurationRequest() {
PageModelConfigurationRequest configuration = new PageModelConfigurationRequest();
List<PageModelFrameReq> frames = new ArrayList<>();
frames.add(createValidFrameRequest());
frames.add(new PageModelFrameReq(1, "Position 1"));
configuration.setFrames(frames);
return configuration;
}
use of org.entando.entando.web.pagemodel.model.PageModelFrameReq in project entando-core by entando.
the class PageModelControllerIntegrationTest method add_page_model_with_errors.
@Test
public void add_page_model_with_errors() throws Exception {
try {
PageModelRequest pageModelRequest = PageModelTestUtil.validPageModelRequest();
PageModelFrameReq newFrames = new PageModelFrameReq(2, "Position 1");
newFrames.getDefaultWidget().setCode("invalid_widget");
pageModelRequest.getConfiguration().getFrames().add(newFrames);
pageModelRequest.setCode(PAGE_MODEL_CODE);
ResultActions result = mockMvc.perform(post("/pageModels").content(createJson(pageModelRequest)).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isBadRequest());
result.andExpect(jsonPath("$.payload.size()", is(0)));
result.andExpect(jsonPath("$.errors.size()", is(1)));
result.andExpect(jsonPath("$.errors[0].code", is("6")));
result.andExpect(jsonPath("$.metaData.size()", is(0)));
PageModel pageModel = this.pageModelManager.getPageModel(PAGE_MODEL_CODE);
Assert.assertNull(pageModel);
newFrames.getDefaultWidget().setCode("leftmenu");
newFrames.getDefaultWidget().getProperties().put("wrongParam", "code(homepage).subtree(8)");
result = mockMvc.perform(post("/pageModels").content(createJson(pageModelRequest)).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isBadRequest());
result.andExpect(jsonPath("$.payload.size()", is(0)));
result.andExpect(jsonPath("$.errors.size()", is(1)));
result.andExpect(jsonPath("$.errors[0].code", is("7")));
result.andExpect(jsonPath("$.metaData.size()", is(0)));
pageModel = this.pageModelManager.getPageModel(PAGE_MODEL_CODE);
Assert.assertNull(pageModel);
newFrames.getDefaultWidget().getProperties().remove("wrongParam");
PageModelFrameReq newWrongFrames = new PageModelFrameReq(7, "Position 7");
pageModelRequest.getConfiguration().getFrames().add(newWrongFrames);
result = mockMvc.perform(post("/pageModels").content(createJson(pageModelRequest)).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isBadRequest());
result.andExpect(jsonPath("$.payload.size()", is(0)));
result.andExpect(jsonPath("$.errors.size()", is(1)));
result.andExpect(jsonPath("$.errors[0].code", is("5")));
result.andExpect(jsonPath("$.metaData.size()", is(0)));
pageModel = this.pageModelManager.getPageModel(PAGE_MODEL_CODE);
Assert.assertNull(pageModel);
} catch (Exception e) {
throw e;
} finally {
this.pageModelManager.deletePageModel(PAGE_MODEL_CODE);
}
}
Aggregations