use of org.entando.entando.web.guifragment.model.GuiFragmentRequestBody in project entando-core by entando.
the class GuiFragmentValidatorTest method validateExistingAndInvalidFragment.
@Test
public void validateExistingAndInvalidFragment() throws Exception {
GuiFragment existing = new GuiFragment();
existing.setCode("existing");
when(this.guiFragmentManager.getGuiFragment("existing")).thenReturn(existing);
GuiFragmentRequestBody request = new GuiFragmentRequestBody("existing", "");
MapBindingResult bindingResult = new MapBindingResult(new HashMap<Object, Object>(), "fragment");
validator.validate(request, bindingResult);
Assert.assertTrue(bindingResult.hasErrors());
Assert.assertEquals(2, bindingResult.getErrorCount());
}
use of org.entando.entando.web.guifragment.model.GuiFragmentRequestBody in project entando-core by entando.
the class GuiFragmentValidatorTest method validateInvalidFragmentCode_2.
@Test
public void validateInvalidFragmentCode_2() throws Exception {
String code = "wrong_characters_&_$_123";
when(this.guiFragmentManager.getGuiFragment(code)).thenReturn(null);
GuiFragmentRequestBody request = new GuiFragmentRequestBody(code, "<h1>prova</h1>");
MapBindingResult bindingResult = new MapBindingResult(new HashMap<Object, Object>(), "fragment");
validator.validate(request, bindingResult);
Assert.assertTrue(bindingResult.hasErrors());
Assert.assertEquals(1, bindingResult.getErrorCount());
}
Aggregations