-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Converter is now version-aware (#116)
* Added comparison tooling for semver * Adjusted message to respect platform version * Terminate End Event is supported in 8.1.0 * Created new message for inclusive gateway * Inclusive gateway forking is supported in 8.1.0 * Changed default version to 8.1.0 * Added platformVersion parameter to REST and CLI * Adjusted docs * Adjusted message and behaviour * formatter
- Loading branch information
1 parent
15b5936
commit f3c1308
Showing
20 changed files
with
370 additions
and
31 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
...converter/core/src/main/java/org/camunda/community/converter/version/SemanticVersion.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,18 @@ | ||
package org.camunda.community.converter.version; | ||
|
||
public enum SemanticVersion { | ||
_8_0_0("8.0.0"), | ||
_8_1_0("8.1.0"), | ||
_8_2_0("8.2.0"); | ||
|
||
private final String name; | ||
|
||
SemanticVersion(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...nverter/core/src/main/java/org/camunda/community/converter/version/VersionComparator.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,19 @@ | ||
package org.camunda.community.converter.version; | ||
|
||
import java.util.Comparator; | ||
|
||
public class VersionComparator implements Comparator<int[]> { | ||
|
||
@Override | ||
public int compare(int[] version1, int[] version2) { | ||
int positionsToCompare = Math.min(version1.length, version2.length); | ||
int comparison = 0; | ||
for (int i = 0; i < positionsToCompare; i++) { | ||
comparison = version1[i] - version2[i]; | ||
if (comparison != 0) { | ||
return comparison; | ||
} | ||
} | ||
return comparison; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...nverter/core/src/main/java/org/camunda/community/converter/version/VersionComparison.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,12 @@ | ||
package org.camunda.community.converter.version; | ||
|
||
public class VersionComparison { | ||
private static final VersionComparator VERSION_COMPARATOR = new VersionComparator(); | ||
private static final VersionExtractor VERSION_EXTRACTOR = new VersionExtractor(); | ||
|
||
public static boolean isSupported(String actualVersion, String requiredVersion) { | ||
return VERSION_COMPARATOR.compare( | ||
VERSION_EXTRACTOR.apply(actualVersion), VERSION_EXTRACTOR.apply(requiredVersion)) | ||
>= 0; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...onverter/core/src/main/java/org/camunda/community/converter/version/VersionExtractor.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,11 @@ | ||
package org.camunda.community.converter.version; | ||
|
||
import java.util.Arrays; | ||
import java.util.function.Function; | ||
|
||
public class VersionExtractor implements Function<String, int[]> { | ||
@Override | ||
public int[] apply(String version) { | ||
return Arrays.stream(version.split("\\.")).mapToInt(Integer::valueOf).toArray(); | ||
} | ||
} |
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
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
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
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
35 changes: 35 additions & 0 deletions
35
...ter/core/src/test/java/org/camunda/community/converter/version/VersionComparatorTest.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,35 @@ | ||
package org.camunda.community.converter.version; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class VersionComparatorTest { | ||
|
||
@Test | ||
void shouldFindEqualVersion() { | ||
int[] version1 = new int[] {8, 0, 0}; | ||
int[] version2 = new int[] {8, 0}; | ||
VersionComparator comparator = new VersionComparator(); | ||
int compare = comparator.compare(version1, version2); | ||
assertThat(compare).isEqualTo(0); | ||
} | ||
|
||
@Test | ||
void shouldFindBiggerVersion() { | ||
int[] version1 = new int[] {8, 1, 0}; | ||
int[] version2 = new int[] {8, 0}; | ||
VersionComparator comparator = new VersionComparator(); | ||
int compare = comparator.compare(version1, version2); | ||
assertThat(compare).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
void shouldFindSmallerVersion() { | ||
int[] version1 = new int[] {0, 26, 0}; | ||
int[] version2 = new int[] {8, 1}; | ||
VersionComparator comparator = new VersionComparator(); | ||
int compare = comparator.compare(version1, version2); | ||
assertThat(compare).isEqualTo(-8); | ||
} | ||
} |
Oops, something went wrong.