-
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.
feat(pogues mapping): questionnaire properties (#1184)
* feat(pogues mapping): questionnaire model * feat(pogues mapping): agency metadata * feat(pogues mapping): questionnaire label * feat(pogues mapping): filter and language check * test(pogues mapping): questionnaire properties
- Loading branch information
Showing
10 changed files
with
205 additions
and
5 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...re/src/main/java/fr/insee/eno/core/exceptions/business/IllegalPoguesElementException.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package fr.insee.eno.core.exceptions.business; | ||
|
||
public class IllegalPoguesElementException extends RuntimeException { | ||
|
||
public IllegalPoguesElementException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
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
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
16 changes: 16 additions & 0 deletions
16
...main/java/fr/insee/eno/core/processing/in/steps/pogues/PoguesCheckExpressionLanguage.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fr.insee.eno.core.processing.in.steps.pogues; | ||
|
||
import fr.insee.eno.core.exceptions.business.IllegalPoguesElementException; | ||
import fr.insee.eno.core.model.EnoQuestionnaire; | ||
import fr.insee.eno.core.processing.ProcessingStep; | ||
|
||
public class PoguesCheckExpressionLanguage implements ProcessingStep<EnoQuestionnaire> { | ||
@Override | ||
public void apply(EnoQuestionnaire enoQuestionnaire) { | ||
String expressionLanguage = enoQuestionnaire.getExpressionLanguage(); | ||
if (expressionLanguage == null) // if this property is missing it's alright, might be removed later on anyway | ||
return; | ||
if (!"VTL".equals(expressionLanguage)) | ||
throw new IllegalPoguesElementException("'" + expressionLanguage + "' expression language is not allowed."); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ore/src/main/java/fr/insee/eno/core/processing/in/steps/pogues/PoguesCheckFilterMode.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fr.insee.eno.core.processing.in.steps.pogues; | ||
|
||
import fr.insee.eno.core.exceptions.business.IllegalPoguesElementException; | ||
import fr.insee.eno.core.model.EnoQuestionnaire; | ||
import fr.insee.eno.core.processing.ProcessingStep; | ||
|
||
public class PoguesCheckFilterMode implements ProcessingStep<EnoQuestionnaire> { | ||
@Override | ||
public void apply(EnoQuestionnaire enoQuestionnaire) { | ||
String filterMode = enoQuestionnaire.getFilterMode(); | ||
if (filterMode == null) // if this property is missing it's alright, might be removed later on anyway | ||
return; | ||
if (!"FILTER".equals(filterMode)) | ||
throw new IllegalPoguesElementException("'" + filterMode + "' filter mode is not allowed."); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
.../java/fr/insee/eno/core/processing/in/steps/pogues/PoguesCheckExpressionLanguageTest.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package fr.insee.eno.core.processing.in.steps.pogues; | ||
|
||
import fr.insee.eno.core.exceptions.business.IllegalPoguesElementException; | ||
import fr.insee.eno.core.mappers.PoguesMapper; | ||
import fr.insee.eno.core.model.EnoQuestionnaire; | ||
import fr.insee.pogues.model.FormulasLanguageEnum; | ||
import fr.insee.pogues.model.Questionnaire; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class PoguesCheckExpressionLanguageTest { | ||
|
||
@Test | ||
void validValue() { | ||
// | ||
Questionnaire poguesQuestionnaire = new Questionnaire(); | ||
poguesQuestionnaire.setFormulasLanguage(FormulasLanguageEnum.VTL); | ||
EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); | ||
// | ||
new PoguesMapper().mapPoguesQuestionnaire(poguesQuestionnaire, enoQuestionnaire); | ||
// | ||
PoguesCheckExpressionLanguage processing = new PoguesCheckExpressionLanguage(); | ||
assertDoesNotThrow(() -> processing.apply(enoQuestionnaire)); | ||
} | ||
|
||
@Test | ||
void invalidValue_shouldThrow() { | ||
// | ||
Questionnaire poguesQuestionnaire = new Questionnaire(); | ||
poguesQuestionnaire.setFormulasLanguage(FormulasLanguageEnum.XPATH); | ||
EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); | ||
// | ||
new PoguesMapper().mapPoguesQuestionnaire(poguesQuestionnaire, enoQuestionnaire); | ||
// | ||
PoguesCheckExpressionLanguage processing = new PoguesCheckExpressionLanguage(); | ||
assertThrows(IllegalPoguesElementException.class, () -> processing.apply(enoQuestionnaire)); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...src/test/java/fr/insee/eno/core/processing/in/steps/pogues/PoguesCheckFilterModeTest.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package fr.insee.eno.core.processing.in.steps.pogues; | ||
|
||
import fr.insee.eno.core.exceptions.business.IllegalPoguesElementException; | ||
import fr.insee.eno.core.mappers.PoguesMapper; | ||
import fr.insee.eno.core.model.EnoQuestionnaire; | ||
import fr.insee.pogues.model.FlowLogicEnum; | ||
import fr.insee.pogues.model.Questionnaire; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class PoguesCheckFilterModeTest { | ||
|
||
@Test | ||
void validValue() { | ||
// | ||
Questionnaire poguesQuestionnaire = new Questionnaire(); | ||
poguesQuestionnaire.setFlowLogic(FlowLogicEnum.FILTER); | ||
EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); | ||
// | ||
new PoguesMapper().mapPoguesQuestionnaire(poguesQuestionnaire, enoQuestionnaire); | ||
// | ||
PoguesCheckFilterMode processing = new PoguesCheckFilterMode(); | ||
assertDoesNotThrow(() -> processing.apply(enoQuestionnaire)); | ||
} | ||
|
||
@Test | ||
void invalidValue_shouldThrow() { | ||
// | ||
Questionnaire poguesQuestionnaire = new Questionnaire(); | ||
poguesQuestionnaire.setFlowLogic(FlowLogicEnum.REDIRECTION); | ||
EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire(); | ||
// | ||
new PoguesMapper().mapPoguesQuestionnaire(poguesQuestionnaire, enoQuestionnaire); | ||
// | ||
PoguesCheckFilterMode processing = new PoguesCheckFilterMode(); | ||
assertThrows(IllegalPoguesElementException.class, () -> processing.apply(enoQuestionnaire)); | ||
} | ||
|
||
} |
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
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