From 5932f0c2ce58c7ca096d2069fb50de842196f5f2 Mon Sep 17 00:00:00 2001 From: "joao.p.almeida" Date: Thu, 6 Aug 2026 11:29:16 +0100 Subject: [PATCH] feat: update build to use jdk17 Update build to use jdk17 and replace jmockit by mockito --- .github/workflows/build.yml | 14 ++++----- .github/workflows/deploy.yml | 8 ++--- openml-datarobot/pom.xml | 10 +++--- .../DataRobotModelProviderLoadTest.java | 9 +++--- openml-java-utils/pom.xml | 4 +-- .../java/utils/ModelParameterUtilsTest.java | 31 +++++++------------ pom.xml | 26 ++++++++++------ 7 files changed, 51 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 708ff1a9..6afb38e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - run: | @@ -33,10 +33,10 @@ jobs: echo exit code $? git tag --list - - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: - java-version: '8' + java-version: '17' distribution: 'zulu' - name: Cache Maven packages @@ -56,8 +56,8 @@ jobs: # The skipped tests is because h2o-xgboost isn't ready to use with musl - name: Test with musl run: | - docker run --rm -t -v ~/.m2:/root/.m2 -v $(pwd):/feedzai-openml-java -e FDZ_OPENML_JAVA_LIBC="musl" alpine:3.18.4 \ - /bin/sh -c 'apk add clang openjdk8 maven bash git && \ + docker run --rm -t -v ~/.m2:/root/.m2 -v $(pwd):/feedzai-openml-java -e FDZ_OPENML_JAVA_LIBC="musl" alpine:3.20 \ + /bin/sh -c 'apk add clang openjdk17 maven bash git && \ git config --global --add safe.directory /feedzai-openml-java && \ git config --global --add safe.directory /feedzai-openml-java/openml-lightgbm/lightgbm-builder/make-lightgbm && \ cd /feedzai-openml-java && \ @@ -67,7 +67,7 @@ jobs: # The skipped tests is because h2o-xgboost isn't ready to use on arm64 - name: Test on arm64 run: | - docker run --rm --platform=arm64 -t -v ~/.m2:/root/.m2 -v $(pwd):/feedzai-openml-java maven:3.8-openjdk-8-slim \ + docker run --rm --platform=arm64 -t -v ~/.m2:/root/.m2 -v $(pwd):/feedzai-openml-java maven:3.9-eclipse-temurin-17 \ /bin/bash -c 'apt update && apt install -y --no-install-recommends git && \ git config --global --add safe.directory /feedzai-openml-java && \ git config --global --add safe.directory /feedzai-openml-java/openml-lightgbm/lightgbm-builder/make-lightgbm && \ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b58617fb..7ae0afbb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - run: | @@ -23,10 +23,10 @@ jobs: echo exit code $? git tag --list - - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: - java-version: '8' + java-version: '17' distribution: 'zulu' server-id: ossrh server-username: MAVEN_USERNAME diff --git a/openml-datarobot/pom.xml b/openml-datarobot/pom.xml index a49a695c..c19bd5bf 100644 --- a/openml-datarobot/pom.xml +++ b/openml-datarobot/pom.xml @@ -92,11 +92,6 @@ test test-jar - - org.jmockit - jmockit - test - com.google.auto.service auto-service @@ -111,6 +106,11 @@ assertj-core test + + org.mockito + mockito-core + test + com.feedzai openml-java-utils diff --git a/openml-datarobot/src/test/java/com/feedzai/openml/datarobot/DataRobotModelProviderLoadTest.java b/openml-datarobot/src/test/java/com/feedzai/openml/datarobot/DataRobotModelProviderLoadTest.java index 154c9722..fe745bf2 100644 --- a/openml-datarobot/src/test/java/com/feedzai/openml/datarobot/DataRobotModelProviderLoadTest.java +++ b/openml-datarobot/src/test/java/com/feedzai/openml/datarobot/DataRobotModelProviderLoadTest.java @@ -30,7 +30,6 @@ import com.feedzai.openml.provider.exception.ModelLoadingException; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import mockit.Mocked; import org.assertj.core.api.Assertions; import org.junit.Test; import org.slf4j.Logger; @@ -51,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; /** * Tests for loading models with {@link DataRobotModelProvider}. @@ -375,13 +375,12 @@ public double getValue(final int index) { /** * Tests that fetching the labels from a model that does not contain them yields a default value. * - * @param mockedPredictor The mocked predictor. - * * @since 0.5.8 */ @Test - public void readUnexistingTargetLabelsTest(final @Mocked Predictor mockedPredictor) { - assertThat(new DataRobotModelCreator().getTargetModelValues(mockedPredictor)) + public void readUnexistingTargetLabelsTest() { + final Predictor predictor = mock(Predictor.class); + assertThat(new DataRobotModelCreator().getTargetModelValues(predictor)) .as("The target labels") .containsExactlyInAnyOrder("0", "1"); } diff --git a/openml-java-utils/pom.xml b/openml-java-utils/pom.xml index ee95a2e7..d7c8bd3e 100644 --- a/openml-java-utils/pom.xml +++ b/openml-java-utils/pom.xml @@ -63,8 +63,8 @@ test - org.jmockit - jmockit + org.mockito + mockito-core test diff --git a/openml-java-utils/src/test/java/com/feedzai/openml/java/utils/ModelParameterUtilsTest.java b/openml-java-utils/src/test/java/com/feedzai/openml/java/utils/ModelParameterUtilsTest.java index 83263637..78724134 100644 --- a/openml-java-utils/src/test/java/com/feedzai/openml/java/utils/ModelParameterUtilsTest.java +++ b/openml-java-utils/src/test/java/com/feedzai/openml/java/utils/ModelParameterUtilsTest.java @@ -24,29 +24,32 @@ import com.feedzai.openml.provider.descriptor.fieldtype.NumericFieldType; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import mockit.Expectations; -import mockit.Mocked; -import mockit.integration.junit4.JMockit; import org.junit.Test; -import org.junit.runner.RunWith; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * Validates the behaviour of {@link ModelParameterUtils}. */ -@RunWith(JMockit.class) public class ModelParameterUtilsTest { /** - * Validates that effective model parameters are being correctly calculated.s - * - * @param mlAlgorithmDescriptor The mocked ML algorithm. + * Validates that effective model parameters are being correctly calculated. */ @Test - public final void effectiveModelParameterValues(@Mocked final MLAlgorithmDescriptor mlAlgorithmDescriptor) { + public final void effectiveModelParameterValues() { + + final MLAlgorithmDescriptor mlAlgorithmDescriptor = mock(MLAlgorithmDescriptor.class); + when(mlAlgorithmDescriptor.getParameters()).thenReturn(ImmutableSet.of( + new ModelParameter("param0", "", "", true, new BooleanFieldType(false)), + new ModelParameter("param1", "", "", true, new FreeTextFieldType("1")), + new ModelParameter("param2", "", "", true, NumericFieldType.min(0d, NumericFieldType.ParameterConfigType.INT, 2d)), + new ModelParameter("param3", "", "", true, new ChoiceFieldType(ImmutableSet.of("1", "2", "3"), "3")) + )); final Map expectedParams = ImmutableMap.of( "param0", "false", @@ -56,16 +59,6 @@ public final void effectiveModelParameterValues(@Mocked final MLAlgorithmDescrip "param1", "99" ); - new Expectations() {{ - mlAlgorithmDescriptor.getParameters(); - result = ImmutableSet.of( - new ModelParameter("param0", "", "", true, new BooleanFieldType(false)), - new ModelParameter("param1", "", "", true, new FreeTextFieldType("1")), - new ModelParameter("param2", "", "", true, NumericFieldType.min(0d, NumericFieldType.ParameterConfigType.INT, 2d)), - new ModelParameter("param3", "", "", true, new ChoiceFieldType(ImmutableSet.of("1", "2", "3"), "3")) - ); - }}; - final Map effectiveParams = ModelParameterUtils.getEffectiveModelParameterValues( mlAlgorithmDescriptor, ImmutableSet.of("param0", "param1", "param2", "param3", "param4"), diff --git a/pom.xml b/pom.xml index c44da522..a6a71beb 100644 --- a/pom.xml +++ b/pom.xml @@ -70,9 +70,9 @@ UTF-8 1.8 + 8 4.13.1 3.7.0 - 1.35 1.2.0 2.6.7 2.6.7 @@ -188,9 +188,9 @@ test - org.jmockit - jmockit - ${jmockit.version} + org.mockito + mockito-core + 4.11.0 test @@ -208,10 +208,9 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.13.0 - 1.8 - 1.8 + ${java.release} @@ -222,7 +221,16 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.5.2 + + + @{argLine} + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.lang.reflect=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.io=ALL-UNNAMED + + org.apache.maven.plugins @@ -250,7 +258,7 @@ org.jacoco jacoco-maven-plugin - 0.8.4 + 0.8.12