Code example for StringReader

0
 
  @Test 
  public void testLoadConfigFromJson_HappyPath() throws Exception 
  { 
    String json = "{\"intSetting\": 1,\"nestedConfig\":{\"stringSetting\":\"Hello\"},\"listSetting\":[{\"stringSetting\":\"item0\"},{\"stringSetting\":\"item1\"}]}";
    StringReader jsonReader = new StringReader(json);
 
    _configManager.loadConfigFromJson(jsonReader);
 
    DynamicConfig dynConfig = _configManager.getReadOnlyConfig();
    assertEquals("intSetting correct", 1, dynConfig.getIntSetting());
    assertEquals("nestedConfig.stringSetting correct", "Hello", 
                 dynConfig.getNestedConfig().getStringSetting());
    assertEquals("listSetting size correct", 2, dynConfig.getListSetting().size());
    assertEquals("listSetting[0].stringSetting", "item0", 
                 dynConfig.getListSetting(0).getStringSetting());
    assertEquals("listSetting[1].stringSetting", "item1", 
                 dynConfig.getListSetting(1).getStringSetting());
  } 
 
  @Test