Search in sources :

Example 6 with SimpleComponentState

use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.

the class ComponentStateTest method shouldRenderJsonWithFieldValue.

@Test
public void shouldRenderJsonWithFieldValue() throws Exception {
    // given
    InternalComponentState componentState = new SimpleComponentState();
    componentState.setFieldValue("text");
    componentState.initialize(new JSONObject(), Locale.ENGLISH);
    // when
    JSONObject json = componentState.render();
    // then
    assertEquals("text", json.getJSONObject(AbstractComponentState.JSON_CONTENT).getString(AbstractComponentState.JSON_VALUE));
}
Also used : JSONObject(org.json.JSONObject) SimpleComponentState(com.qcadoo.view.internal.components.SimpleComponentState) InternalComponentState(com.qcadoo.view.internal.api.InternalComponentState) Test(org.junit.Test)

Example 7 with SimpleComponentState

use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.

the class ComponentStateTest method shouldModifyVisibleFlag.

@Test
public void shouldModifyVisibleFlag() throws Exception {
    // given
    InternalComponentState componentState = new SimpleComponentState();
    // when
    componentState.setVisible(false);
    // then
    assertFalse(componentState.isVisible());
    assertFalse(componentState.render().getBoolean(AbstractComponentState.JSON_VISIBLE));
}
Also used : SimpleComponentState(com.qcadoo.view.internal.components.SimpleComponentState) InternalComponentState(com.qcadoo.view.internal.api.InternalComponentState) Test(org.junit.Test)

Example 8 with SimpleComponentState

use of com.qcadoo.view.internal.components.SimpleComponentState in project qcadoo by qcadoo.

the class ComponentStateTest method shouldHaveEnableFlag.

@Test
public void shouldHaveEnableFlag() 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_ENABLED, true);
    // when
    componentState.initialize(json, Locale.ENGLISH);
    // then
    assertTrue(componentState.isEnabled());
    assertTrue(componentState.render().getBoolean(AbstractComponentState.JSON_ENABLED));
}
Also used : JSONObject(org.json.JSONObject) SimpleComponentState(com.qcadoo.view.internal.components.SimpleComponentState) InternalComponentState(com.qcadoo.view.internal.api.InternalComponentState) Test(org.junit.Test)

Aggregations

InternalComponentState (com.qcadoo.view.internal.api.InternalComponentState)8 SimpleComponentState (com.qcadoo.view.internal.components.SimpleComponentState)8 Test (org.junit.Test)8 JSONObject (org.json.JSONObject)6