RestImpl { void getUserChannelList(final SimpleListCallback<Subscription> callback) { checkNotNull(callback, "callback == null"); HttpUrl httpUrl = requestUrl(baseUrl, getRestApiMethodNameByRoomType(BaseRoom.RoomType.PUBLIC, "list.joined")) .build(); Request request = requestBuilder(httpUrl) .get() .build(); client.newCall(request).enqueue(new okhttp3.Callback() { @Override public void onFailure(Call call, IOException e) { callback.onError(new RocketChatNetworkErrorException("network error", e)); } @Override public void onResponse(Call call, Response response) throws IOException { if (!response.isSuccessful()) { processCallbackError(response, ERROR_HANDLER(callback)); return; } try { JSONObject json = new JSONObject(response.body().string()); Type type = Types.newParameterizedType(List.class, Subscription.class); JsonAdapter<List<Subscription>> adapter = moshi.adapter(type); List<Subscription> subscriptionList = adapter.fromJson(json.getJSONArray("channels").toString()); callback.onSuccess(subscriptionList); } catch (JSONException e) { callback.onError(new RocketChatInvalidResponseException(e.getMessage(), e)); } } }); } RestImpl(OkHttpClient client, Moshi moshi, HttpUrl baseUrl, TokenProvider tokenProvider, Logger logger);   }
@Test(expected = NullPointerException.class) public void testUserChannelListShouldFailWithNullCallback() { rest.getUserChannelList(null); }