Skip to content

Commit 46677e0

Browse files
committed
Add test coverage for new util function
1 parent 4365197 commit 46677e0

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/utils/VersionUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ private VersionUtils() {
2828

2929
/**
3030
* Converts a full version string to a major.minor.x format.
31-
*
32-
* @param version The full version string to convert (e.g., "2.32.1")
33-
* @return The version string in major.minor.x format (e.g., "2.32.x"),
34-
* or the original string if it doesn't match the expected version pattern
35-
*/
31+
*
32+
* @param version The full version string to convert (e.g., "2.32.1")
33+
* @return The version string in major.minor.x format (e.g., "2.32.x"),
34+
* or the original string if it doesn't match the expected version pattern
35+
*/
3636
public static String convertToMajorMinorX(String version) {
3737
Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(.*)");
3838
Matcher matcher = pattern.matcher(version);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.codegen.utils;
17+
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
20+
import org.junit.Test;
21+
22+
public class VersionUtilsTest {
23+
24+
@Test
25+
public void serviceVersionInfo_redactPatchVersion() {
26+
String currentVersion = "2.35.13";
27+
String currentSnapshotVersion = "2.35.13-SNAPSHOT";
28+
29+
String actualVersion = VersionUtils.convertToMajorMinorX(currentVersion);
30+
String actualSnapshotVersion = VersionUtils.convertToMajorMinorX(currentSnapshotVersion);
31+
assertThat(actualVersion).isEqualTo("2.35.x");
32+
assertThat(actualSnapshotVersion).isEqualTo("2.35.x-SNAPSHOT");
33+
}
34+
}

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/useragent/SdkUserAgentBuilderTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.List;
2828
import java.util.Optional;
2929
import java.util.stream.Stream;
30+
import org.junit.Test;
3031
import org.junit.jupiter.params.ParameterizedTest;
3132
import org.junit.jupiter.params.provider.Arguments;
3233
import org.junit.jupiter.params.provider.MethodSource;

0 commit comments

Comments
 (0)