@Test
public void testJsonOptions() {

    TestGsonConfiguration.AnnotatedDoc testDoc = new TestGsonConfiguration.AnnotatedDoc();
    testDoc.value = new TestGsonConfiguration.SomeComplexObject("complexA", "complexB");
    testDoc.sensitivePropertyOptions = "sensitive data1";
    testDoc.sensitiveUsageOption = "sensitive data2";
    Pattern containsWhitespacePattern = Pattern.compile("\\s");
    String jsonIncludeSensitiveAndBuiltInPrettyPrinted = Utils.toJson(EnumSet.noneOf(JsonMapper.JsonOptions.class), testDoc);
    assertThat(jsonIncludeSensitiveAndBuiltInPrettyPrinted, containsString("complexA"));
    assertThat(jsonIncludeSensitiveAndBuiltInPrettyPrinted, containsString("sensitive"));
    assertThat(jsonIncludeSensitiveAndBuiltInPrettyPrinted, containsString(ServiceDocument.FIELD_NAME_VERSION));
    assertTrue("pretty-printed JSON should have whitespaces",
            containsWhitespacePattern.matcher(jsonIncludeSensitiveAndBuiltInPrettyPrinted).find());
    String jsonExcludeSensitiveIncludesBuiltIn = Utils.toJson(EnumSet.of(JsonMapper.JsonOptions.EXCLUDE_SENSITIVE), testDoc);
    assertThat(jsonExcludeSensitiveIncludesBuiltIn, containsString("complexA"));
    assertThat(jsonExcludeSensitiveIncludesBuiltIn, not(containsString("sensitive")));
    assertThat(jsonExcludeSensitiveIncludesBuiltIn, containsString(ServiceDocument.FIELD_NAME_VERSION));
    String jsonIncludeSensitiveExcludeBuiltIn = Utils.toJson(EnumSet.of(JsonMapper.JsonOptions.EXCLUDE_BUILTIN), testDoc);
    assertThat(jsonIncludeSensitiveExcludeBuiltIn, containsString("complexA"));
    assertThat(jsonIncludeSensitiveExcludeBuiltIn, containsString("sensitive"));
    assertThat(jsonIncludeSensitiveExcludeBuiltIn, not(containsString(ServiceDocument.FIELD_NAME_VERSION)));
    String jsonExcludeSensitiveAndBuiltInCompact = Utils.toJson(
            EnumSet.of(JsonMapper.JsonOptions.EXCLUDE_SENSITIVE, JsonMapper.JsonOptions.EXCLUDE_BUILTIN, JsonMapper.JsonOptions.COMPACT),
            testDoc);
    assertThat(jsonExcludeSensitiveAndBuiltInCompact, containsString("complexA"));
    assertThat(jsonExcludeSensitiveAndBuiltInCompact, not(containsString("sensitive")));
    assertThat(jsonExcludeSensitiveAndBuiltInCompact, not(containsString(ServiceDocument.FIELD_NAME_VERSION)));
    assertFalse("compact JSON should not have whitespaces",
            containsWhitespacePattern.matcher(jsonExcludeSensitiveAndBuiltInCompact).find());
}