ContractInputToWidgetMapper { public Component createSubmitButton(ButtonAction actionType) { ButtonWidget submitButton = parametrizedWidgetFactory.createSubmitButton(actionType); submitButton.setDataToSend(FormOutputData.NAME); submitButton.setPropertyValue("dataFromError", ParameterType.VARIABLE, SubmitErrorsListData.SUBMIT_ERROR_DATA); submitButton.setTargetUrlOnSuccess("/bonita"); submitButton.setPropertyValue("disabled", ParameterType.EXPRESSION, "$form.$invalid"); return submitButton.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_submit_button_have_contract_action() throws Exception { ContractInputToWidgetMapper contractInputToWidgetMapper = makeContractInputToWidgetMapper(); Element element = contractInputToWidgetMapper.createSubmitButton(ButtonAction.SUBMIT_TASK); assertThat(element.getPropertyValues().get("action").getValue()).isEqualTo("Submit task"); }
@Test public void should_submit_button_send_sentData_variable() throws Exception { ContractInputToWidgetMapper contractInputToWidgetMapper = makeContractInputToWidgetMapper(); Element element = contractInputToWidgetMapper.createSubmitButton(ButtonAction.SUBMIT_TASK); PropertyValue PropertyValue = element.getPropertyValues().get("dataToSend"); assertThat(PropertyValue.getType()).isEqualTo("expression"); assertThat(PropertyValue.getValue()).isEqualTo("formOutput"); }
@Test public void submit_button_should_redirect_to_bonita_on_success() throws Exception { ContractInputToWidgetMapper contractInputToWidgetMapper = makeContractInputToWidgetMapper(); Element element = contractInputToWidgetMapper.createSubmitButton(ButtonAction.SUBMIT_TASK); PropertyValue PropertyValue = element.getPropertyValues().get("targetUrlOnSuccess"); assertThat(PropertyValue.getType()).isEqualTo("interpolation"); assertThat(PropertyValue.getValue()).isEqualTo("/bonita"); }