Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>fr.insee.lunatic</groupId>
<artifactId>lunatic-model</artifactId>
<packaging>jar</packaging>
<version>5.11.0</version>
<version>5.12.0</version>
<name>Lunatic Model</name>
<description>Classes and converters for the Lunatic model</description>
<url>https://inseefr.github.io/Lunatic-Model/</url>
Expand Down Expand Up @@ -117,8 +117,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/fr/insee/lunatic/model/flat/PairwiseLinks.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,37 @@
"bindingDependencies",
"xAxisIterations",
"yAxisIterations",
"sourceVariables",
"components",
"symLinks"
})
@Getter
@Setter
public class PairwiseLinks
extends ComponentType
implements ComponentNestingType
{
public class PairwiseLinks extends ComponentType implements ComponentNestingType {

/**
* Variables associated with the pairwise links component.
*/
@Getter
@Setter
public static class SourceVariables {
/** Name variable name. */
private String name;
/** Gender variable name. */
private String gender;
/** Age variable name. */
private String age;
}

@JsonProperty("xAxisIterations")
protected LabelType xAxisIterations;

@JsonProperty("yAxisIterations")
protected LabelType yAxisIterations;

/** {@link SourceVariables} */
private SourceVariables sourceVariables;

protected List<ComponentType> components;
protected SymLinksType symLinks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class CleaningSerializationTest {
]
}
}
}
""";
}""";

@Test
void serializeCleaning() throws SerializationException, JSONException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package fr.insee.lunatic.conversion;

import fr.insee.lunatic.exception.SerializationException;
import fr.insee.lunatic.model.flat.PairwiseLinks;
import fr.insee.lunatic.model.flat.Questionnaire;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;

class PairwiseLinksSerializationTest {

@Test
void serializePairwiseLinks() throws SerializationException, JSONException {
//
Questionnaire questionnaire = new Questionnaire();
PairwiseLinks pairwiseLinks = new PairwiseLinks();
pairwiseLinks.setId("foo-id");
PairwiseLinks.SourceVariables sourceVariables = new PairwiseLinks.SourceVariables();
sourceVariables.setName("FIRST_NAME_VAR");
sourceVariables.setGender("GENDER_VAR");
pairwiseLinks.setSourceVariables(sourceVariables);
questionnaire.getComponents().add(pairwiseLinks);
//
String result = new JsonSerializer().serialize(questionnaire);
//
String expected = """
{
"componentType": "Questionnaire",
"components": [
{
"id": "foo-id",
"componentType": "PairwiseLinks",
"sourceVariables": {
"name": "FIRST_NAME_VAR",
"gender": "GENDER_VAR"
},
"components": []
}
]
}
""";
JSONAssert.assertEquals(expected, result, JSONCompareMode.STRICT);
}

}