RestImpl { void getRoomPinnedMessages(String roomId, BaseRoom.RoomType roomType, int offset, final PaginatedCallback<Message> callback) { checkNotNull(roomId,"roomId == null"); checkNotNull(roomType,"roomType == null"); checkNotNull(callback,"callback == null"); HttpUrl httpUrl = requestUrl(baseUrl, getRestApiMethodNameByRoomType(roomType, "messages")) .addQueryParameter("roomId", roomId) .addQueryParameter("offset", String.valueOf(offset)) .addQueryParameter("query", "{\"pinned\":true}") .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()); logger.info("Response = " + json.toString()); Type type = Types.newParameterizedType(List.class, Message.class); JsonAdapter<List<Message>> adapter = moshi.adapter(type); List<Message> messageList = adapter.fromJson(json.getJSONArray("messages").toString()); callback.onSuccess(messageList, json.optInt("total")); } 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 testGetRoomPinnedMessagesShouldFailWithNullRoomId() { rest.getRoomPinnedMessages(null, BaseRoom.RoomType.PUBLIC, 0, messagesCallback); }
@Test(expected = NullPointerException.class) public void testGetRoomPinnedMessagesShouldFailWithNullRoomType() { rest.getRoomPinnedMessages(null, null, 0, messagesCallback); }
@Test(expected = NullPointerException.class) public void testGetRoomPinnedMessagesShouldFailWithNullCallback() { rest.getRoomPinnedMessages(null, BaseRoom.RoomType.PUBLIC, 0, null); }