Skip to content

Commit ff71618

Browse files
committed
Added more unit tests
1 parent c168dd4 commit ff71618

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

codegen/src/test/java/software/amazon/awssdk/codegen/utils/VersionUtilsTest.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
1919

20-
import org.junit.Test;
20+
import java.util.stream.Stream;
21+
import org.junit.jupiter.params.ParameterizedTest;
22+
import org.junit.jupiter.params.provider.Arguments;
23+
import org.junit.jupiter.params.provider.MethodSource;
2124

2225
public class VersionUtilsTest {
2326

24-
@Test
25-
public void serviceVersionInfo_redactPatchVersion() {
26-
String currentVersion = "2.35.13";
27-
String currentSnapshotVersion = "2.35.13-SNAPSHOT";
27+
@ParameterizedTest(name = "{0}")
28+
@MethodSource("versionsTestCases")
29+
public void serviceVersionInfo_redactPatchVersion(String testName, String versionToTruncate, String expectedVersion) {
30+
String actualVersion = VersionUtils.convertToMajorMinorX(versionToTruncate);
31+
assertThat(actualVersion).isEqualTo(expectedVersion);
32+
}
2833

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");
34+
private static Stream<Arguments> versionsTestCases() {
35+
return Stream.of(
36+
Arguments.of("valid version", "2.35.13", "2.35.x"),
37+
Arguments.of("valid snapshot version", "2.35.13-SNAPSHOT", "2.35.x-SNAPSHOT"),
38+
Arguments.of("different major version", "3.5.5", "3.5.x"),
39+
Arguments.of("invalid version, uses version as-is", "23513", "23513")
40+
);
3341
}
3442
}

0 commit comments

Comments
 (0)