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


##########
ql/src/test/org/apache/hadoop/hive/ql/exec/repl/TestRangerDumpTask.java:
##########
@@ -124,50 +123,45 @@ public void testSuccessNonEmptyRangerPolicies() throws 
Exception {
         + 
"\"dataMaskPolicyItems\":[],\"rowFilterPolicyItems\":[],\"id\":40,\"guid\":"
         + 
"\"4e2b3406-7b9a-4004-8cdf-7a239c8e2cae\",\"isEnabled\":true,\"version\":1}]}";
     RangerExportPolicyList rangerPolicyList = new 
Gson().fromJson(rangerResponse, RangerExportPolicyList.class);
-    Mockito.when(mockClient.exportRangerPolicies(Mockito.anyString(), 
Mockito.anyString(), Mockito.anyString(),
+    when(mockClient.exportRangerPolicies(Mockito.anyString(), 
Mockito.anyString(), Mockito.anyString(),
       Mockito.any()))
       .thenReturn(rangerPolicyList);
-    Mockito.when(conf.get(RANGER_REST_URL)).thenReturn("rangerEndpoint");
-    Mockito.when(conf.get(RANGER_HIVE_SERVICE_NAME)).thenReturn("hive");
-    Mockito.when(work.getDbName()).thenReturn("testdb");
+    when(conf.get(RANGER_REST_URL)).thenReturn("rangerEndpoint");
+    when(conf.get(RANGER_HIVE_SERVICE_NAME)).thenReturn("hive");
+    when(work.getDbName()).thenReturn("testdb");
     Path rangerDumpPath = new Path("/tmp");
-    Mockito.when(work.getCurrentDumpPath()).thenReturn(rangerDumpPath);
+    when(work.getCurrentDumpPath()).thenReturn(rangerDumpPath);
     Path policyFile = new Path(rangerDumpPath, 
ReplUtils.HIVE_RANGER_POLICIES_FILE_NAME);
-    Mockito.when(mockClient.saveRangerPoliciesToFile(rangerPolicyList, 
rangerDumpPath,
+    when(mockClient.saveRangerPoliciesToFile(rangerPolicyList, rangerDumpPath,
       ReplUtils.HIVE_RANGER_POLICIES_FILE_NAME, conf)).thenReturn(policyFile);
-    Mockito.when(work.getRangerConfigResource()).thenReturn(new 
URL("file://ranger.xml"));
+    when(work.getRangerConfigResource()).thenReturn(new 
URL("file://ranger.xml"));
     int status = task.execute();
     Assert.assertEquals(0, status);
   }
 
   @Test
   public void testSuccessRangerDumpMetrics() throws Exception {
-    Logger logger = Mockito.mock(Logger.class);
-    Whitebox.setInternalState(ReplState.class, logger);
+    Logger logger = LoggerFactory.getLogger("ReplState");
+    StringAppender appender = StringAppender.createStringAppender(null);
+    appender.addToLogger(logger.getName(), Level.INFO);
+    appender.start();
     RangerExportPolicyList rangerPolicyList = new RangerExportPolicyList();
     rangerPolicyList.setPolicies(new ArrayList<RangerPolicy>());
     Mockito.when(mockClient.exportRangerPolicies(Mockito.anyString(), 
Mockito.anyString(), Mockito.anyString(),
-      Mockito.any()))
-      .thenReturn(rangerPolicyList);
+                    Mockito.any()))
+            .thenReturn(rangerPolicyList);

Review Comment:
   Unnecessary change.



##########
ql/src/test/org/apache/hadoop/hive/ql/parse/repl/load/message/TestPrimaryToReplicaResourceFunction.java:
##########
@@ -76,30 +78,37 @@ public void setup() {
         new Context("primaryDb", null, null, null, hiveConf, null, null, 
logger);
     when(hiveConf.getVar(HiveConf.ConfVars.REPL_FUNCTIONS_ROOT_DIR))
         .thenReturn("/someBasePath/withADir/");
+    timeMockedStatic = mockStatic(Time.class);
+    timeMockedStatic.when(Time::monotonicNowNanos).thenReturn(0L);
     function = new PrimaryToReplicaResourceFunction(context, metadata, 
"replicaDbName");
   }
 
+  @After
+  public void tearDown() {
+    timeMockedStatic.close();
+  }
+
   @Test
   public void createDestinationPath() throws IOException, SemanticException, 
URISyntaxException {
-    mockStatic(FileSystem.class);
-    when(FileSystem.get(any(Configuration.class))).thenReturn(mockFs);
-    when(FileSystem.get(any(URI.class), 
any(Configuration.class))).thenReturn(mockFs);
+    MockedStatic<FileSystem> fileSystemMockedStatic = 
mockStatic(FileSystem.class);
+    MockedStatic<ReplCopyTask> ignoredReplCopyTaskMockedStatic = 
mockStatic(ReplCopyTask.class);
+    MockedStatic<CreateFunctionHandler> createFunctionHandlerMockedStatic = 
mockStatic(CreateFunctionHandler.class);
+
+    fileSystemMockedStatic.when(() -> 
FileSystem.get(any(Configuration.class))).thenReturn(mockFs);
+    fileSystemMockedStatic.when(() -> FileSystem.get(any(URI.class), 
any(Configuration.class))).thenReturn(mockFs);
+
     when(mockFs.getScheme()).thenReturn("hdfs");
     when(mockFs.getUri()).thenReturn(new URI("hdfs", "somehost:9000", null, 
null, null));
-    mockStatic(System.class);
-//    when(System.nanoTime()).thenReturn(Long.MAX_VALUE);
+
     when(functionObj.getFunctionName()).thenReturn("someFunctionName");
-    mockStatic(ReplCopyTask.class);
     Task mock = mock(Task.class);
     when(ReplCopyTask.getLoadCopyTask(any(ReplicationSpec.class), 
any(Path.class), any(Path.class),
-        any(HiveConf.class), any(), any())).thenReturn(mock);
-
+            any(HiveConf.class), any(), any())).thenReturn(mock);
     ResourceUri resourceUri = function.destinationResourceUri(new 
ResourceUri(ResourceType.JAR,
-        "hdfs://localhost:9000/user/someplace/ab.jar#e094828883"));
-
+            "hdfs://localhost:9000/user/someplace/ab.jar#e094828883"));
     assertThat(resourceUri.getUri(),
-        is(equalTo(
-            
"hdfs://somehost:9000/someBasePath/withADir/replicadbname/somefunctionname/" + 
String
-                .valueOf(0L) + "/ab.jar")));
+            is(equalTo(
+                    
"hdfs://somehost:9000/someBasePath/withADir/replicadbname/somefunctionname/" + 
String
+                            .valueOf(0L) + "/ab.jar")));

Review Comment:
   Unnecessary changes.



##########
ql/src/test/org/apache/hadoop/hive/ql/exec/repl/TestAtlasLoadTask.java:
##########
@@ -55,28 +56,24 @@ public void testAtlasLoadMetrics() throws Exception {
     atlasLoadTask = new AtlasLoadTask(conf, work);
     AtlasLoadTask atlasLoadTaskSpy = Mockito.spy(atlasLoadTask);
     
Mockito.when(conf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST_REPL)).thenReturn(true);
-    Logger logger = Mockito.mock(Logger.class);
-    Whitebox.setInternalState(ReplState.class, logger);
+    Logger logger = LoggerFactory.getLogger("ReplState");
+    StringAppender appender = StringAppender.createStringAppender(null);
+    appender.addToLogger(logger.getName(), Level.INFO);
+    appender.start();
     AtlasReplInfo atlasReplInfo = new 
AtlasReplInfo("http://localhost:21000/atlas";, "srcDB",
-        "tgtDB", "srcCluster", "tgtCluster", new Path("hdfs://tmp"), null, 
conf);
+            "tgtDB", "srcCluster", "tgtCluster", new Path("hdfs://tmp"), null, 
conf);

Review Comment:
   Unnecessary change.



-- 
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