Search in sources :

Example 11 with WindowComponentPattern

use of com.qcadoo.view.internal.components.window.WindowComponentPattern in project qcadoo by qcadoo.

the class ComponentPatternTest method shouldAddItselfToParentOnInitialize.

@Test
public void shouldAddItselfToParentOnInitialize() throws Exception {
    // given
    InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
    AbstractContainerPattern parent = new WindowComponentPattern(getComponentDefinition("test", viewDefinition));
    ComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("testName", "testField", null, parent, viewDefinition));
    // when
    pattern.initialize();
    // then
    assertEquals(pattern, parent.getFieldEntityIdChangeListeners().get("testField"));
}
Also used : WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) 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 12 with WindowComponentPattern

use of com.qcadoo.view.internal.components.window.WindowComponentPattern 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 13 with WindowComponentPattern

use of com.qcadoo.view.internal.components.window.WindowComponentPattern 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)

Example 14 with WindowComponentPattern

use of com.qcadoo.view.internal.components.window.WindowComponentPattern in project qcadoo by qcadoo.

the class InitializationTest method shouldGetDataDefinitionFromBelongsToTypeScopeFieldDefinition.

@Test
public void shouldGetDataDefinitionFromBelongsToTypeScopeFieldDefinition() throws Exception {
    // given
    BelongsToType fieldType = mock(BelongsToType.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", null, "field", parent, viewDefinition));
    // when
    pattern.initialize();
    // then
    Assert.assertEquals(belongsToDefinition, getField(pattern, "dataDefinition"));
    Assert.assertEquals(fieldDefinition, getField(pattern, "scopeFieldDefinition"));
}
Also used : BelongsToType(com.qcadoo.model.api.types.BelongsToType) 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 15 with WindowComponentPattern

use of com.qcadoo.view.internal.components.window.WindowComponentPattern in project qcadoo by qcadoo.

the class InitializationTest method shouldSetFieldDefinitionWithoutScopeComponent.

@Test
public void shouldSetFieldDefinitionWithoutScopeComponent() 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", null, "field", parent, viewDefinition));
    // when
    pattern.initialize();
    // then
    Assert.assertEquals(dataDefinition, getField(pattern, "dataDefinition"));
    Assert.assertEquals(fieldDefinition, getField(pattern, "scopeFieldDefinition"));
}
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)

Aggregations

WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)16 Test (org.junit.Test)12 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)11 DataDefinition (com.qcadoo.model.api.DataDefinition)9 TextInputComponentPattern (com.qcadoo.view.internal.components.TextInputComponentPattern)9 FieldDefinition (com.qcadoo.model.api.FieldDefinition)6 ComponentPattern (com.qcadoo.view.internal.api.ComponentPattern)4 FormComponentPattern (com.qcadoo.view.internal.components.form.FormComponentPattern)3 BelongsToType (com.qcadoo.model.api.types.BelongsToType)2 HasManyType (com.qcadoo.model.api.types.HasManyType)2 ModuleException (com.qcadoo.plugin.api.ModuleException)2 ViewDefinitionImpl (com.qcadoo.view.internal.internal.ViewDefinitionImpl)2 ViewDefinitionParserException (com.qcadoo.view.internal.xml.ViewDefinitionParserException)2 ViewDefinitionParserNodeException (com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException)2 IOException (java.io.IOException)2 JSONObject (org.json.JSONObject)2 Node (org.w3c.dom.Node)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ComponentDefinition (com.qcadoo.view.internal.ComponentDefinition)1 ContainerPattern (com.qcadoo.view.internal.api.ContainerPattern)1