BaseResource { public JSONObject getRequestObject() { return this.getRequestObject(true); } BaseResource(final RexsterApplication rexsterApplication); JSONObject generateErrorObject(String message); JSONObject generateErrorObjectJsonFail(Throwable source); JSONObject generateErrorObject(String message, Throwable source); JSONObject getRequestObject(); JSONObject getRequestObjectFlat(); JSONObject getRequestObject(final boolean parseToJson);  }
@Test public void testQueryParametersToJson() throws JSONException { Map<String, String> qp = new HashMap<String, String>(); qp.put("a", "true"); qp.put("b", "false"); qp.put("c.a", "12.0"); qp.put("c.b", "\"marko\""); qp.put("c.c", "peter"); qp.put("c.d.a.b", "true"); qp.put("d", "[marko,rodriguez,10]"); BaseResource tt = new MockResource(qp); Assert.assertTrue(tt.getRequestObject().optBoolean("a")); Assert.assertFalse(tt.getRequestObject().optBoolean("b")); Assert.assertEquals(12.0, tt.getRequestObject().optJSONObject("c").optDouble("a"), 0); Assert.assertEquals("\"marko\"", tt.getRequestObject().optJSONObject("c").optString("b")); Assert.assertEquals("peter", tt.getRequestObject().optJSONObject("c").optString("c")); Assert.assertTrue(tt.getRequestObject().optJSONObject("c").optJSONObject("d").optJSONObject("a").optBoolean("b")); Assert.assertEquals("marko", tt.getRequestObject().optJSONArray("d").optString(0)); Assert.assertEquals("rodriguez", tt.getRequestObject().optJSONArray("d").optString(1)); Assert.assertEquals("10", tt.getRequestObject().optJSONArray("d").optString(2)); }