質問

これは私のコードです(ジャージー1.4 + モキト1.8.5):

import org.junit.Test;
import static org.junit.Assert.*;
import com.sun.jersey.api.client.WebResource;
import static org.mockito.Mockito.*;
public FooTest {
  @Test public shouldMakeAHttpCall() {
    WebResource wr = mock(WebResource.class);
    doReturn(wr).when(wr).accept(anyVararg());
    doReturn("some text").when(wr).get(String.class);
  }
}

コンパイラは言う:

cannot find symbol: method accept(java.lang.Object)
location: class com.sun.jersey.api.client.WebResource

何か問題があります anyVargarg(), 、しかし、正確に何ですか?

役に立ちましたか?

解決

これが解決策です:

doReturn(wr).when(wr).accept((MediaType) anyVararg());

他のヒント

やってみました:

WebResource wr = mock(WebResource.class);
when(wr.accept(anyObject())).thenReturn(wr);
when(wr.get(anyString()).thenReturn("some text");
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top