Skip to content

Commit

Permalink
Remove RC constant from Neo4jVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwalker committed Jul 18, 2024
1 parent 976f2b2 commit d2ec2df
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 34 deletions.
11 changes: 0 additions & 11 deletions neo4j-adapter/src/main/java/org/neo4j/gds/compat/Neo4jVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ default boolean isSupported() {
return !(this instanceof Unsupported);
}

default boolean isUnstable() {
return this instanceof Unstable;
}

record MajorMinor(int major, int minor) {
@Override
public String toString() {
Expand All @@ -67,13 +63,6 @@ public String toString() {
}
}

record Unstable(int major, int minor, String fullVersion) implements Neo4jVersion {
@Override
public String toString() {
return this.major + "." + this.minor;
}
}

record Unsupported(int major, int minor, String fullVersion) implements Neo4jVersion {
@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static Neo4jVersion findNeo4jVersion() {
}

private static final int SUPPORTED_MAJOR_VERSION = 5;
private static final int NUM_SUPPORTED_MINOR_VERSIONS = 6;
private static final int MIN_SUPPORTED_MINOR_VERSION = 16;

@VisibleForTesting
Expand All @@ -81,16 +80,6 @@ static Neo4jVersion parse(CharSequence version, String fullVersion) {
return new Neo4jVersion.Unsupported(majorVersion, minorVersion, fullVersion);
}

if (fullVersion.contains("SNAPSHOT")) {
return new Neo4jVersion.Unstable(majorVersion, minorVersion, fullVersion);
}

// TODO: remove this once we have a layer for that particular version, not "dev"
var LATEST_SUPPORTED_MINOR_VERSION = MIN_SUPPORTED_MINOR_VERSION + NUM_SUPPORTED_MINOR_VERSIONS - 1; // -1 because the range is inclusive
if (minorVersion > LATEST_SUPPORTED_MINOR_VERSION) {
return new Neo4jVersion.Unstable(majorVersion, minorVersion, fullVersion);
}

return new Neo4jVersion.Known(majorVersion, minorVersion, fullVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class Neo4jVersionLookupTest {
void testParse(String input, int major, int minor) {
assertThat(Neo4jVersionLookup.parse(input, input))
.returns(new Neo4jVersion.MajorMinor(major, minor), Neo4jVersion::semanticVersion)
.returns(true, Neo4jVersion::isSupported)
.returns(false, Neo4jVersion::isUnstable);
.returns(true, Neo4jVersion::isSupported);
}

@ParameterizedTest
Expand All @@ -58,8 +57,7 @@ void testParse(String input, int major, int minor) {
void testParseNext(String input, int major, int minor) {
assertThat(Neo4jVersionLookup.parse(input, input))
.returns(true, v -> v.matches(major, minor))
.returns(true, Neo4jVersion::isSupported)
.returns(true, Neo4jVersion::isUnstable);
.returns(true, Neo4jVersion::isSupported);
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ void testSysInfoProc() throws IOException {

var neo4jVersion = GraphDatabaseApiProxy.neo4jVersion();

var expectedCompatibility = neo4jVersion.isUnstable()
? Set.of("Neo4j %s".formatted(neo4jVersion), "Neo4j RC", "Neo4j DEV")
: Set.of("Neo4j %s".formatted(neo4jVersion));
var expectedCompatibility = Set.of("Neo4j %s".formatted(neo4jVersion));

var allCompatibilities = new HashSet<>(ALL_COMPATIBILITIES);
allCompatibilities.removeAll(expectedCompatibility);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
package org.neo4j.gds.junit.annotation;

@SuppressWarnings("all")
@SuppressWarnings("all") // squelch checkstyle
public enum Neo4jVersion {
V_5_16(16),
V_5_17(17),
Expand All @@ -29,7 +29,6 @@ public enum Neo4jVersion {
V_5_21(21),
V_5_22(22),
V_5_23(23),
V_Dev(-2),
;

private final int minor;
Expand All @@ -39,8 +38,6 @@ public enum Neo4jVersion {
}

public boolean matches(org.neo4j.gds.compat.Neo4jVersion version) {
return (this == V_Dev)
? version.isUnstable()
: version.major() == 5 && version.minor() == this.minor;
return version.matches(5, this.minor);
}
}

0 comments on commit d2ec2df

Please sign in to comment.