From 8927b635d9fee2192b1c0d0d6461a802a1f34409 Mon Sep 17 00:00:00 2001 From: Nicolas Senave Date: Thu, 26 Oct 2023 19:17:23 +0200 Subject: [PATCH 1/7] fix: end questions labels and numbering --- .../core/processing/common/EnoProcessing.java | 15 ++++++++----- .../common/steps/EnoAddCommentSection.java | 7 ++++++ .../steps/EnoAddPrefixInQuestionLabels.java | 22 ++++++++++++------- .../steps/EnoAddResponseTimeSection.java | 7 ++++++ 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/eno-core/src/main/java/fr/insee/eno/core/processing/common/EnoProcessing.java b/eno-core/src/main/java/fr/insee/eno/core/processing/common/EnoProcessing.java index c6c44179a..6e44cfebc 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/processing/common/EnoProcessing.java +++ b/eno-core/src/main/java/fr/insee/eno/core/processing/common/EnoProcessing.java @@ -22,18 +22,21 @@ public void applyProcessing(EnoQuestionnaire enoQuestionnaire) { EnoIndex enoIndex = enoQuestionnaire.getIndex(); assert enoIndex != null; EnoCatalog enoCatalog = new EnoCatalog(enoQuestionnaire); + // ProcessingPipeline processingPipeline = new ProcessingPipeline<>(); processingPipeline.start(enoQuestionnaire) .thenIf(parameters.isIdentificationQuestion(), new EnoAddIdentificationSection()) - .thenIf(parameters.isResponseTimeQuestion(), new EnoAddResponseTimeSection()) - .thenIf(parameters.isCommentSection(), new EnoAddCommentSection()) .then(new EnoModeSelection(parameters.getSelectedModes(), enoCatalog)) .thenIf(parameters.isSequenceNumbering(), new EnoAddNumberingInSequences( - parameters.getModeParameter())) - .then(new EnoAddPrefixInQuestionLabels( - parameters.isArrowCharInQuestions(), parameters.getQuestionNumberingMode(), - parameters.getModeParameter())) + parameters.getModeParameter())); + // This step will be re-used after for question numbering reasons + EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( + parameters.isArrowCharInQuestions(), parameters.getQuestionNumberingMode(), + parameters.getModeParameter()); + processingPipeline.then(prefixingStep) + .thenIf(parameters.isResponseTimeQuestion(), new EnoAddResponseTimeSection(prefixingStep)) + .thenIf(parameters.isCommentSection(), new EnoAddCommentSection(prefixingStep)) .then(new EnoInsertComponentFilters()) .then(new EnoResolveBindingReferences()); } diff --git a/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSection.java b/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSection.java index 8310d964c..b9277857e 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSection.java +++ b/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSection.java @@ -25,6 +25,12 @@ public class EnoAddCommentSection implements ProcessingStep { public static final boolean COMMENT_QUESTION_MANDATORY = false; public static final int COMMENT_QUESTION_LENGTH = 2000; + private final EnoAddPrefixInQuestionLabels prefixingStep; + + public EnoAddCommentSection(EnoAddPrefixInQuestionLabels prefixingStep) { + this.prefixingStep = prefixingStep; + } + public void apply(EnoQuestionnaire enoQuestionnaire) { // EnoIndex enoIndex = enoQuestionnaire.getIndex(); @@ -49,6 +55,7 @@ public void apply(EnoQuestionnaire enoQuestionnaire) { commentQuestion.setName(COMMENT_VARIABLE_NAME); commentQuestion.setLabel(new DynamicLabel()); commentQuestion.getLabel().setValue(COMMENT_QUESTION_LABEL); + prefixingStep.addPrefixInQuestionLabel(commentQuestion); commentQuestion.setMandatory(COMMENT_QUESTION_MANDATORY); commentQuestion.setLengthType(TextQuestion.qualifyLength(COMMENT_QUESTION_LENGTH)); commentQuestion.setMaxLength(BigInteger.valueOf(COMMENT_QUESTION_LENGTH)); diff --git a/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddPrefixInQuestionLabels.java b/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddPrefixInQuestionLabels.java index e72e4ae95..1ce7d89e6 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddPrefixInQuestionLabels.java +++ b/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddPrefixInQuestionLabels.java @@ -24,6 +24,8 @@ public class EnoAddPrefixInQuestionLabels implements ProcessingStep getSequenceComponentIds(AbstractSequence sequence) { return sequence.getSequenceStructure().stream().map(StructureItemReference::getId).toList(); } - private void addPrefixInQuestionLabel(Question question, int questionNumber) { + public void addPrefixInQuestionLabel(Question question) { + if (prefixingDisabled()) + return; DynamicLabel questionLabel = question.getLabel(); questionLabel.setValue(addPrefixInLabel(questionLabel.getValue(), questionNumber)); + questionNumber ++; } private String addPrefixInLabel(String questionLabelValue, int questionNumber) { diff --git a/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSection.java b/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSection.java index c3de3d702..b0ce0ef4b 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSection.java +++ b/eno-core/src/main/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSection.java @@ -35,6 +35,12 @@ public class EnoAddResponseTimeSection implements ProcessingStep Date: Thu, 26 Oct 2023 19:18:41 +0200 Subject: [PATCH 2/7] fix: lunatic response time questions pagination --- .../processing/out/LunaticProcessing.java | 1 + ...LunaticResponseTimeQuestionPagination.java | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPagination.java diff --git a/eno-core/src/main/java/fr/insee/eno/core/processing/out/LunaticProcessing.java b/eno-core/src/main/java/fr/insee/eno/core/processing/out/LunaticProcessing.java index e507fe739..594fcc86c 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/processing/out/LunaticProcessing.java +++ b/eno-core/src/main/java/fr/insee/eno/core/processing/out/LunaticProcessing.java @@ -45,6 +45,7 @@ public void applyProcessing(Questionnaire lunaticQuestionnaire, EnoQuestionnaire .then(new LunaticAddResizing(enoQuestionnaire)) .then(new LunaticAddHierarchy()) .then(new LunaticAddPageNumbers(parameters.getLunaticPaginationMode())) + .then(new LunaticResponseTimeQuestionPagination()) .then(new LunaticAddCleaningVariables()) .thenIf(parameters.isControls(), new LunaticAddControlFormat()) .then(new LunaticReverseConsistencyControlLabel()) diff --git a/eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPagination.java b/eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPagination.java new file mode 100644 index 000000000..260c914e3 --- /dev/null +++ b/eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPagination.java @@ -0,0 +1,25 @@ +package fr.insee.eno.core.processing.out.steps.lunatic; + +import fr.insee.eno.core.processing.ProcessingStep; +import fr.insee.eno.core.processing.common.steps.EnoAddResponseTimeSection; +import fr.insee.lunatic.model.flat.ComponentType; +import fr.insee.lunatic.model.flat.Questionnaire; + +import java.util.Optional; + +public class LunaticResponseTimeQuestionPagination implements ProcessingStep { + + @Override + public void apply(Questionnaire lunaticQuestionnaire) { + Optional hoursQuestionComponent = lunaticQuestionnaire.getComponents().stream() + .filter(component -> EnoAddResponseTimeSection.HOURS_QUESTION_ID.equals(component.getId())) + .findAny(); + if (hoursQuestionComponent.isPresent()) { + String pageNumber = hoursQuestionComponent.get().getPage(); + int hoursQuestionComponentIndex = lunaticQuestionnaire.getComponents().indexOf(hoursQuestionComponent.get()); + // minutes question is just after the hours question + lunaticQuestionnaire.getComponents().get(hoursQuestionComponentIndex + 1).setPage(pageNumber); + } + } + +} From 6116eaf3e4266cd383339ddfce9762ca4ed7bfe7 Mon Sep 17 00:00:00 2001 From: Nicolas Senave Date: Thu, 26 Oct 2023 19:20:20 +0200 Subject: [PATCH 3/7] test: response time questions label --- .../steps/EnoAddResponseTimeSectionTest.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java b/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java index facb71426..f9b1a976f 100644 --- a/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java +++ b/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java @@ -4,18 +4,90 @@ import fr.insee.eno.core.DDIToLunatic; import fr.insee.eno.core.exceptions.business.DDIParsingException; import fr.insee.eno.core.model.EnoQuestionnaire; +import fr.insee.eno.core.model.question.NumericQuestion; import fr.insee.eno.core.model.sequence.Sequence; import fr.insee.eno.core.parameter.EnoParameters; import fr.insee.eno.core.parameter.Format; +import fr.insee.eno.core.reference.EnoIndex; import fr.insee.lunatic.model.flat.Questionnaire; import org.junit.jupiter.api.Test; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; class EnoAddResponseTimeSectionTest { + @Test + void hoursQuestionLabel_noPrefix() { + // Given + EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); + enoQuestionnaire.setIndex(new EnoIndex()); + EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( + false, EnoParameters.QuestionNumberingMode.NONE, EnoParameters.ModeParameter.PROCESS); + EnoAddResponseTimeSection processing = new EnoAddResponseTimeSection(prefixingStep); + // When + processing.apply(enoQuestionnaire); + // Then + Optional hoursQuestion = enoQuestionnaire.getSingleResponseQuestions().stream() + .filter(NumericQuestion.class::isInstance) + .map(NumericQuestion.class::cast) + .filter(singleResponseQuestion -> EnoAddResponseTimeSection.HOURS_QUESTION_ID.equals(singleResponseQuestion.getId())) + .findAny(); + Optional minutesQuestion = enoQuestionnaire.getSingleResponseQuestions().stream() + .filter(NumericQuestion.class::isInstance) + .map(NumericQuestion.class::cast) + .filter(singleResponseQuestion -> EnoAddResponseTimeSection.MINUTES_QUESTION_ID.equals(singleResponseQuestion.getId())) + .findAny(); + assertTrue(hoursQuestion.isPresent()); + assertTrue(minutesQuestion.isPresent()); + assertEquals(EnoAddResponseTimeSection.RESPONSE_TIME_QUESTION_LABEL, hoursQuestion.get().getLabel().getValue()); + assertEquals("", minutesQuestion.get().getLabel().getValue()); + } + + @Test + void hoursQuestionLabel_arrowPrefix() { + // Given + EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); + enoQuestionnaire.setIndex(new EnoIndex()); + EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( + true, EnoParameters.QuestionNumberingMode.NONE, EnoParameters.ModeParameter.PROCESS); + EnoAddResponseTimeSection processing = new EnoAddResponseTimeSection(prefixingStep); + // When + processing.apply(enoQuestionnaire); + // Then + Optional hoursQuestion = enoQuestionnaire.getSingleResponseQuestions().stream() + .filter(NumericQuestion.class::isInstance) + .map(NumericQuestion.class::cast) + .filter(singleResponseQuestion -> EnoAddResponseTimeSection.HOURS_QUESTION_ID.equals(singleResponseQuestion.getId())) + .findAny(); + assertTrue(hoursQuestion.isPresent()); + String expected = "\"➡ \" || " + EnoAddResponseTimeSection.RESPONSE_TIME_QUESTION_LABEL; + assertEquals(expected, hoursQuestion.get().getLabel().getValue()); + } + + @Test + void hoursQuestionLabel_arrowAndNumberPrefix() { + // Given + EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); + enoQuestionnaire.setIndex(new EnoIndex()); + EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( + true, EnoParameters.QuestionNumberingMode.NONE, EnoParameters.ModeParameter.PROCESS); + EnoAddResponseTimeSection processing = new EnoAddResponseTimeSection(prefixingStep); + // When + processing.apply(enoQuestionnaire); + // Then + Optional hoursQuestion = enoQuestionnaire.getSingleResponseQuestions().stream() + .filter(NumericQuestion.class::isInstance) + .map(NumericQuestion.class::cast) + .filter(singleResponseQuestion -> EnoAddResponseTimeSection.HOURS_QUESTION_ID.equals(singleResponseQuestion.getId())) + .findAny(); + assertTrue(hoursQuestion.isPresent()); + String expected = "\"➡ 1. \" || " + EnoAddResponseTimeSection.RESPONSE_TIME_QUESTION_LABEL; + assertEquals(expected, hoursQuestion.get().getLabel().getValue()); + } + @Test void integrationTest() throws DDIParsingException { // From 1db0d615e6783f92b99cf88b73cc6a5e07cc63aa Mon Sep 17 00:00:00 2001 From: Nicolas Senave Date: Thu, 26 Oct 2023 19:20:54 +0200 Subject: [PATCH 4/7] test: lunatic response time questions pagination --- ...ticResponseTimeQuestionPaginationTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPaginationTest.java diff --git a/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPaginationTest.java b/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPaginationTest.java new file mode 100644 index 000000000..03bcb02ee --- /dev/null +++ b/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/LunaticResponseTimeQuestionPaginationTest.java @@ -0,0 +1,51 @@ +package fr.insee.eno.core.processing.out.steps.lunatic; + +import fr.insee.eno.core.mappers.LunaticMapper; +import fr.insee.eno.core.model.EnoQuestionnaire; +import fr.insee.eno.core.parameter.EnoParameters; +import fr.insee.eno.core.processing.common.steps.EnoAddPrefixInQuestionLabels; +import fr.insee.eno.core.processing.common.steps.EnoAddResponseTimeSection; +import fr.insee.eno.core.processing.out.steps.lunatic.pagination.LunaticAddPageNumbers; +import fr.insee.eno.core.reference.EnoIndex; +import fr.insee.lunatic.model.flat.ComponentType; +import fr.insee.lunatic.model.flat.Questionnaire; +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class LunaticResponseTimeQuestionPaginationTest { + + @Test + void questionPaginationMode_hoursAndMinutesQuestionShouldHaveTheSameNumber() { + // Given + EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); + enoQuestionnaire.setIndex(new EnoIndex()); + new EnoAddResponseTimeSection(new EnoAddPrefixInQuestionLabels( + true, EnoParameters.QuestionNumberingMode.NONE, EnoParameters.ModeParameter.CAWI)) + .apply(enoQuestionnaire); + // + Questionnaire lunaticQuestionnaire = new Questionnaire(); + LunaticMapper lunaticMapper = new LunaticMapper(); + lunaticMapper.mapQuestionnaire(enoQuestionnaire, lunaticQuestionnaire); + // + new LunaticAddPageNumbers(EnoParameters.LunaticPaginationMode.QUESTION).apply(lunaticQuestionnaire); + + // When + new LunaticResponseTimeQuestionPagination().apply(lunaticQuestionnaire); + + // Then + Optional hoursQuestionComponent = lunaticQuestionnaire.getComponents().stream() + .filter(component -> EnoAddResponseTimeSection.HOURS_QUESTION_ID.equals(component.getId())) + .findAny(); + Optional minutesQuestionComponent = lunaticQuestionnaire.getComponents().stream() + .filter(component -> EnoAddResponseTimeSection.MINUTES_QUESTION_ID.equals(component.getId())) + .findAny(); + assertTrue(hoursQuestionComponent.isPresent()); + assertTrue(minutesQuestionComponent.isPresent()); + assertThat(hoursQuestionComponent.get().getPage()).isEqualTo(minutesQuestionComponent.get().getPage()); + } + +} From c13169714c909fe9286157c9b5baeec5d191a099 Mon Sep 17 00:00:00 2001 From: nsenave Date: Thu, 26 Oct 2023 21:34:36 +0200 Subject: [PATCH 5/7] test: prefixing step apply --- .../common/steps/EnoAddResponseTimeSectionTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java b/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java index f9b1a976f..dd8baf7ea 100644 --- a/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java +++ b/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddResponseTimeSectionTest.java @@ -26,6 +26,7 @@ void hoursQuestionLabel_noPrefix() { enoQuestionnaire.setIndex(new EnoIndex()); EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( false, EnoParameters.QuestionNumberingMode.NONE, EnoParameters.ModeParameter.PROCESS); + prefixingStep.apply(enoQuestionnaire); EnoAddResponseTimeSection processing = new EnoAddResponseTimeSection(prefixingStep); // When processing.apply(enoQuestionnaire); @@ -53,6 +54,7 @@ void hoursQuestionLabel_arrowPrefix() { enoQuestionnaire.setIndex(new EnoIndex()); EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( true, EnoParameters.QuestionNumberingMode.NONE, EnoParameters.ModeParameter.PROCESS); + prefixingStep.apply(enoQuestionnaire); EnoAddResponseTimeSection processing = new EnoAddResponseTimeSection(prefixingStep); // When processing.apply(enoQuestionnaire); @@ -73,7 +75,8 @@ void hoursQuestionLabel_arrowAndNumberPrefix() { EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); enoQuestionnaire.setIndex(new EnoIndex()); EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( - true, EnoParameters.QuestionNumberingMode.NONE, EnoParameters.ModeParameter.PROCESS); + true, EnoParameters.QuestionNumberingMode.SEQUENCE, EnoParameters.ModeParameter.PROCESS); + prefixingStep.apply(enoQuestionnaire); EnoAddResponseTimeSection processing = new EnoAddResponseTimeSection(prefixingStep); // When processing.apply(enoQuestionnaire); From 653ac943d4e2d3c5be46d6cf476e9c80816e4c1b Mon Sep 17 00:00:00 2001 From: nsenave Date: Thu, 26 Oct 2023 21:35:31 +0200 Subject: [PATCH 6/7] chore: bump version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a1f5dd1c8..7bfaa7429 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { allprojects { group = 'fr.insee.eno' - version = '3.11.6-SNAPSHOT' + version = '3.11.7-SNAPSHOT' sourceCompatibility = '17' } From 7c9376227190a05fcb0b7b0ac8b30a6cc042ba0f Mon Sep 17 00:00:00 2001 From: nsenave Date: Thu, 26 Oct 2023 21:54:04 +0200 Subject: [PATCH 7/7] test: comment section label --- .../steps/EnoAddCommentSectionTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSectionTest.java b/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSectionTest.java index c80376c35..5a7fa5d05 100644 --- a/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSectionTest.java +++ b/eno-core/src/test/java/fr/insee/eno/core/processing/common/steps/EnoAddCommentSectionTest.java @@ -4,18 +4,57 @@ import fr.insee.eno.core.DDIToLunatic; import fr.insee.eno.core.exceptions.business.DDIParsingException; import fr.insee.eno.core.model.EnoQuestionnaire; +import fr.insee.eno.core.model.label.DynamicLabel; +import fr.insee.eno.core.model.question.TextQuestion; import fr.insee.eno.core.model.sequence.Sequence; +import fr.insee.eno.core.model.sequence.StructureItemReference; import fr.insee.eno.core.parameter.EnoParameters; import fr.insee.eno.core.parameter.Format; +import fr.insee.eno.core.reference.EnoIndex; import fr.insee.lunatic.model.flat.Questionnaire; import org.junit.jupiter.api.Test; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; class EnoAddCommentSectionTest { + @Test + void commentQuestionLabel_arrowAndNumberPrefix() { + // Given a questionnaire with one question + EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); + enoQuestionnaire.setIndex(new EnoIndex()); + Sequence sequence = new Sequence(); + sequence.getSequenceStructure().add( + new StructureItemReference("question-id", StructureItemReference.StructureItemType.QUESTION)); + TextQuestion question = new TextQuestion(); + question.setId("question-id"); + question.setLabel(new DynamicLabel()); + question.getLabel().setValue("\"Foo label\""); + enoQuestionnaire.getIndex().put("question-id", question); + enoQuestionnaire.getSequences().add(sequence); + enoQuestionnaire.getSingleResponseQuestions().add(question); + // + EnoAddPrefixInQuestionLabels prefixingStep = new EnoAddPrefixInQuestionLabels( + true, EnoParameters.QuestionNumberingMode.ALL, EnoParameters.ModeParameter.PROCESS); + prefixingStep.apply(enoQuestionnaire); + + // When + new EnoAddCommentSection(prefixingStep).apply(enoQuestionnaire); + + // Then + Optional commentQuestion = enoQuestionnaire.getSingleResponseQuestions().stream() + .filter(TextQuestion.class::isInstance) + .map(TextQuestion.class::cast) + .filter(singleResponseQuestion -> EnoAddCommentSection.COMMENT_QUESTION_ID.equals(singleResponseQuestion.getId())) + .findAny(); + assertTrue(commentQuestion.isPresent()); + String expected = "\"➡ 2. \" || " + EnoAddCommentSection.COMMENT_QUESTION_LABEL; + assertEquals(expected, commentQuestion.get().getLabel().getValue()); + } + @Test void integrationTest() throws DDIParsingException { //