### Question:
ParseRESTCommand extends ParseRequest<JSONObject> { @Override protected ParseHttpBody newBody(ProgressCallback uploadProgressCallback) { if (jsonParameters == null) { String message = String.format("Trying to execute a %s command without body parameters.", method.toString()); throw new IllegalArgumentException(message); } try { JSONObject parameters = jsonParameters; if (method == ParseHttpRequest.Method.GET || method == ParseHttpRequest.Method.DELETE) { parameters = new JSONObject(jsonParameters.toString()); parameters.put(PARAMETER_METHOD_OVERRIDE, method.toString()); } return new ParseByteArrayHttpBody(parameters.toString(), "application/json"); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } ParseRESTCommand(
      String httpPath,
      ParseHttpRequest.Method httpMethod,
      Map<String, ?> parameters,
      String sessionToken);  ParseRESTCommand(
      String httpPath,
      ParseHttpRequest.Method httpMethod,
      JSONObject jsonParameters,
      String sessionToken); private  ParseRESTCommand(
      String httpPath,
      ParseHttpRequest.Method httpMethod,
      JSONObject jsonParameters,
      String localId, String sessionToken);   ParseRESTCommand(Init<?> builder); static ParseRESTCommand fromJSONObject(JSONObject jsonObject); @Override Task<JSONObject> executeAsync(
      final ParseHttpClient client,
      final ProgressCallback uploadProgressCallback,
      final ProgressCallback downloadProgressCallback,
      final Task<Void> cancellationToken); String getCacheKey(); JSONObject toJSONObject(); String getSessionToken(); String getOperationSetUUID(); void setLocalId(String localId); String getLocalId(); void resolveLocalIds(); void retainLocalIds(); void releaseLocalIds(); public String masterKey; }### Answer:
@Test public void testNewBodyWithNoJSONParameters() throws Exception { String httpPath = "www.parse.com"; String sessionToken = "sessionToken"; String localId = "localId"; ParseRESTCommand command = new ParseRESTCommand.Builder() .httpPath(httpPath) .method(ParseHttpRequest.Method.GET) .sessionToken(sessionToken) .localId(localId) .build(); thrown.expect(IllegalArgumentException.class); String message = String.format("Trying to execute a %s command without body parameters.", ParseHttpRequest.Method.GET.toString()); thrown.expectMessage(message); command.newBody(null); }
@Test public void testNewBody() throws Exception { String httpPath = "www.parse.com"; JSONObject jsonParameters = new JSONObject() .put("count", 1) .put("limit", 1); String sessionToken = "sessionToken"; String localId = "localId"; ParseRESTCommand command = new ParseRESTCommand.Builder() .httpPath(httpPath) .jsonParameters(jsonParameters) .method(ParseHttpRequest.Method.GET) .sessionToken(sessionToken) .localId(localId) .build(); ParseByteArrayHttpBody body = (ParseByteArrayHttpBody) command.newBody(null); JSONObject json = new JSONObject(new String(ParseIOUtils.toByteArray(body.getContent()))); assertEquals(1, json.getInt("count")); assertEquals(1, json.getInt("limit")); assertEquals(ParseHttpRequest.Method.GET.toString(), json.getString("_method")); assertEquals("application/json", body.getContentType()); }