[ 
https://issues.apache.org/jira/browse/HADOOP-19243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17879558#comment-17879558
 ] 

ASF GitHub Bot commented on HADOOP-19243:
-----------------------------------------

steveloughran commented on code in PR #6968:
URL: https://github.com/apache/hadoop/pull/6968#discussion_r1745508768


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSDirAttrOp.java:
##########
@@ -28,9 +29,11 @@
 import org.mockito.Mockito;
 
 import java.io.FileNotFoundException;
+import java.util.Random;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.*;

Review Comment:
   use single imports over .*



##########
hadoop-cloud-storage-project/hadoop-huaweicloud/pom.xml:
##########
@@ -173,8 +173,8 @@
     </dependency>
     <dependency>
       <groupId>org.powermock</groupId>
-      <artifactId>powermock-api-mockito</artifactId>
-      <version>1.7.4</version>
+      <artifactId>powermock-api-mockito2</artifactId>

Review Comment:
   
   move the declaration of this jar into the hadoop-project pom with this 
module importing it, same for the one below. There's an existing 
powermock.version they can use once all projects are in sync
   
   



##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestFileWithSnapshotFeature.java:
##########
@@ -97,6 +101,16 @@ public void testUpdateQuotaAndCollectBlocks() {
     Assert.assertEquals(-BLOCK_SIZE, counts.getTypeSpaces().get(SSD));
   }
 
+  private INodeFile createMockFile(short replication) {

Review Comment:
   add a short javadoc saying why this is needed



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/writer/cosmosdb/TestCosmosDBDocumentStoreWriter.java:
##########
@@ -47,13 +47,10 @@ public class TestCosmosDBDocumentStoreWriter {
   public void setUp() {
     AsyncDocumentClient asyncDocumentClient =
         Mockito.mock(AsyncDocumentClient.class);
-    PowerMockito.mockStatic(DocumentStoreUtils.class);
-    PowerMockito.when(DocumentStoreUtils.getCosmosDBDatabaseName(
-        ArgumentMatchers.any(Configuration.class)))
-        .thenReturn("FooBar");
-    PowerMockito.when(DocumentStoreUtils.createCosmosDBAsyncClient(
-        ArgumentMatchers.any(Configuration.class)))
-        .thenReturn(asyncDocumentClient);
+    Configuration conf = Mockito.mock(Configuration.class);
+    mockStatic(DocumentStoreUtils.class);
+    
when(DocumentStoreUtils.getCosmosDBDatabaseName(conf)).thenReturn("FooBar");

Review Comment:
   nit: can you keep the `thenReturn()` clauses on separate lines}



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/writer/cosmosdb/TestCosmosDBDocumentStoreWriter.java:
##########
@@ -28,9 +28,9 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.ArgumentMatchers;
+import static org.mockito.Mockito.mockStatic;

Review Comment:
   move into the static import block





> Upgrade Mockito version to 4.11.0
> ---------------------------------
>
>                 Key: HADOOP-19243
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19243
>             Project: Hadoop Common
>          Issue Type: Sub-task
>            Reporter: Muskan Mishra
>            Assignee: Muskan Mishra
>            Priority: Major
>              Labels: pull-request-available
>
> While Compiling test classes with JDK17, faced error related to Mockito:
> *Mockito cannot mock this class.*
> So to make it compatible with jdk17 we have to upgrade the version of 
> mockito-core as well as mockito-inline.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to