use of com.qcadoo.view.internal.api.ComponentPattern in project qcadoo by qcadoo.
the class FormComponentPattern method tryAddVersionField.
private void tryAddVersionField() {
List<ComponentPattern> layouts = getChildren().values().stream().filter(childComponentPattern -> childComponentPattern instanceof GridLayoutPattern).collect(Collectors.toList());
if (!layouts.isEmpty()) {
GridLayoutPattern gridLayoutPattern = (GridLayoutPattern) layouts.get(0);
FieldComponentPattern versionComponentPattern = getVersionField(gridLayoutPattern);
gridLayoutPattern.addChild(versionComponentPattern);
GridLayoutCell[][] cells = gridLayoutPattern.getCells();
if (cells != null && cells[0] != null && cells[0][0] != null) {
cells[0][0].addComponent(versionComponentPattern);
}
}
}
use of com.qcadoo.view.internal.api.ComponentPattern 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);
}
use of com.qcadoo.view.internal.api.ComponentPattern 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.ComponentPattern 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);
}
use of com.qcadoo.view.internal.api.ComponentPattern in project qcadoo by qcadoo.
the class ViewDefinitionTest method shouldReturnPattern.
@Test
public void shouldReturnPattern() throws Exception {
// given
InternalViewDefinition viewDefinition = new ViewDefinitionImpl("name", "plugin", mock(DataDefinition.class), true, null);
ComponentPattern pattern = Mockito.mock(ComponentPattern.class);
viewDefinition.registerComponent("reference", "path", pattern);
// when
ComponentPattern actualPattern = viewDefinition.getComponentByReference("reference");
// then
Assert.assertEquals(pattern, actualPattern);
}
Aggregations