use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class ContainerPatternTest method shouldNotCallInitializeOnChildren.
@Test
public void shouldNotCallInitializeOnChildren() throws Exception {
// given
InternalViewDefinition viewDefinition = Mockito.mock(InternalViewDefinition.class);
ComponentPattern child = Mockito.mock(ComponentPattern.class);
AbstractContainerPattern parent = new FormComponentPattern(getComponentDefinition("test", viewDefinition));
parent.addChild(child);
// when
parent.initialize();
// then
Mockito.verify(child, never()).initialize();
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class FieldAndScopeListenerPatternTest method shouldAddItselfToRelationScopeComponentWhenComplexFieldPath.
@Test
public void shouldAddItselfToRelationScopeComponentWhenComplexFieldPath() throws Exception {
// given
InternalViewDefinition viewDefinition = Mockito.mock(InternalViewDefinition.class);
AbstractContainerPattern parent = Mockito.mock(AbstractContainerPattern.class);
TextInputComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("testName", null, "#{testComponent}.testField", parent, viewDefinition));
ComponentPatternMock testComponent = new ComponentPatternMock(getComponentDefinition("name", viewDefinition));
given(viewDefinition.getComponentByReference("testComponent")).willReturn(testComponent);
// when
pattern.initialize();
// then
assertEquals(pattern, testComponent.getScopeEntityIdChangeListeners().get("testField"));
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class InitializationTest method shouldTakeDataDefinitionFromParent.
@Test
public void shouldTakeDataDefinitionFromParent() throws Exception {
// given
DataDefinition dataDefinition = mock(DataDefinition.class);
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
AbstractContainerPattern parent = new WindowComponentPattern(getComponentDefinition("parent", viewDefinition));
setField(parent, "dataDefinition", dataDefinition);
AbstractComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("test", parent, viewDefinition));
// when
pattern.initialize();
// then
Assert.assertEquals(dataDefinition, getField(pattern, "dataDefinition"));
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class InitializationTest method shouldGetDataDefinitionFromBelongsToTypeFieldDefinition.
@Test
public void shouldGetDataDefinitionFromBelongsToTypeFieldDefinition() 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", "field", null, parent, viewDefinition));
// when
pattern.initialize();
// then
Assert.assertEquals(belongsToDefinition, getField(pattern, "dataDefinition"));
Assert.assertEquals(fieldDefinition, getField(pattern, "fieldDefinition"));
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class InitializationTest method shouldTakeDataDefinitionFromScopeComponent.
@Test
public void shouldTakeDataDefinitionFromScopeComponent() throws Exception {
// given
FieldDefinition fieldDefinition = mock(FieldDefinition.class);
DataDefinition dataDefinition = mock(DataDefinition.class);
given(dataDefinition.getField("field")).willReturn(fieldDefinition);
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
AbstractComponentPattern sourceComponent = new TextInputComponentPattern(getComponentDefinition("component", viewDefinition));
setField(sourceComponent, "dataDefinition", dataDefinition);
setField(sourceComponent, "initialized", true);
given(viewDefinition.getComponentByReference("component")).willReturn(sourceComponent);
AbstractComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("test", null, "#{component}.field", null, viewDefinition));
// when
pattern.initialize();
// then
Assert.assertEquals(dataDefinition, getField(pattern, "dataDefinition"));
Assert.assertEquals(fieldDefinition, getField(pattern, "scopeFieldDefinition"));
}
Aggregations