use of com.qcadoo.view.internal.api.ComponentPattern in project qcadoo by qcadoo.
the class ContainerPatternTest method shouldReturnNullWhenChildNotExist.
@Test
public void shouldReturnNullWhenChildNotExist() throws Exception {
// given
AbstractContainerPattern parent = new FormComponentPattern(getComponentDefinition("test", null));
// when
ComponentPattern child = parent.getChild("test3");
// then
Assert.assertNull(child);
}
use of com.qcadoo.view.internal.api.ComponentPattern in project qcadoo by qcadoo.
the class FieldAndScopeListenerPatternTest method shouldHaveFieldListeners.
@Test
public void shouldHaveFieldListeners() throws Exception {
// given
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
AbstractContainerPattern parent = new ContainerPatternMock(getComponentDefinition("f1", viewDefinition));
ComponentPatternMock child1 = new ComponentPatternMock(getComponentDefinition("t1", "t1", null, parent, viewDefinition));
ComponentPatternMock child2 = new ComponentPatternMock(getComponentDefinition("t2", "t2", null, parent, viewDefinition));
parent.addChild(child1);
parent.addChild(child2);
parent.initialize();
child1.initialize();
child2.initialize();
// when
Map<String, ComponentPattern> listeners = parent.getFieldEntityIdChangeListeners();
// then
Assert.assertEquals(2, listeners.size());
Assert.assertEquals(child1, listeners.get("t1"));
Assert.assertEquals(child2, listeners.get("t2"));
}
use of com.qcadoo.view.internal.api.ComponentPattern in project qcadoo by qcadoo.
the class FieldAndScopeListenerPatternTest method shouldHaveScopeListeners.
@Test
public void shouldHaveScopeListeners() throws Exception {
// given
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
AbstractContainerPattern parent = new ContainerPatternMock(getComponentDefinition("f1", viewDefinition));
ComponentPatternMock child1 = new ComponentPatternMock(getComponentDefinition("t1", null, "t1", parent, viewDefinition));
ComponentPatternMock child2 = new ComponentPatternMock(getComponentDefinition("t2", null, "t2", parent, viewDefinition));
parent.addChild(child1);
parent.addChild(child2);
parent.initialize();
child1.initialize();
child2.initialize();
// when
Map<String, ComponentPattern> listeners = parent.getScopeEntityIdChangeListeners();
// then
Assert.assertEquals(2, listeners.size());
Assert.assertEquals(child1, listeners.get("t1"));
Assert.assertEquals(child2, listeners.get("t2"));
}
use of com.qcadoo.view.internal.api.ComponentPattern in project qcadoo by qcadoo.
the class ViewDefinitionTest method shouldCallInitializeOnChildren.
@Test
public void shouldCallInitializeOnChildren() throws Exception {
// given
InternalViewDefinition viewDefinition = new ViewDefinitionImpl("name", "plugin", mock(DataDefinition.class), true, null);
ComponentPattern pattern1 = Mockito.mock(ComponentPattern.class);
given(pattern1.getName()).willReturn("test1");
given(pattern1.initialize()).willReturn(false, true);
ComponentPattern pattern2 = Mockito.mock(ComponentPattern.class);
given(pattern2.getName()).willReturn("test2");
given(pattern2.initialize()).willReturn(true);
viewDefinition.addComponentPattern(pattern1);
viewDefinition.addComponentPattern(pattern2);
// when
viewDefinition.initialize();
// then
Mockito.verify(pattern1, times(2)).initialize();
Mockito.verify(pattern2, times(2)).initialize();
}
use of com.qcadoo.view.internal.api.ComponentPattern in project qcadoo by qcadoo.
the class ViewDefinitionTest method shouldReturnJsFilePaths.
@Test
public void shouldReturnJsFilePaths() throws Exception {
// given
ViewDefinitionImpl viewDefinition = new ViewDefinitionImpl("name", "plugin", mock(DataDefinition.class), true, null);
AbstractContainerPattern parent = new WindowComponentPattern(getComponentDefinition("test", viewDefinition));
ComponentPattern form = new FormComponentPattern(getComponentDefinition("test", parent, viewDefinition));
parent.addChild(form);
viewDefinition.addComponentPattern(parent);
viewDefinition.initialize();
// when
Set<String> paths = viewDefinition.getJsFilePaths();
// then
Assert.assertEquals(1, paths.size());
}
Aggregations