Skip to content

Commit

Permalink
[ML] Remove toVersion method from MlConfigVersion (elastic#99884)
Browse files Browse the repository at this point in the history
There's no need for a toVersion method in MlConfigVersion.
  • Loading branch information
droberts195 authored Sep 26, 2023
1 parent accf966 commit b08f7b7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,6 @@ public static MlConfigVersion fromVersion(Version version) {
return fromId(version.id);
}

public static Version toVersion(MlConfigVersion mlConfigVersion) {
if (mlConfigVersion.before(FIRST_ML_VERSION) || mlConfigVersion.onOrAfter(V_8_10_0)) {
throw new IllegalArgumentException("Cannot convert " + mlConfigVersion + ". Incompatible version");
}
return Version.fromId(mlConfigVersion.id);
}

public static MlConfigVersion getMinMlConfigVersion(DiscoveryNodes nodes) {
return getMinMaxMlConfigVersion(nodes).v1();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,6 @@ public void testFromVersion() {
assertEquals("Cannot convert " + Version.fromId(8_11_00_99) + ". Incompatible version", e.getMessage());
}

public void testToVersion() {
MlConfigVersion mlConfigVersion_V_7_7_0 = MlConfigVersion.V_7_0_0;
Version version_V_7_7_0 = MlConfigVersion.toVersion(mlConfigVersion_V_7_7_0);
assertEquals(version_V_7_7_0.id, mlConfigVersion_V_7_7_0.id());

// There's no mapping between Version and MlConfigVersion values from MlConfigVersion.V_10 onwards.
MlConfigVersion mlConfigVersion_V_10 = MlConfigVersion.V_10;
Exception e = expectThrows(IllegalArgumentException.class, () -> MlConfigVersion.toVersion(mlConfigVersion_V_10));
assertEquals("Cannot convert " + mlConfigVersion_V_10 + ". Incompatible version", e.getMessage());
}

public void testVersionConstantPresent() {
Set<MlConfigVersion> ignore = Set.of(MlConfigVersion.ZERO, MlConfigVersion.CURRENT, MlConfigVersion.FIRST_ML_VERSION);
assertThat(MlConfigVersion.CURRENT, sameInstance(MlConfigVersion.fromId(MlConfigVersion.CURRENT.id())));
Expand Down

0 comments on commit b08f7b7

Please sign in to comment.