Search in sources :

Example 16 with TextInputComponentPattern

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

the class ComponentPatternTest method shouldHaveHasDescriptionFlag.

@Test
public void shouldHaveHasDescriptionFlag() throws Exception {
    // given
    ComponentDefinition componentDefinition = getComponentDefinition("testName", null);
    componentDefinition.setHasDescription(true);
    AbstractComponentPattern pattern = new TextInputComponentPattern(componentDefinition);
    // then
    assertTrue(pattern.isHasDescription());
}
Also used : ComponentDefinition(com.qcadoo.view.internal.ComponentDefinition) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 17 with TextInputComponentPattern

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

the class ContainerPatternTest method shouldHaveChildren.

@Test
public void shouldHaveChildren() throws Exception {
    // given
    AbstractContainerPattern parent = new FormComponentPattern(getComponentDefinition("test", null));
    ComponentPattern child1 = new TextInputComponentPattern(getComponentDefinition("test1", parent, null));
    ComponentPattern child2 = new TextInputComponentPattern(getComponentDefinition("test2", parent, null));
    parent.addChild(child1);
    parent.addChild(child2);
    // when
    Map<String, ComponentPattern> children = parent.getChildren();
    // then
    Assert.assertEquals(2, children.size());
    Assert.assertEquals(child1, children.get("test1"));
    Assert.assertEquals(child2, children.get("test2"));
}
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)

Example 18 with TextInputComponentPattern

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

the class FieldAndScopeListenerPatternTest method shouldAddItselfToRelationFieldComponentWhenComplexFieldPath.

@Test
public void shouldAddItselfToRelationFieldComponentWhenComplexFieldPath() throws Exception {
    // given
    InternalViewDefinition viewDefinition = Mockito.mock(InternalViewDefinition.class);
    AbstractContainerPattern parent = Mockito.mock(AbstractContainerPattern.class);
    TextInputComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("testName", "#{testComponent}.testField", null, parent, viewDefinition));
    ComponentPatternMock testComponent = new ComponentPatternMock(getComponentDefinition("name", viewDefinition));
    given(viewDefinition.getComponentByReference("testComponent")).willReturn(testComponent);
    // when
    pattern.initialize();
    // then
    Assert.assertEquals(pattern, testComponent.getFieldEntityIdChangeListeners().get("testField"));
}
Also used : InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 19 with TextInputComponentPattern

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

the class InitializationTest method shouldSetFieldDefinitionWithoutFieldComponent.

@Test
public void shouldSetFieldDefinitionWithoutFieldComponent() throws Exception {
    // given
    FieldDefinition fieldDefinition = mock(FieldDefinition.class);
    DataDefinition dataDefinition = mock(DataDefinition.class);
    given(dataDefinition.getField("field")).willReturn(fieldDefinition);
    InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
    AbstractContainerPattern parent = new WindowComponentPattern(getComponentDefinition("parent", viewDefinition));
    setField(parent, "dataDefinition", dataDefinition);
    setField(parent, "initialized", true);
    AbstractComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("test", "field", null, parent, viewDefinition));
    // when
    pattern.initialize();
    // then
    Assert.assertEquals(dataDefinition, getField(pattern, "dataDefinition"));
    Assert.assertEquals(fieldDefinition, getField(pattern, "fieldDefinition"));
}
Also used : WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinition(com.qcadoo.model.api.DataDefinition) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 20 with TextInputComponentPattern

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

the class InitializationTest method shouldGetDataDefinitionFromHasManyTypeFieldDefinition.

@Test
public void shouldGetDataDefinitionFromHasManyTypeFieldDefinition() throws Exception {
    // given
    HasManyType fieldType = mock(HasManyType.class);
    FieldDefinition fieldDefinition = mock(FieldDefinition.class);
    given(fieldDefinition.getType()).willReturn(fieldType);
    DataDefinition dataDefinition = mock(DataDefinition.class);
    given(dataDefinition.getField("field")).willReturn(fieldDefinition);
    DataDefinition belongsToDefinition = mock(DataDefinition.class);
    given(fieldType.getDataDefinition()).willReturn(belongsToDefinition);
    InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
    AbstractContainerPattern parent = new WindowComponentPattern(getComponentDefinition("parent", viewDefinition));
    setField(parent, "dataDefinition", dataDefinition);
    setField(parent, "initialized", true);
    AbstractComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("test", "field", null, parent, viewDefinition));
    // when
    pattern.initialize();
    // then
    Assert.assertEquals(belongsToDefinition, getField(pattern, "dataDefinition"));
    Assert.assertEquals(fieldDefinition, getField(pattern, "fieldDefinition"));
}
Also used : HasManyType(com.qcadoo.model.api.types.HasManyType) WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinition(com.qcadoo.model.api.DataDefinition) 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