Commit c90d56b7 authored by Romain Bioteau's avatar Romain Bioteau
Browse files

BS-11320

Fix recursive algorithm
parent ebc46c4f
......@@ -88,6 +88,18 @@ public class EndingPageflowConstraintTest {
assertThat(constraintUnderTest.performBatchValidation(context).isOK()).isTrue();
}
@Test
public void shouldPerformBatchValidation_ReturnValidStatus_For_Pageflow_With_Group_And_SubmitButton() throws Exception {
final Task pageflow = ProcessFactory.eINSTANCE.createTask();
final Form formWithSubmitButton = FormFactory.eINSTANCE.createForm();
final Group group = FormFactory.eINSTANCE.createGroup();
formWithSubmitButton.getWidgets().add(group);
formWithSubmitButton.getWidgets().add(FormFactory.eINSTANCE.createSubmitFormButton());
pageflow.getForm().add(formWithSubmitButton);
when(context.getTarget()).thenReturn(pageflow);
assertThat(constraintUnderTest.performBatchValidation(context).isOK()).isTrue();
}
@Test
public void shouldPerformBatchValidation_ReturnErrorStatus_For_Pageflow_Without_SubmitButton() throws Exception {
final Task pageflow = ProcessFactory.eINSTANCE.createTask();
......
......@@ -66,13 +66,15 @@ AbstractLiveValidationMarkerConstraint {
return context.createSuccessStatus();
}
public boolean containsSubmitButton(final List<Widget> widgets){
protected boolean containsSubmitButton(final List<Widget> widgets) {
for (final Widget widget : widgets) {
if (widget instanceof SubmitFormButton){
return true;
}
if (widget instanceof Group) {
return containsSubmitButton(((Group) widget).getWidgets());
if (containsSubmitButton(((Group) widget).getWidgets())) {
return true;
}
}
}
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment