-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: unit test for pairwise resizing
- Loading branch information
Showing
1 changed file
with
57 additions
and
1 deletion.
There are no files selected for viewing
58 changes: 57 additions & 1 deletion
58
...nsee/eno/core/processing/out/steps/lunatic/resizing/LunaticPairwiseResizingLogicTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |