@Test public void testParameterMapToJsonParsing() throws Exception { assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "1")), new JSONObject("{a:{b:{c:1}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "\"1\"")), new JSONObject("{a:{b:{c:\"1\"}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "true")), new JSONObject("{a:{b:{c:true}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "false")), new JSONObject("{a:{b:{c:false}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "null")), new JSONObject("{a:{b:{c:null}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b(0).c", "hello", "a.b(1).c", "hello")), new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "hello, true, false, null, 1,2, \"null\", \"()\"")), new JSONObject("{a:{b:{c:[\"hello\",true,false,null,1,2,\"null\",\"()\"]}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "\"hello, true, false, null, 1,2\"")), new JSONObject("{a:{b:{c:\"hello, true, false, null, 1,2\"}}}")); }
@Test public void testParameterMapToJsonParsing() throws Exception { assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "1")), new JSONObject("{a:{b:{c:1}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "\"1\"")), new JSONObject("{a:{b:{c:\"1\"}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "true")), new JSONObject("{a:{b:{c:true}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "false")), new JSONObject("{a:{b:{c:false}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "null")), new JSONObject("{a:{b:{c:null}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b(0).c", "hello", "a.b(1).c", "hello")), new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "hello, true, false, null, 1,2, \"null\", \"()\"")), new JSONObject("{a:{b:{c:[\"hello\",true,false,null,1,2,\"null\",\"()\"]}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "\"hello, true, false, null, 1,2\"")), new JSONObject("{a:{b:{c:\"hello, true, false, null, 1,2\"}}}")); }
@Test public void testParameterMapToJsonParsing() throws Exception { assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "1")), new JSONObject("{a:{b:{c:1}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "\"1\"")), new JSONObject("{a:{b:{c:\"1\"}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "true")), new JSONObject("{a:{b:{c:true}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "false")), new JSONObject("{a:{b:{c:false}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "null")), new JSONObject("{a:{b:{c:null}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b(0).c", "hello", "a.b(1).c", "hello")), new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "hello, true, false, null, 1,2, \"null\", \"()\"")), new JSONObject("{a:{b:{c:[\"hello\",true,false,null,1,2,\"null\",\"()\"]}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "\"hello, true, false, null, 1,2\"")), new JSONObject("{a:{b:{c:\"hello, true, false, null, 1,2\"}}}")); }
@Test public void testParameterMapToJsonParsing() throws Exception { assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "1")), new JSONObject("{a:{b:{c:1}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "\"1\"")), new JSONObject("{a:{b:{c:\"1\"}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "true")), new JSONObject("{a:{b:{c:true}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "false")), new JSONObject("{a:{b:{c:false}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "null")), new JSONObject("{a:{b:{c:null}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b(0).c", "hello", "a.b(1).c", "hello")), new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "hello, true, false, null, 1,2, \"null\", \"()\"")), new JSONObject("{a:{b:{c:[\"hello\",true,false,null,1,2,\"null\",\"()\"]}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "\"hello, true, false, null, 1,2\"")), new JSONObject("{a:{b:{c:\"hello, true, false, null, 1,2\"}}}")); }
@Test public void testParameterMapToJsonParsing() throws Exception { assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "1")), new JSONObject("{a:{b:{c:1}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "\"1\"")), new JSONObject("{a:{b:{c:\"1\"}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "true")), new JSONObject("{a:{b:{c:true}}}")); assertJsonEquals( JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "false")), new JSONObject("{a:{b:{c:false}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject(ImmutableMap.of("a.b.c", "null")), new JSONObject("{a:{b:{c:null}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b(0).c", "hello", "a.b(1).c", "hello")), new JSONObject("{a:{b:[{c:\"hello\"},{c:\"hello\"}]}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "hello, true, false, null, 1,2, \"null\", \"()\"")), new JSONObject("{a:{b:{c:[\"hello\",true,false,null,1,2,\"null\",\"()\"]}}}")); assertJsonEquals(JsonConversionUtil.parametersToJsonObject( ImmutableMap.of("a.b.c", "\"hello, true, false, null, 1,2\"")), new JSONObject("{a:{b:{c:\"hello, true, false, null, 1,2\"}}}")); }