use of com.qcadoo.view.internal.FieldEntityIdChangeListener 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.FieldEntityIdChangeListener in project qcadoo by qcadoo.
the class GridComponentStateTest method shouldNotModeUpSelectedEntityOnFail.
@Test(expected = IllegalStateException.class)
public void shouldNotModeUpSelectedEntityOnFail() throws Exception {
// given
FieldEntityIdChangeListener listener = mock(FieldEntityIdChangeListener.class);
SearchResult result = mock(SearchResult.class);
given(substituteCriteria.list()).willReturn(result);
given(result.getTotalNumberOfEntities()).willReturn(0);
given(result.getEntities()).willReturn(Collections.<Entity>emptyList());
willThrow(new IllegalStateException()).given(substituteDataDefinition).move(13L, -1);
grid.initialize(json, Locale.ENGLISH);
grid.addFieldEntityIdChangeListener("field", listener);
// when
grid.performEvent(viewDefinitionState, "moveUp");
}
use of com.qcadoo.view.internal.FieldEntityIdChangeListener in project qcadoo by qcadoo.
the class GridComponentStateTest method shouldNotModeDownSelectedEntityOnFail.
@Test(expected = IllegalStateException.class)
public void shouldNotModeDownSelectedEntityOnFail() throws Exception {
// given
FieldEntityIdChangeListener listener = mock(FieldEntityIdChangeListener.class);
SearchResult result = mock(SearchResult.class);
given(substituteCriteria.list()).willReturn(result);
given(result.getTotalNumberOfEntities()).willReturn(0);
given(result.getEntities()).willReturn(Collections.<Entity>emptyList());
willThrow(new IllegalStateException()).given(substituteDataDefinition).move(13L, 1);
grid.initialize(json, Locale.ENGLISH);
grid.addFieldEntityIdChangeListener("field", listener);
// when
grid.performEvent(viewDefinitionState, "moveDown");
}
use of com.qcadoo.view.internal.FieldEntityIdChangeListener in project qcadoo by qcadoo.
the class GridComponentStateTest method shouldRefresh.
@Test
public void shouldRefresh() throws Exception {
// given
FieldEntityIdChangeListener listener = mock(FieldEntityIdChangeListener.class);
SearchResult result = mock(SearchResult.class);
given(substituteCriteria.list()).willReturn(result);
given(result.getTotalNumberOfEntities()).willReturn(0);
given(result.getEntities()).willReturn(Collections.<Entity>emptyList());
grid.initialize(json, Locale.ENGLISH);
grid.addFieldEntityIdChangeListener("field", listener);
// when
grid.performEvent(viewDefinitionState, "refresh");
}
use of com.qcadoo.view.internal.FieldEntityIdChangeListener in project qcadoo by qcadoo.
the class GridComponentStateTest method shouldSelectEntity.
@Test
public void shouldSelectEntity() throws Exception {
// given
FieldEntityIdChangeListener listener = mock(FieldEntityIdChangeListener.class);
SearchResult result = mock(SearchResult.class);
given(substituteCriteria.list()).willReturn(result);
given(result.getTotalNumberOfEntities()).willReturn(0);
given(result.getEntities()).willReturn(Collections.<Entity>emptyList());
grid.initialize(json, Locale.ENGLISH);
grid.addFieldEntityIdChangeListener("field", listener);
// when
grid.performEvent(viewDefinitionState, "select");
// then
verify(listener).onFieldEntityIdChange(13L);
}
Aggregations