use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class InitializationTest method shouldTakeDataDefinitionFromFieldComponent.
@Test
public void shouldTakeDataDefinitionFromFieldComponent() 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 fieldComponent = new TextInputComponentPattern(getComponentDefinition("component", viewDefinition));
setField(fieldComponent, "dataDefinition", dataDefinition);
setField(fieldComponent, "initialized", true);
given(viewDefinition.getComponentByReference("component")).willReturn(fieldComponent);
AbstractComponentPattern pattern = new TextInputComponentPattern(getComponentDefinition("test", "#{component}.field", null, null, viewDefinition));
// when
pattern.initialize();
// then
Assert.assertEquals(dataDefinition, 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 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"));
}
use of com.qcadoo.view.internal.api.InternalViewDefinition 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.InternalViewDefinition in project qcadoo by qcadoo.
the class ViewDefinitionTest method shouldHaveBasicInformation.
@Test
public void shouldHaveBasicInformation() throws Exception {
// given
DataDefinition dataDefinition = mock(DataDefinition.class);
InternalViewDefinition viewDefinition = new ViewDefinitionImpl("name", "plugin", dataDefinition, true, null);
// then
assertEquals("name", viewDefinition.getName());
assertEquals("plugin", viewDefinition.getPluginIdentifier());
assertEquals(dataDefinition, viewDefinition.getDataDefinition());
assertTrue(viewDefinition.isMenuAccessible());
}
Aggregations