ClientBuilder builder = ResteasyClientBuilder.newBuilder();
builder = builder.sslContext(sslContext);
builder = builder.hostnameVerifier((s1,s2)-> true);
我想模拟builder.hostnameVerifier
我以不同的方式尝试了它,
对于前2行,我可以模拟。我的代码如下:
PowerMockito.mockStatic(ResteasyClientBuilder.class);
PowerMockito.when(ResteasyClientBuilder.newBuilder()).thenReturn(clientBuilder);
PowerMockito.when(clientBuilder.sslContext(sslContext)).thenReturn(clientBuilder);
PowerMockito.when(this.verifier.verify(Matchers.anyString(), Matchers.anyObject())).thenReturn(true);
PowerMockito.when(clientBuilder.hostnameVerifier(this.verifier)).thenReturn(clientBuilder);