Search in sources :

Example 1 with TextInputComponentPattern

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

the class ComponentPatternTest method shouldHaveDefaultEnabledFlag.

@Test
public void shouldHaveDefaultEnabledFlag() throws Exception {
    // given
    ComponentDefinition componentDefinition = getComponentDefinition("testName", null);
    componentDefinition.setDefaultEnabled(false);
    AbstractComponentPattern pattern = new TextInputComponentPattern(componentDefinition);
    // then
    assertFalse(pattern.isDefaultEnabled());
}
Also used : ComponentDefinition(com.qcadoo.view.internal.ComponentDefinition) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 2 with TextInputComponentPattern

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

the class ComponentPatternTest method shouldHaveListenersOnEmptyOptions.

@Test
public void shouldHaveListenersOnEmptyOptions() throws Exception {
    // given
    TranslationService translationService = mock(TranslationService.class);
    InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
    ComponentDefinition componentDefinition = getComponentDefinition("testName", null);
    componentDefinition.setTranslationService(translationService);
    componentDefinition.setViewDefinition(viewDefinition);
    AbstractComponentPattern pattern = new TextInputComponentPattern(componentDefinition);
    // when
    Map<String, Object> model = pattern.prepareView(Locale.ENGLISH);
    // then
    JSONObject options = (JSONObject) model.get("jsOptions");
    assertEquals(7, options.length());
}
Also used : JSONObject(org.json.JSONObject) TranslationService(com.qcadoo.localization.api.TranslationService) InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) JSONObject(org.json.JSONObject) ComponentDefinition(com.qcadoo.view.internal.ComponentDefinition) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 3 with TextInputComponentPattern

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

the class ComponentPatternTest method shouldHaveDefaultVisibleFlag.

@Test
public void shouldHaveDefaultVisibleFlag() throws Exception {
    // given
    ComponentDefinition componentDefinition = getComponentDefinition("testName", null);
    componentDefinition.setDefaultVisible(false);
    AbstractComponentPattern pattern = new TextInputComponentPattern(componentDefinition);
    // then
    assertFalse(pattern.isDefaultVisible());
}
Also used : ComponentDefinition(com.qcadoo.view.internal.ComponentDefinition) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 4 with TextInputComponentPattern

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

the class ComponentPatternTest method shouldReturnValidPath.

@Test
public void shouldReturnValidPath() throws Exception {
    // given
    ContainerPattern root = new WindowComponentPattern(getComponentDefinition("rootName", null));
    ContainerPattern child1 = new WindowComponentPattern(getComponentDefinition("child1", root, null));
    ComponentPattern child2 = new TextInputComponentPattern(getComponentDefinition("child2", root, null));
    ComponentPattern child11 = new TextInputComponentPattern(getComponentDefinition("child11", child1, null));
    // when
    String rootPathName = root.getPath();
    String child1PathName = child1.getPath();
    String child2PathName = child2.getPath();
    String child11PathName = child11.getPath();
    // then
    Assert.assertEquals("rootName", rootPathName);
    Assert.assertEquals("rootName.child1", child1PathName);
    Assert.assertEquals("rootName.child2", child2PathName);
    Assert.assertEquals("rootName.child1.child11", child11PathName);
}
Also used : ContainerPattern(com.qcadoo.view.internal.api.ContainerPattern) WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) FormComponentPattern(com.qcadoo.view.internal.components.form.FormComponentPattern) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) ComponentPattern(com.qcadoo.view.internal.api.ComponentPattern) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 5 with TextInputComponentPattern

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

the class ContainerPatternTest method shouldReturnChildByName.

@Test
public void shouldReturnChildByName() throws Exception {
    // given
    AbstractContainerPattern parent = new FormComponentPattern(getComponentDefinition("test", null));
    ComponentPattern child1 = new TextInputComponentPattern(getComponentDefinition("test1", parent, null));
    parent.addChild(child1);
    // when
    ComponentPattern child = parent.getChild("test1");
    // then
    Assert.assertEquals(child1, child);
}
Also used : FormComponentPattern(com.qcadoo.view.internal.components.form.FormComponentPattern) FormComponentPattern(com.qcadoo.view.internal.components.form.FormComponentPattern) ComponentPattern(com.qcadoo.view.internal.api.ComponentPattern) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Aggregations

TextInputComponentPattern (com.qcadoo.view.internal.components.TextInputComponentPattern)24 Test (org.junit.Test)24 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)17 DataDefinition (com.qcadoo.model.api.DataDefinition)13 FieldDefinition (com.qcadoo.model.api.FieldDefinition)11 WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)9 ComponentDefinition (com.qcadoo.view.internal.ComponentDefinition)7 BelongsToType (com.qcadoo.model.api.types.BelongsToType)5 HasManyType (com.qcadoo.model.api.types.HasManyType)5 FormComponentPattern (com.qcadoo.view.internal.components.form.FormComponentPattern)5 ComponentPattern (com.qcadoo.view.internal.api.ComponentPattern)4 ComponentOption (com.qcadoo.view.internal.ComponentOption)2 GridComponentPattern (com.qcadoo.view.internal.components.grid.GridComponentPattern)2 AbstractComponentPattern (com.qcadoo.view.internal.patterns.AbstractComponentPattern)2 AbstractPatternTest (com.qcadoo.view.internal.patterns.AbstractPatternTest)2 JSONObject (org.json.JSONObject)2 TranslationService (com.qcadoo.localization.api.TranslationService)1 FieldType (com.qcadoo.model.api.types.FieldType)1 ComponentState (com.qcadoo.view.api.ComponentState)1 GridComponent (com.qcadoo.view.api.components.GridComponent)1