Skip to content

Commit

Permalink
Update to Java 23
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Nov 8, 2024
1 parent 6085fcd commit fa43e28
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 27 deletions.
9 changes: 9 additions & 0 deletions weasis-acquire/weasis-acquire-explorer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
</bnd>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar
</argLine>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import org.weasis.acquire.explorer.gui.dialog.AcquirePublishDialog.Resolution;
import org.weasis.core.api.media.data.ImageElement;
Expand All @@ -25,30 +27,47 @@ class PublishDicomTaskTest {
@Mock AcquireImageInfo imgInfo;
@Mock ImageElement imgElt;

@BeforeEach
void setUp() {
try (AutoCloseable closeable = MockitoAnnotations.openMocks(this)) {
// Initialize mocks before each test
} catch (Exception e) {
e.printStackTrace();
}
}

@Test
void testCalculateRatio() {
Mockito.when(imgInfo.getImage()).thenReturn(imgElt);

// Assertions for null values
assertNull(PublishDicomTask.calculateRatio(null, null));
assertNull(PublishDicomTask.calculateRatio(imgInfo, null));
assertNull(PublishDicomTask.calculateRatio(imgInfo, Resolution.ORIGINAL));

Mockito.reset(imgElt);

// Scenario 1
Mockito.when(imgElt.getTagValue(TagW.ImageWidth)).thenReturn(4000);
Mockito.when(imgElt.getTagValue(TagW.ImageHeight)).thenReturn(2000);
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.ULTRA_HD), 0.96, 1));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.FULL_HD), 0.48, 1));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.HD_DVD), 0.32, 1));
assertTrue(
isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.ULTRA_HD), 0.96, 0.05));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.FULL_HD), 0.48, 0.05));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.HD_DVD), 0.32, 0.05));

Mockito.reset(imgElt);

// Scenario 2
Mockito.when(imgElt.getTagValue(TagW.ImageWidth)).thenReturn(2000);
Mockito.when(imgElt.getTagValue(TagW.ImageHeight)).thenReturn(4000);
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.ULTRA_HD), 0.96, 1));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.FULL_HD), 0.48, 1));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.HD_DVD), 0.32, 1));
assertTrue(
isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.ULTRA_HD), 0.96, 0.05));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.FULL_HD), 0.48, 0.05));
assertTrue(isCloseTo(PublishDicomTask.calculateRatio(imgInfo, Resolution.HD_DVD), 0.32, 0.05));
}

private boolean isCloseTo(Double actual, double expected, double percentage) {
private boolean isCloseTo(Double actual, double expected, double tolerance) {
double diff = Math.abs(actual - expected);
double tolerance = expected * percentage / 100.0;
return diff <= tolerance;
}
}
38 changes: 19 additions & 19 deletions weasis-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<revision>4.5.2</revision>
<changelist>-SNAPSHOT</changelist> <!-- Remove "-SNAPSHOT" for release -->

<java-version>22</java-version>
<jdk-version>22</jdk-version>
<java-version>23</java-version>
<jdk-version>23</jdk-version>
<enforcer.jdk-version>[${jdk-version},)</enforcer.jdk-version>
<enforcer.maven-version>[3.6.3,)</enforcer.maven-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -108,7 +108,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<release>${java-version}</release>
</configuration>
Expand Down Expand Up @@ -136,22 +136,22 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.3.2</version>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.2</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
Expand All @@ -161,17 +161,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<version>3.8.1</version>
<executions>
<execution>
<goals>
Expand All @@ -183,7 +183,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<version>3.5.2</version>
<configuration>
<argLine>@{argLine} -Xshare:off -XX:+EnableDynamicAgentLoading</argLine>
<parallel>all</parallel>
Expand All @@ -192,12 +192,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -207,12 +207,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>4.0.0-M13</version>
<version>4.0.0-M16</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
Expand All @@ -222,22 +222,22 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<version>0.8.12</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
Expand Down

0 comments on commit fa43e28

Please sign in to comment.