use of com.qcadoo.view.internal.states.AbstractContainerState in project qcadoo by qcadoo.
the class ContainerPatternTest method shouldCallCreateComponentStateOnChildren.
@Test
public void shouldCallCreateComponentStateOnChildren() throws Exception {
// given
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
InternalViewDefinitionState viewDefinitionState = mock(InternalViewDefinitionState.class);
AbstractContainerState state = new EmptyContainerState();
InternalComponentState state1 = mock(InternalComponentState.class);
given(state1.getName()).willReturn("name1");
InternalComponentState state2 = mock(InternalComponentState.class);
given(state2.getName()).willReturn("name2");
ComponentPattern pattern1 = mock(ComponentPattern.class);
given(pattern1.getName()).willReturn("name1");
given(pattern1.createComponentState(viewDefinitionState)).willReturn(state1);
ComponentPattern pattern2 = mock(ComponentPattern.class);
given(pattern2.getName()).willReturn("name2");
given(pattern2.createComponentState(viewDefinitionState)).willReturn(state2);
ContainerPatternMock parent = new ContainerPatternMock(getComponentDefinition("name", viewDefinition), state);
parent.addChild(pattern1);
parent.addChild(pattern2);
// when
ComponentState actualState = parent.createComponentState(viewDefinitionState);
// then
assertEquals(state, actualState);
verify(pattern1).createComponentState(viewDefinitionState);
verify(pattern2).createComponentState(viewDefinitionState);
verify(viewDefinitionState).registerComponent("name", actualState);
assertEquals(state1, state.getChild("name1"));
assertEquals(state2, state.getChild("name2"));
}
Aggregations