Skip to content

Commit

Permalink
test: unit test for pairwise resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
nsenave committed Sep 21, 2023
1 parent f5b3c23 commit cd7514f
Showing 1 changed file with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<LunaticResizingPairwiseEntry> 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());
}

}

0 comments on commit cd7514f

Please sign in to comment.