'ApolloQueryCall Test in java
I am trying to test onResponse method. If I understand korrectly, when I call apolloQueryCall.enqueue , it should return response as response. When I run this code, it does not enter neither onResponse or onFailere. What am I missing? I could not find examples that work for me on the internet for Java.
String body = "{\n" +
" \"data\": {\n" +
" \"message\": \"kedi\"\n" +
" }\n" +
"}";
MockWebServer webServer = new MockWebServer();
MockResponse response = new MockResponse().setResponseCode(200).setBody(body);
webServer.enqueue(response);
var apolloClient = ApolloClient.builder()
.serverUrl(webServer.url("http://localhost/mock"))
.okHttpClient(okHttpClient)
.build();
var apolloQueryCall = apolloClient.query(query);
apolloQueryCall.enqueue(new ApolloCall.Callback<MyClass.Data>() {
@Override
public void onResponse(@NotNull Response<MyClass.Data> response) {
System.out.println("response:" + response);
}
@Override
public void onFailure(@NotNull ApolloException e) {
System.out.println(e.getMessage());
}
});
webServer.close();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
