use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.
the class ComponentStateTest method shouldNotRenderComponentIfNotRequested.
@Test
public void shouldNotRenderComponentIfNotRequested() throws Exception {
// given
InternalComponentState componentState = new SimpleComponentState();
// when
JSONObject json = componentState.render();
// then
assertFalse(json.has(AbstractComponentState.JSON_CONTENT));
}
use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.
the class ComponentStateTest method shouldRenderJsonWithNullFieldValue.
@Test
public void shouldRenderJsonWithNullFieldValue() throws Exception {
// given
InternalComponentState componentState = new SimpleComponentState();
componentState.setFieldValue(null);
componentState.initialize(new JSONObject(), Locale.ENGLISH);
// when
JSONObject json = componentState.render();
// then
assertFalse(json.getJSONObject(AbstractComponentState.JSON_CONTENT).has(AbstractComponentState.JSON_VALUE));
}
use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.
the class ComponentStateTest method shouldModifyEnableFlag.
@Test
public void shouldModifyEnableFlag() throws Exception {
// given
InternalComponentState componentState = new SimpleComponentState();
// when
componentState.setEnabled(false);
// then
assertFalse(componentState.isEnabled());
assertFalse(componentState.render().getBoolean(AbstractComponentState.JSON_ENABLED));
}
use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.
the class ComponentStateTest method shouldHaveVisibleFlag.
@Test
public void shouldHaveVisibleFlag() throws Exception {
// given
InternalComponentState componentState = new SimpleComponentState();
JSONObject json = new JSONObject();
JSONObject jsonContent = new JSONObject();
jsonContent.put(AbstractComponentState.JSON_VALUE, "text");
json.put(AbstractComponentState.JSON_CONTENT, jsonContent);
json.put(AbstractComponentState.JSON_VISIBLE, true);
// when
componentState.initialize(json, Locale.ENGLISH);
// then
assertTrue(componentState.isVisible());
assertTrue(componentState.render().getBoolean(AbstractComponentState.JSON_VISIBLE));
}
use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.
the class ComponentStateTest method shouldHaveFieldValueAfterInitialize.
@Test
public void shouldHaveFieldValueAfterInitialize() throws Exception {
// given
InternalComponentState componentState = new SimpleComponentState();
JSONObject json = new JSONObject();
JSONObject jsonContent = new JSONObject();
jsonContent.put(AbstractComponentState.JSON_VALUE, "text");
json.put(AbstractComponentState.JSON_CONTENT, jsonContent);
// when
componentState.initialize(json, Locale.ENGLISH);
// then
assertEquals("text", componentState.getFieldValue());
}
Aggregations