InvisibleProgrammer commented on code in PR #4707:
URL: https://github.com/apache/hive/pull/4707#discussion_r1341354306
##########
ql/src/test/org/apache/hadoop/hive/ql/exec/repl/ranger/TestRangerRestClient.java:
##########
@@ -54,23 +55,26 @@ public class TestRangerRestClient {
@Mock
private HiveConf conf;
+ MockedStatic<UserGroupInformation> userGroupInformationMockedStatic;
+
@Before
public void setup() throws Exception {
- PowerMockito.mockStatic(UserGroupInformation.class);
-
Mockito.when(UserGroupInformation.getLoginUser()).thenReturn(userGroupInformation);
- Mockito.when(userGroupInformation.doAs((PrivilegedAction<Object>)
Mockito.any())).thenCallRealMethod();
- Mockito.when(userGroupInformation.doAs((PrivilegedExceptionAction<Object>)
Mockito.any())).thenCallRealMethod();
+ userGroupInformationMockedStatic = mockStatic(UserGroupInformation.class);
+
+
userGroupInformationMockedStatic.when(UserGroupInformation::getLoginUser).thenReturn(userGroupInformation);
+
Mockito.when(mockClient.getRangerExportUrl(Mockito.anyString(),
Mockito.anyString(), Mockito.anyString()))
- .thenCallRealMethod();
- Mockito.when(mockClient.getRangerImportUrl(Mockito.anyString(),
Mockito.anyString()))
- .thenCallRealMethod();
+ .thenCallRealMethod();
Mockito.when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_INTIAL_DELAY,
TimeUnit.SECONDS)).thenReturn(1L);
Mockito.when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_TOTAL_DURATION,
TimeUnit.SECONDS)).thenReturn(20L);
Mockito.when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_JITTER,
TimeUnit.SECONDS)).thenReturn(1L);
Mockito.when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_MAX_DELAY_BETWEEN_RETRIES,
TimeUnit.SECONDS))
- .thenReturn(10L);
-
Mockito.when(conf.getFloat(HiveConf.ConfVars.REPL_RETRY_BACKOFF_COEFFICIENT.varname,
1.0f))
Review Comment:
No. It was a leftover. Mockito is way more restrictive than PowerMock and it
doesn't allow stubbing. If I put it back into the code, it won't even run the
tests, it gets something like UnnecessaryStubbingException.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]