use of com.qcadoo.view.internal.components.form.FormComponentPattern in project qcadoo by qcadoo.
the class DefaultEventHandlerTest method shouldCallCustomEventMethod.
@Test
public void shouldCallCustomEventMethod() throws Exception {
// given
ViewDefinitionState viewDefinitionState = mock(ViewDefinitionState.class);
FormComponentPattern pattern = mock(FormComponentPattern.class);
given(pattern.getExpressionNew()).willReturn(null);
given(pattern.getExpressionEdit()).willReturn(null);
setField(pattern, "applicationContext", applicationContext);
FormComponentState component = new FormComponentState(pattern);
ViewEventListenerHook eventListener = mock(ViewEventListenerHook.class);
given(eventListener.getEventName()).willReturn("custom");
component.registerCustomEvent(eventListener);
// when
component.performEvent(viewDefinitionState, "custom", "arg0", "arg1");
// then
Mockito.verify(eventListener).invokeEvent(viewDefinitionState, component, new String[] { "arg0", "arg1" });
}
use of com.qcadoo.view.internal.components.form.FormComponentPattern in project qcadoo by qcadoo.
the class DefaultEventHandlerTest method shouldNotThrowExceptionWhenEventNotExists.
@Test
public void shouldNotThrowExceptionWhenEventNotExists() throws Exception {
// given
ViewDefinitionState viewDefinitionState = mock(ViewDefinitionState.class);
FormComponentPattern pattern = mock(FormComponentPattern.class);
given(pattern.getExpressionNew()).willReturn(null);
given(pattern.getExpressionEdit()).willReturn(null);
setField(pattern, "applicationContext", applicationContext);
FormComponentState component = new FormComponentState(pattern);
component.setFieldValue(13L);
// when
component.performEvent(viewDefinitionState, "noSuchMethod");
}
use of com.qcadoo.view.internal.components.form.FormComponentPattern in project qcadoo by qcadoo.
the class FieldEntityIdChangeListenerTest method shouldHaveFieldListeners.
@Test
public void shouldHaveFieldListeners() throws Exception {
// given
ComponentState component1 = createMockComponent("component1");
ComponentState component2 = createMockComponent("component2");
FormComponentPattern pattern = mock(FormComponentPattern.class);
given(pattern.getExpressionNew()).willReturn(null);
given(pattern.getExpressionEdit()).willReturn(null);
ApplicationContext applicationContext = mock(ApplicationContext.class);
setField(pattern, "applicationContext", applicationContext);
FormComponentState container = new FormComponentState(pattern);
container.addFieldEntityIdChangeListener("field1", (FieldEntityIdChangeListener) component1);
container.addFieldEntityIdChangeListener("field2", (FieldEntityIdChangeListener) component2);
// when
container.setFieldValue(13L);
// then
verify((FieldEntityIdChangeListener) component1).onFieldEntityIdChange(13L);
verify((FieldEntityIdChangeListener) component2).onFieldEntityIdChange(13L);
}
use of com.qcadoo.view.internal.components.form.FormComponentPattern 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.components.form.FormComponentPattern 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);
}
Aggregations