You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "steveloughran (via GitHub)" <gi...@apache.org> on 2024/09/05 13:21:45 UTC
Re: [PR] HADOOP-19243. Upgrade Mockito version to 4.11.0 [hadoop]
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org