浏览代码

Stop using Mockito for mocking ZoneId class, generate a random ZoneId instead (#86185)

Andrei Stefan 3 年之前
父节点
当前提交
a701897c6c

+ 5 - 0
x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/tree/NodeSubclassTests.java

@@ -46,6 +46,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.SimpleFileVisitor;
 import java.nio.file.attribute.BasicFileAttributes;
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
@@ -514,6 +515,10 @@ public class NodeSubclassTests<T extends B, B extends Node<B>> extends ESTestCas
             // Location is final and can't be mocked but we have a handy method to generate ones.
             return SourceTests.randomSource();
         }
+        if (argClass == ZoneId.class) {
+            // ZoneId is a sealed class (cannot be mocked) starting with Java 19
+            return randomZone();
+        }
         try {
             return mock(argClass);
         } catch (MockitoException e) {