Skip to content

Commit

Permalink
fix(hotfix): vtl inversion regression (#1166)
Browse files Browse the repository at this point in the history
* fix(security): bump spring boot version

* chore: bump version

* ci: allow hotfix versions

* fix: regression on vtl expression inversion

* test: update tests after fix
  • Loading branch information
nsenave authored Nov 26, 2024
1 parent e21645f commit bba372d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:

- name: Get previous final release tag
id: previousTag
run: echo "previousTag=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | grep "^[3-9]\.[0-9]\+\.[0-9]\+$" | tail -1)" >> $GITHUB_OUTPUT
run: echo "previousTag=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | grep "^[3-9]\.[0-9]+\.[0-9]+(-hotfix\.\d+)?$" | tail -1)" >> $GITHUB_OUTPUT
# Note: the regex works for single digit major version, to be updated if the version goes 10.0.0 or more

- name: Create tag
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.sonarqube.gradle.SonarTask

plugins {
id("org.springframework.boot") version "3.3.5" apply false
id("org.springframework.boot") version "3.4.0" apply false
id("io.spring.dependency-management") version "1.1.6" apply false
id("application")
id("jacoco-report-aggregation")
Expand All @@ -16,7 +16,7 @@ java {

allprojects {
group = "fr.insee.eno"
version = "3.29.0"
version = "3.29.0-hotfix.1"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@ public static String concatenateStrings(String vtlString1, String vtlString2) {

/**
* Inverts the given expression (which is supposed to be a VTL expression that returns a boolean)
* by adding a 'not()' around it, or eventually removing one if the entire expression is in a "not".
* by adding a 'not()' around it.
* @param expression VTL boolean expression.
* @return The inverted VTL expression.
*/
public static String invertBooleanExpression(String expression) {
String trimmed = expression.trim();
// If the whole expression is within a not(), remove it
if (trimmed.startsWith("not(") && trimmed.endsWith(")"))
return trimmed.substring(4, trimmed.length() - 1);
// Otherwise, add a not() around the expression
return "not(" + trimmed + ")";
return "not(" + expression + ")";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void mapDDIWithRoundabout() throws DDIParsingException {
assertEquals(1, enoQuestionnaire.getFilters().size());
Filter enoFilter = enoQuestionnaire.getFilters().getFirst();
assertTrue(enoFilter.isRoundaboutFilter());
assertFalse(enoFilter.getExpression().getValue().startsWith("not"));
assertTrue(enoFilter.getExpression().getValue().startsWith("not"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void roundaboutItem() {
assertEquals("\"Occurrence description of \" || FIRST_NAME",
roundaboutItem.getDescription().getValue().stripTrailing());
assertEquals(LabelTypeEnum.VTL_MD, roundaboutItem.getDescription().getType());
assertEquals("FIRST_NAME <> FIRST_NAME_REF",
assertEquals("not(not(FIRST_NAME <> FIRST_NAME_REF))",
roundaboutItem.getDisabled().getValue().stripTrailing());
assertEquals(LabelTypeEnum.VTL, roundaboutItem.getDisabled().getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class VtlSyntaxUtilsTest {

@Test
void invertExpressions() {
assertEquals("FOO", VtlSyntaxUtils.invertBooleanExpression("not(FOO)"));
assertEquals("not(not(FOO))", VtlSyntaxUtils.invertBooleanExpression("not(FOO)"));
assertEquals("not(FOO)", VtlSyntaxUtils.invertBooleanExpression("FOO"));
assertEquals("not(FOO)", VtlSyntaxUtils.invertBooleanExpression("not(not(FOO))"));
assertEquals("FOO = 1", VtlSyntaxUtils.invertBooleanExpression("not(FOO = 1)"));
assertEquals("not(not(not(FOO)))", VtlSyntaxUtils.invertBooleanExpression("not(not(FOO))"));
assertEquals("not(not(FOO = 1))", VtlSyntaxUtils.invertBooleanExpression("not(FOO = 1)"));
assertEquals("not(FOO = 1)", VtlSyntaxUtils.invertBooleanExpression("FOO = 1"));
}

Expand Down

0 comments on commit bba372d

Please sign in to comment.