@Test
public void add_a_complex_children_components_embedded_in_a_container_when_visiting_a_multiple_complex_node_contract_input()
        throws Exception {

    Page page = new Page();
    new ContractInputVisitorImpl(page, contractInputToWidgetMapper).visit(
            (NodeContractInput) ContractInputBuilder.aNodeContractInput("complex").mulitple()
                    .withInput(
                            ContractInputBuilder.aNodeContractInput("subcomplex")
                                    .withInput(ContractInputBuilder.aStringContractInput("lastName")).build())
                    .withInput(
                            ContractInputBuilder.aNodeContractInput("subcomplexMultiple").mulitple()
                                    .withInput(ContractInputBuilder.aStringContractInput("friend")).build())
                    .build());
    assertThat(page.getRows()).hasSize(3);//one for the container label, one for the container,one for the button bar
    checkSubcomplexTitle(page.getRows().get(0), "Complex");
    List<Element> complexSecondRow = page.getRows().get(1);
    assertThat(complexSecondRow).hasSize(1);
    assertThat(complexSecondRow.get(0)).isInstanceOf(Container.class);
    Container complexContainer = (Container) complexSecondRow.get(0);
    assertThat(complexContainer.getPropertyValues())
            .contains(entry(ParameterConstants.REPEATED_COLLECTION_PARAMETER,
                    aDataPropertyValue("formInput.complex")));
    assertThat(complexContainer.getRows()).hasSize(6);
    assertThat(complexContainer.getRows().get(0)).hasSize(1);
    checkSubcomplex(complexContainer);
    checkComplexRemoveButton(complexContainer, 5);
    List<Element> thirdRow = page.getRows().get(2);
    assertThat(thirdRow).hasSize(1);
    Component addButton = (Component) thirdRow.get(0);
    assertThat(addButton.getId()).isEqualTo("pbButton");
    assertThat(addButton.getPropertyValues().get("valueToAdd").getValue()).isEqualTo("{" + System.lineSeparator() +
            "  \"subcomplex\" : {" + System.lineSeparator() +
            "    \"lastName\" : \"\"" + System.lineSeparator() +
            "  }," + System.lineSeparator() +
            "  \"subcomplexMultiple\" : [ ]" + System.lineSeparator() +
            "}");
}