use of com.qcadoo.view.api.ComponentState in project qcadoo by qcadoo.
the class FieldAndScopeListenerPatternTest method shouldUpdateStateScopeListeners.
@Test
public void shouldUpdateStateScopeListeners() throws Exception {
// given
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
AbstractContainerPattern parent = new ContainerPatternMock(getComponentDefinition("f1", viewDefinition));
ComponentPatternMock child1 = new ComponentPatternMock(getComponentDefinition("t1", null, "field1", parent, viewDefinition));
ComponentPatternMock child2 = new ComponentPatternMock(getComponentDefinition("t2", null, "field2", parent, viewDefinition));
parent.addChild(child1);
parent.addChild(child2);
parent.initialize();
child1.initialize();
child2.initialize();
ComponentStateMock f1State = new ComponentStateMock();
ComponentState t1State = Mockito.mock(ComponentState.class, withSettings().extraInterfaces(ScopeEntityIdChangeListener.class));
ComponentState t2State = Mockito.mock(ComponentState.class, withSettings().extraInterfaces(ScopeEntityIdChangeListener.class));
ViewDefinitionState viewDefinitions = Mockito.mock(ViewDefinitionState.class);
BDDMockito.given(viewDefinitions.getComponentByReference("f1")).willReturn(f1State);
BDDMockito.given(viewDefinitions.getComponentByReference("f1.t1")).willReturn(t1State);
BDDMockito.given(viewDefinitions.getComponentByReference("f1.t2")).willReturn(t2State);
// when
parent.updateComponentStateListeners(viewDefinitions);
// then
assertEquals(t1State, f1State.getPublicScopeFieldEntityIdChangeListeners().get("field1"));
assertEquals(t2State, f1State.getPublicScopeFieldEntityIdChangeListeners().get("field2"));
}
use of com.qcadoo.view.api.ComponentState in project qcadoo by qcadoo.
the class FieldAndScopeListenerPatternTest method shouldUpdateStateFieldListeners.
@Test
public void shouldUpdateStateFieldListeners() throws Exception {
// given
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
AbstractContainerPattern parent = new ContainerPatternMock(getComponentDefinition("f1", viewDefinition));
ComponentPatternMock child1 = new ComponentPatternMock(getComponentDefinition("t1", "field1", null, parent, viewDefinition));
ComponentPatternMock child2 = new ComponentPatternMock(getComponentDefinition("t2", "field2", null, parent, viewDefinition));
parent.addChild(child1);
parent.addChild(child2);
parent.initialize();
child1.initialize();
child2.initialize();
ComponentStateMock f1State = new ComponentStateMock();
ComponentState t1State = Mockito.mock(ComponentState.class, withSettings().extraInterfaces(FieldEntityIdChangeListener.class));
ComponentState t2State = Mockito.mock(ComponentState.class, withSettings().extraInterfaces(FieldEntityIdChangeListener.class));
ViewDefinitionState viewDefinitions = Mockito.mock(ViewDefinitionState.class);
BDDMockito.given(viewDefinitions.getComponentByReference("f1")).willReturn(f1State);
BDDMockito.given(viewDefinitions.getComponentByReference("f1.t1")).willReturn(t1State);
BDDMockito.given(viewDefinitions.getComponentByReference("f1.t2")).willReturn(t2State);
// when
parent.updateComponentStateListeners(viewDefinitions);
// then
assertEquals(t1State, f1State.getPublicFieldEntityIdChangeListeners().get("field1"));
assertEquals(t2State, f1State.getPublicFieldEntityIdChangeListeners().get("field2"));
}
use of com.qcadoo.view.api.ComponentState in project qcadoo by qcadoo.
the class ViewDefinitionStateTest method shouldReturnNullWhenStateNoExists.
@Test
public void shouldReturnNullWhenStateNoExists() throws Exception {
// given
ViewDefinitionState viewDefinitionState = new ViewDefinitionStateImpl();
// when
ComponentState actualState = viewDefinitionState.getComponentByReference("xxx");
// then
assertNull(actualState);
}
Aggregations