Skip to content

Commit

Permalink
Bugfix/activate helidon versionutil tests (OpenAPITools#18815)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Philzen authored and welshm committed Jun 5, 2024
1 parent 6a0b9ff commit 226a47f
Showing 1 changed file with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,26 @@
*/
package org.openapitools.codegen.languages;

import org.testng.annotations.Test;

import java.util.List;

import org.testng.Assert;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.assertThat;

// 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
// more broadly.
class HelidonCommonCodegenTest {
public class HelidonCommonCodegenTest {

@Test
void checkMajorVersionMatch() {
Assert.assertEquals("1.2.3",
JavaHelidonCommonCodegen.VersionUtil.instance().chooseVersion("1",
List.of("3.2.1",
"3.2.0",
"2.0.4",
"1.2.3",
"1.2.2",
"1.1.0")));
JavaHelidonCommonCodegen.VersionUtil test = JavaHelidonCommonCodegen.VersionUtil.instance();

@Test void checkMajorVersionMatch() {
assertThat(test.chooseVersion("1", List.of("3.2.1", "3.2.0", "2.0.4", "1.2.3", "1.2.2", "1.1.0")))
.isEqualTo("1.2.3");
}

@Test
void checkExactMatch() {
Assert.assertEquals("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")));
@Test 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")))
.isEqualTo("1.2.2");
}
}

0 comments on commit 226a47f

Please sign in to comment.