diff --git a/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticPairwiseResizingLogicTest.java b/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticPairwiseResizingLogicTest.java index f3d9debc5..5ad0474c9 100644 --- a/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticPairwiseResizingLogicTest.java +++ b/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticPairwiseResizingLogicTest.java @@ -1,4 +1,60 @@ package fr.insee.eno.core.processing.out.steps.lunatic.resizing; -public class LunaticPairwiseResizingLogicTest { +import fr.insee.eno.core.model.lunatic.LunaticResizingPairwiseEntry; +import fr.insee.eno.core.model.question.PairwiseQuestion; +import fr.insee.eno.core.reference.EnoIndex; +import fr.insee.lunatic.model.flat.*; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class LunaticPairwiseResizingLogicTest { + + @Test + void pairwiseResizingTest() { + // + Questionnaire lunaticQuestionnaire = new Questionnaire(); + // + PairwiseLinks lunaticPairwise = new PairwiseLinks(); + lunaticPairwise.setId("pairwise-id"); + lunaticPairwise.setXAxisIterations(new LabelType()); + lunaticPairwise.getXAxisIterations().setValue("count(LOOP_VAR)"); + lunaticPairwise.setYAxisIterations(new LabelType()); + lunaticPairwise.getYAxisIterations().setValue("count(LOOP_VAR)"); + Dropdown dropdown = new Dropdown(); + dropdown.setComponentType(ComponentTypeEnum.DROPDOWN); + dropdown.setResponse(new ResponseType()); + dropdown.getResponse().setName("LINKS_VAR"); + lunaticPairwise.getComponents().add(dropdown); + lunaticQuestionnaire.getComponents().add(lunaticPairwise); + // + VariableType loopVariable = new VariableType(); + loopVariable.setVariableType(VariableTypeEnum.COLLECTED); + loopVariable.setName("LOOP_VAR"); + lunaticQuestionnaire.getVariables().add(loopVariable); + + // + PairwiseQuestion enoPairwise = new PairwiseQuestion(); + enoPairwise.setId("pairwise-id"); + enoPairwise.setLoopVariableName("LOOP_VAR"); + + // + EnoIndex enoIndex = new EnoIndex(); + enoIndex.put("pairwise-id", enoPairwise); + + // When + LunaticPairwiseResizingLogic pairwiseResizingLogic = new LunaticPairwiseResizingLogic( + lunaticQuestionnaire, enoIndex); + List pairwiseResizingEntries = pairwiseResizingLogic + .buildPairwiseResizingEntries(lunaticPairwise); + + // Test + assertEquals(1, pairwiseResizingEntries.size()); + assertEquals("LOOP_VAR", pairwiseResizingEntries.get(0).getName()); + assertEquals(List.of("count(LOOP_VAR)", "count(LOOP_VAR)"), pairwiseResizingEntries.get(0).getSizeForLinksVariables()); + assertEquals(List.of("LINKS_VAR"), pairwiseResizingEntries.get(0).getLinksVariables()); + } + }