コード例 #1
0
  @Test
  public void convertToJsonTest() throws MalformedObjectNameException, AttributeNotFoundException {
    File file = new File("myFile");

    Map ret = (Map) converter.convertToJson(file, null, JsonConvertOptions.DEFAULT);
    assertEquals(ret.get("name"), "myFile");
    String name =
        (String) converter.convertToJson(file, Arrays.asList("name"), JsonConvertOptions.DEFAULT);
    assertEquals(name, "myFile");
  }
コード例 #2
0
  @Test
  public void convertTransientValue() throws AttributeNotFoundException {
    TransientValueBean bean = new TransientValueBean();
    bean.value = "value";
    bean.transientValue = "transient";

    Map ret = (Map) converter.convertToJson(bean, null, JsonConvertOptions.DEFAULT);
    assertNull(ret.get("transientValue"));
    assertEquals(ret.get("value"), "value");
  }