Skip to content

Commit

Permalink
fix: null pointer exception with non collected cells in dynamic table (
Browse files Browse the repository at this point in the history
  • Loading branch information
nsenave committed Jan 15, 2025
1 parent da1681c commit 3fea381
Show file tree
Hide file tree
Showing 4 changed files with 685 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ java {

allprojects {
group = "fr.insee.eno"
version = "3.32.0-SNAPSHOT.1"
version = "3.32.1-SNAPSHOT"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import fr.insee.lunatic.model.flat.variable.VariableType;
import fr.insee.lunatic.model.flat.variable.VariableTypeEnum;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

import static fr.insee.eno.core.processing.out.steps.lunatic.resizing.LunaticLoopResizingLogic.insertIterationEntry;
Expand Down Expand Up @@ -48,7 +45,10 @@ public void buildResizingEntries(RosterForLoop lunaticRoster, ResizingType lunat

// Concerned variables to be resized: responses of the roster component
List<String> resizedVariableNames = lunaticRoster.getComponents().stream()
.map(BodyCell::getResponse).map(ResponseType::getName).toList();
.map(BodyCell::getResponse)
.filter(Objects::nonNull)
.map(ResponseType::getName)
.toList();

// Insert resizing entries (the logic is the same as for loops)
resizingVariableNames.forEach(variableName -> insertIterationEntry(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package fr.insee.eno.core.processing.out.steps.lunatic.resizing;

import fr.insee.eno.core.DDIToEno;
import fr.insee.eno.core.DDIToLunatic;
import fr.insee.eno.core.exceptions.business.DDIParsingException;
import fr.insee.eno.core.mappers.LunaticMapper;
import fr.insee.eno.core.model.EnoQuestionnaire;
import fr.insee.eno.core.model.calculated.BindingReference;
import fr.insee.eno.core.model.calculated.CalculatedExpression;
import fr.insee.eno.core.model.question.DynamicTableQuestion;
import fr.insee.eno.core.parameter.EnoParameters;
import fr.insee.eno.core.parameter.Format;
import fr.insee.eno.core.processing.out.steps.lunatic.LunaticLoopResolution;
import fr.insee.eno.core.processing.out.steps.lunatic.LunaticSortComponents;
import fr.insee.eno.core.processing.out.steps.lunatic.table.LunaticTableProcessing;
Expand All @@ -16,9 +18,11 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.math.BigInteger;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;

class LunaticRosterResizingLogicTest {
Expand Down Expand Up @@ -125,4 +129,16 @@ void integrationTest() throws DDIParsingException {
lunaticResizing.getResizingEntry("HOW_MANY").getVariables());
}

@Test
void nonCollectedColumnCase_functionalTest() {
// Given
EnoParameters enoParameters = EnoParameters.of(
EnoParameters.Context.HOUSEHOLD, EnoParameters.ModeParameter.CAWI, Format.LUNATIC);
InputStream ddiInputStream = this.getClass().getClassLoader().getResourceAsStream(
"functional/ddi/ddi-m5o3qhu0.xml"); // DDI with non-collected column within a dynamic table
// When + then
DDIToLunatic ddiToLunatic = new DDIToLunatic();
assertDoesNotThrow(() -> ddiToLunatic.transform(ddiInputStream, enoParameters));
}

}
Loading

0 comments on commit 3fea381

Please sign in to comment.