Search in sources :

Example 1 with ScopeEntityIdChangeListener

use of com.qcadoo.view.internal.ScopeEntityIdChangeListener in project qcadoo by qcadoo.

the class ScopeEntityIdChangeListenerTest method shouldHaveScopeListeners.

@Test
public void shouldHaveScopeListeners() 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.addScopeEntityIdChangeListener("component1", (ScopeEntityIdChangeListener) component1);
    container.addScopeEntityIdChangeListener("component2", (ScopeEntityIdChangeListener) component2);
    // when
    container.setFieldValue(13L);
    // then
    verify((ScopeEntityIdChangeListener) component1).onScopeEntityIdChange(13L);
    verify((ScopeEntityIdChangeListener) component2).onScopeEntityIdChange(13L);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) FormComponentPattern(com.qcadoo.view.internal.components.form.FormComponentPattern) ScopeEntityIdChangeListener(com.qcadoo.view.internal.ScopeEntityIdChangeListener) ComponentState(com.qcadoo.view.api.ComponentState) FormComponentState(com.qcadoo.view.internal.components.form.FormComponentState) FormComponentState(com.qcadoo.view.internal.components.form.FormComponentState) Test(org.junit.Test)

Aggregations

ComponentState (com.qcadoo.view.api.ComponentState)1 ScopeEntityIdChangeListener (com.qcadoo.view.internal.ScopeEntityIdChangeListener)1 FormComponentPattern (com.qcadoo.view.internal.components.form.FormComponentPattern)1 FormComponentState (com.qcadoo.view.internal.components.form.FormComponentState)1 Test (org.junit.Test)1 ApplicationContext (org.springframework.context.ApplicationContext)1