ContractInputToWidgetMapper { public Component createAddButton(ContractInput contractInput) { ButtonWidget addButton = parametrizedWidgetFactory.createAddButton(contractInput); if (contractHasInput(contractInput)) { addButton.setValueToAdd(getValueToAddFromContract(contractInput)); } return addButton.toComponent(dimensionFactory); } @Inject  ContractInputToWidgetMapper(DimensionFactory dimensionFactory, JacksonObjectMapper objectMapperWrapper); Element toElement(ContractInput contractInput, List<List<Element>> rows); Element toDocument(LeafContractInput contractInput); Container toContainer(NodeContractInput nodeContractInput, List<List<Element>> rows); Component createSubmitButton(ButtonAction actionType); Component createSubmitErrorAlert(); boolean canCreateComponent(ContractInput contractInput); Component createRemoveButton(); Component createAddButton(ContractInput contractInput);  }
@Test public void should_configure_collection_property_of_add_button_with_iterator_if_in_a_repeated_container() throws Exception { ContractInputToWidgetMapper contractInputToWidgetMapper = makeContractInputToWidgetMapper(); ContractInput skills = aNodeContractInput("skills") .withDataReference( new BusinessDataReference("skills", "org.test.Skill", RelationType.COMPOSITION, LoadingType.EAGER)) .mulitple().build(); aNodeContractInput("employee").mulitple().withInput(skills); Component button = contractInputToWidgetMapper.createAddButton(skills); PropertyValue labelValue = button.getPropertyValues().get("label"); assertThat(labelValue.getValue()).isEqualTo("<span class=\"glyphicon glyphicon-plus\"></span> Add Skill"); PropertyValue repeatedCollectionPropetyValue = button.getPropertyValues().get("collectionToModify"); assertThat(repeatedCollectionPropetyValue.getType()).isEqualTo("variable"); assertThat(repeatedCollectionPropetyValue.getValue()).isEqualTo("$item.skills"); }