I am trying to mock static method which always returns null.
try (MockedStatic<SecretsUtility> utilityMockedStatic = Mockito.mockStatic(SecretsUtility.class)) {
utilityMockedStatic.when(() -> SecretsUtility.readSecret(Mockito.anyString())).thenReturn("abc");
}
static method
public String readSecret(String secretPath)
throws SFEventProcessException {
try (FileInputStream fin = new FileInputStream(secretPath)) {
return secretValue;
} catch (IOException ex) {
throw new Exception(ex.getMessage());
}
}
I am not able to see secretPath while debugging, it says cannot find local variable secretPath.