Bugfix/activate helidon versionutil tests (#18815)

* Reactivate tests

Contrary to Junit5, classes containing TestNG tests need to have
public visibility, otherwise the tests will not be discovered and run.

* Reformat tests for readability

* Rewrite tests using fluent assertions
This commit is contained in:
Philzen
2024-06-02 15:42:02 +02:00
committed by GitHub
parent 713aa92b22
commit 051abb82dc

View File

@@ -16,37 +16,26 @@
*/ */
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.testng.annotations.Test;
import java.util.List; import java.util.List;
import org.testng.Assert; import static org.assertj.core.api.Assertions.assertThat;
import org.testng.annotations.Test;
// This test class is in this package, not org.openapitools.codegen.java.helidon, so it can refer to elements of // This test class is in this package, not org.openapitools.codegen.java.helidon, so it can refer to elements of
// JavaHelidonCommonCodegen without making them public; package-private is sufficient and we don't want to expose those methods // JavaHelidonCommonCodegen without making them public; package-private is sufficient and we don't want to expose those methods
// more broadly. // more broadly.
class HelidonCommonCodegenTest { public class HelidonCommonCodegenTest {
@Test JavaHelidonCommonCodegen.VersionUtil test = JavaHelidonCommonCodegen.VersionUtil.instance();
void checkMajorVersionMatch() {
Assert.assertEquals("1.2.3", @Test void checkMajorVersionMatch() {
JavaHelidonCommonCodegen.VersionUtil.instance().chooseVersion("1", assertThat(test.chooseVersion("1", List.of("3.2.1", "3.2.0", "2.0.4", "1.2.3", "1.2.2", "1.1.0")))
List.of("3.2.1", .isEqualTo("1.2.3");
"3.2.0",
"2.0.4",
"1.2.3",
"1.2.2",
"1.1.0")));
} }
@Test @Test void checkExactMatch() {
void checkExactMatch() { assertThat(test.chooseVersion("1.2.2", List.of("3.2.1", "3.2.0", "2.0.4", "1.2.3", "1.2.2", "1.1.0")))
Assert.assertEquals("1.2.2", .isEqualTo("1.2.2");
JavaHelidonCommonCodegen.VersionUtil.instance().chooseVersion("1.2.2",
List.of("3.2.1",
"3.2.0",
"2.0.4",
"1.2.3",
"1.2.2",
"1.1.0")));
} }
} }