This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 8be5513d4 [OPENMEETINGS-2841] test is fixed
8be5513d4 is described below

commit 8be5513d4728211c8ea5562468b99ff0de933f30
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Thu Sep 17 11:15:54 2026 +0700

    [OPENMEETINGS-2841] test is fixed
---
 .../apache/openmeetings/db/entity/file/TestFileItem.java  | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git 
a/openmeetings-db/src/test/java/org/apache/openmeetings/db/entity/file/TestFileItem.java
 
b/openmeetings-db/src/test/java/org/apache/openmeetings/db/entity/file/TestFileItem.java
index 5fdd1a94d..38c5c56af 100644
--- 
a/openmeetings-db/src/test/java/org/apache/openmeetings/db/entity/file/TestFileItem.java
+++ 
b/openmeetings-db/src/test/java/org/apache/openmeetings/db/entity/file/TestFileItem.java
@@ -29,7 +29,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.MockedStatic;
+import org.mockito.invocation.InvocationOnMock;
 import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.stubbing.Answer;
 
 @ExtendWith(MockitoExtension.class)
 class TestFileItem {
@@ -83,8 +85,17 @@ class TestFileItem {
        }
 
        private void wrapper(Runnable r) {
-               try (MockedStatic<OmFileHelper> theMock = 
mockStatic(OmFileHelper.class)) {
-                       
theMock.when(OmFileHelper::getUploadFilesDir).thenReturn(new 
File("src/test/resources/org/apache/openmeetings/db/entity/file"));
+               try (MockedStatic<OmFileHelper> theMock = 
mockStatic(OmFileHelper.class, new Answer<File>() {
+                       @Override
+                       public File answer(InvocationOnMock invocation) throws 
Throwable {
+                               return switch 
(invocation.getMethod().getName()) {
+                                       case "getUploadFilesDir" -> new 
File("src/test/resources/org/apache/openmeetings/db/entity/file");
+                                       case "getFileSafe" -> new 
File(invocation.getArgument(0, File.class)
+                                                               , 
invocation.getArgument(1, String.class) + "." + invocation.getArgument(2, 
String.class));
+                                       default -> null;
+                               };
+                       }
+               })) {
                        r.run();
                }
        }

Reply via email to