当前位置: 首页 > 知识库问答 >
问题:

MasterPass Merchant Server SDK-请求令牌Junit

翟嘉志
2023-03-14

问题:我面临着使用Mockito创建junit测试用例的问题。

代码:

public void invokeService(AuthTokenRequestBean requestBean) throws Exception {
        retrieveAuthTokenService = new RetrieveAuthTokenService(requestBean);
        when(processorFactory.createService(eq(RetrieveAuthTokenService.class),
                                              any(AuthTokenRequestBean.class))).
            thenReturn(retrieveAuthTokenService);
        Mockito.when(retrieveAuthTokenService.getOutput()).thenReturn(response);
        Mockito.when(retrieveAuthTokenService.process(any(FlowCtx.class))).thenReturn(response);
    }

例外情况:

共有1个答案

淳于玺
2023-03-14

我们可以使用PowerMockito模拟MasterPass SDK实现。因为它包含静态方法,并且可以使用PowerMockito进行模拟。

下面是代码段..

@mock private ProcessorFactory processorxxxx;

 类似资料:
  • 客户端通过使用按附录B“application/x-www-form-urlencoded”格式在HTTP请求实体正文中发送下列UTF-8字符编码的参数向令牌端点发起请求: grant_type 必需的。值必须设置为“client_credentials”。 scope 可选的。如3.3节所述的访问请求的范围。 客户端必须如3.2.1所述与授权服务器进行身份验证。 例如,客户端使用传输层安全发起如

  • 客户端通过使用按附录B“application/x-www-form-urlencoded”格式在HTTP请求实体正文中发送下列UTF-8字符编码的参数向令牌端点发起请求: grant_type 必需的。值必须设置为“password”。 username 必需的。资源所有者的用户名。 password 必需的。资源所有者的密码。 scope 可选的。如3.3节所述的访问请求的范围。 如果客户端类

  • 客户端通过使用按附录B“application/x-www-form-urlencoded”格式在HTTP请求实体正文中发送下列UTF-8字符编码的参数向令牌端点发起请求: grant_type 必需的。值必须被设置为“authorization_code”。 code 从授权服务器收到的授权码。 redirect_uri 必需的,若“redirect_uri”参数如4.1.1节所述包含在授权请求

  • 在过去的几天里,我一直在玩弄twitter应用编程接口,但似乎无法请求“请求令牌”。(流程A) 在twitterapi上,我应该达到以下终点(https://api.twitter.com/oauth/request_token)如果请求成功,则应向我提供一个,和)(应与我通过的匹配)。我试图只使用我的私钥,但这当然是失败的。我对如何生成此请求的理解是否错误? 我相信我的问题是如何生成。阅读twi

  • 嗨,我正在使用本教程 对于我的twitter测试项目,我已经更改了: 从 =new DefaultOAuthProvider("http://twitter.com/oauth/request_token","http://twitter.com/oauth/access_token","http://twitter.com/oauth/authorize"); 到 =new DefaultOAu