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);
}
Aggregations