  @Test
  public void testSerializedNameWithUnderscorePolicy() throws IOException {

    gson = new GsonBuilder()
        .registerTypeAdapterFactory(new AutoMatterTypeAdapterFactory())
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
        .create();
    final String json = gson.toJson(BAR); //isPrivate -> private
    final Bar parsed = gson.fromJson(json, Bar.class); //private -> isPrivate
    assertThat(parsed, is(BAR));
    //Make sure that tranlation of under_scored fields still work.
    final String underscoredIsPrivate = "{\"a\":17,\"b\":\"foobar\",\"is_private\":true}";
    assertThat(gson.fromJson(underscoredIsPrivate, Bar.class), is(BAR)); //is_private -> isPrivate
  }