Skip to content

Commit

Permalink
Replace deprecated Version.valueOf with Version.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
cppwfs committed Oct 18, 2024
1 parent 13a46ab commit 438ade4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

public class DefaultDockerCompose implements DockerCompose {

public static final Version VERSION_1_7_0 = Version.valueOf("1.7.0");
public static final Version VERSION_1_7_0 = Version.parse("1.7.0");
private static final Duration COMMAND_TIMEOUT = standardMinutes(2);
private static final Duration LOG_WAIT_TIMEOUT = standardMinutes(30);
private static final Logger log = LoggerFactory.getLogger(DefaultDockerCompose.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public static Version parseFromDockerComposeVersion(String versionOutput) {
if (version.charAt(i) >= '0' && version.charAt(i) <= '9' || version.charAt(i) == '.') {
builder.append(version.charAt(i));
} else {
return Version.valueOf(builder.toString());
return Version.parse(builder.toString());
}
}
return Version.valueOf(builder.toString());
return Version.parse(builder.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ public class DockerComposeVersionTests {

@Test
public void compare_major_versions_first() {
assertThat(Version.valueOf("2.1.0").compareTo(Version.valueOf("1.2.1"))).isGreaterThan(0);
assertThat(Version.parse("2.1.0").compareTo(Version.parse("1.2.1"))).isGreaterThan(0);
}

@Test
public void compare_minor_versions_when_major_versions_are_the_same() {
assertThat(Version.valueOf("2.1.7").compareTo(Version.valueOf("2.3.2"))).isLessThan(0);
assertThat(Version.parse("2.1.7").compareTo(Version.parse("2.3.2"))).isLessThan(0);
}

@Test
public void return_equals_for_the_same_version_strings() {
assertThat(Version.valueOf("2.1.2").compareTo(Version.valueOf("2.1.2"))).isEqualTo(0);
assertThat(Version.parse("2.1.2").compareTo(Version.parse("2.1.2"))).isEqualTo(0);
}

@Test
public void remove_non_digits_when_passing_version_string() {
assertThat(DockerComposeVersion.parseFromDockerComposeVersion("docker-compose version 1.7.0rc1, build 1ad8866")).isEqualTo(Version.valueOf("1.7.0"));
assertThat(DockerComposeVersion.parseFromDockerComposeVersion("docker-compose version 1.7.0rc1, build 1ad8866")).isEqualTo(Version.parse("1.7.0"));
}
public void check_for_docker_version() {
assertThat(DockerComposeVersion.parseFromDockerComposeVersion("Docker version 26.1.1, build 1ad8866")).isEqualTo(Version.valueOf("26.1.1"));
assertThat(DockerComposeVersion.parseFromDockerComposeVersion("Docker version 26.1.1, build 1ad8866")).isEqualTo(Version.parse("26.1.1"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ void callDockerNetworkPrune() throws Exception {
void understandOldVersionFormat() throws Exception {
when(executedProcess.getInputStream()).thenReturn(IOUtils.toInputStream("Docker version 1.7.2"));
Version version = docker.configuredVersion();
assertThat(version).isEqualTo(Version.valueOf("1.7.2"));
assertThat(version).isEqualTo(Version.parse("1.7.2"));
}

@Test
void understandNewVersionFormat() throws Exception {
when(executedProcess.getInputStream()).thenReturn(IOUtils.toInputStream("Docker version 17.03.1-ce"));
Version version = docker.configuredVersion();
assertThat(version).isEqualTo(Version.valueOf("17.3.1"));
assertThat(version).isEqualTo(Version.parse("17.3.1"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public RuntimeApplicationHelper(DataFlowTemplate dataFlowTemplate, String platfo
.filter(p -> p.getName().equalsIgnoreCase(platformName))
.map(Deployer::getType).findFirst().get();

dataflowServerVersion = Version.valueOf(dataFlowTemplate.aboutOperation().get()
dataflowServerVersion = Version.parse(dataFlowTemplate.aboutOperation().get()
.getVersionInfo().getCore().getVersion());

Assert.hasText(this.platformType, "Could not find platform type for: " + platformName);
Expand All @@ -96,11 +96,11 @@ public Version getDataflowServerVersion() {
}

public boolean dataflowServerVersionEqualOrGreaterThan(String version) {
return dataflowServerVersion.compareTo(Version.valueOf(version)) >= 0;
return dataflowServerVersion.compareTo(Version.parse(version)) >= 0;
}

public boolean dataflowServerVersionLowerThan(String version) {
return dataflowServerVersion.compareTo(Version.valueOf(version)) < 0;
return dataflowServerVersion.compareTo(Version.parse(version)) < 0;
}

public String getPlatformName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private Deployer createAndSaveCFAppDeployer(
.build();
Version version = cloudFoundryClient.info()
.get(GetInfoRequest.builder().build())
.map(response -> Version.valueOf(response.getApiVersion()))
.map(response -> Version.parse(response.getApiVersion()))
.doOnNext(versionInfo -> logger.info(
"Connecting to Cloud Foundry with API Version {}",
versionInfo))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private void validateUploadRequest(Path packageDirPath, UploadRequest uploadRequ
Assert.notNull(uploadRequest.getName(), "Name of package can not be null");
Assert.notNull(uploadRequest.getVersion(), "Version can not be null");
try {
Version.valueOf(uploadRequest.getVersion().trim());
Version.parse(uploadRequest.getVersion().trim());
}
catch (ParseException e) {
throw new SkipperException("UploadRequest doesn't have a valid semantic version. Version = " +
Expand Down

0 comments on commit 438ade4

Please sign in to comment.