InvisibleProgrammer commented on code in PR #4707:
URL: https://github.com/apache/hive/pull/4707#discussion_r1337407337


##########
ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java:
##########
@@ -97,151 +96,159 @@ public void shouldThrowExceptionOnDistcpFailure() throws 
Exception {
     List<Path> srcPaths = Arrays.asList(source, source);
     HiveConf conf = mock(HiveConf.class);
     CopyUtils copyUtils = Mockito.spy(new CopyUtils(null, conf, fs));
+    doReturn(false).when(copyUtils).regularCopy(same(fs), anyList());
 
-    mockStatic(FileUtils.class);
-    mockStatic(Utils.class);
-    when(destination.getFileSystem(same(conf))).thenReturn(fs);
     when(source.getFileSystem(same(conf))).thenReturn(fs);
-    when(FileUtils.distCp(same(fs), anyListOf(Path.class), same(destination),
-                          anyBoolean(), eq(null), same(conf),
-                          same(ShimLoader.getHadoopShims())))
-        .thenReturn(false);
-    when(Utils.getUGI()).thenReturn(mock(UserGroupInformation.class));
-    doReturn(false).when(copyUtils).regularCopy(same(fs), 
anyListOf(ReplChangeManager.FileInfo.class));
-
-    copyUtils.doCopy(destination, srcPaths);
+    try (
+            MockedStatic<FileUtils> fileUtilsMockedStatic = 
mockStatic(FileUtils.class);
+            MockedStatic<Utils> utilsMockedStatic = mockStatic(Utils.class)
+      ) {
+      fileUtilsMockedStatic.when(() -> FileUtils.distCp(same(fs), anyList(), 
same(destination),
+                            anyBoolean(), eq(null), same(conf),
+                            same(ShimLoader.getHadoopShims())))
+          .thenReturn(false);
+      
utilsMockedStatic.when(Utils::getUGI).thenReturn(mock(UserGroupInformation.class));
+
+      copyUtils.doCopy(destination, srcPaths);
+    }

Review Comment:
   Replaced it. TBH, Now I think it is harder to read the code and interpret 
what it exactly does. But I know you know that code base way better than I am 
so I assume you have confidence about our formatting patterns as well. 
   Do you want me to check and change all the mocking occurrences in the PR? 
   As I understood your recommendation there are two issues: 
   - try block should be more compact
   - shouldn't put .thenReturn clauses into new line at methods with long 
parameter list. 
   



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to