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());
}
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"));
}
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"));
}
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"));
}
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"));
}
Aggregations