Skip to content

Commit

Permalink
fix: manage all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nsenave committed Nov 18, 2024
1 parent 8e40c8d commit f9e4873
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions eno-core/src/main/java/fr/insee/eno/core/utils/LunaticUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ public static List<String> getCollectedVariablesInLoop(Loop loop) {
List<String> result = new ArrayList<>();
loop.getComponents().forEach(component -> {
switch (component.getComponentType()) {
case CHECKBOX_BOOLEAN, INPUT_NUMBER, INPUT, TEXTAREA, DATEPICKER, DURATION, RADIO,
case CHECKBOX_BOOLEAN, INPUT_NUMBER, INPUT, TEXTAREA, SUGGESTER, DATEPICKER, DURATION, RADIO,
CHECKBOX_ONE, DROPDOWN, CHECKBOX_GROUP, TABLE ->
result.addAll(getDirectResponseNames(component));
case QUESTIONNAIRE, SEQUENCE, SUBSEQUENCE, TEXT, ACCORDION ->
doNothing();
case QUESTION ->
throw new IllegalStateException("This method does not support the question component.");
case ROSTER_FOR_LOOP ->
throw new LunaticLoopException(String.format(
"Dynamic tables are forbidden in loops: loop '%s' contains a dynamic table.",
Expand All @@ -132,14 +136,15 @@ public static List<String> getCollectedVariablesInLoop(Loop loop) {
throw new LunaticLoopException(String.format(
"Pairwise components are forbidden in loops: loop '%s' contains a pairwise component.",
loop.getId()));
default ->
throw new IllegalArgumentException(
"Unexpected component type '" + component.getComponentType() + "'.");
}
});
return result;
}

private static void doNothing() {
/* No-op method */
}

/**
* Return the response name of the component that belong to the given pairwise links. This method checks if
* the inner component is valid.
Expand Down

0 comments on commit f9e4873

Please sign in to comment.