PolicyTrie { @SuppressWarnings("unchecked") JsonObject buildJsonView(final Iterable<JsonField> jsonFields, final Collection<String> subjectIds, final Permissions permissions) { final PolicyTrie defaultPolicyTrie = new PolicyTrie(grantRevokeIndex, Collections.emptyMap()); if (jsonFields instanceof JsonObject && ((JsonObject) jsonFields).isNull()) { return (JsonObject) jsonFields; } final JsonObjectBuilder outputObjectBuilder = JsonFactory.newObjectBuilder(); for (final JsonField field : jsonFields) { final JsonValue jsonView = getViewForJsonFieldOrNull(field, defaultPolicyTrie, subjectIds, permissions); if (null != jsonView) { outputObjectBuilder.set(field.getKey(), jsonView); } } return outputObjectBuilder.build(); } private  PolicyTrie(); private  PolicyTrie(final GrantRevokeIndex grantRevokeIndex, final Map<JsonKey, PolicyTrie> children);   }
@Test public void buildJsonViewOfNullValue() { final JsonObject createdJsonView = underTest.buildJsonView(JsonFactory.nullObject(), new HashSet<>(), Permissions.none()); final JsonObject expectedJsonView = JsonFactory.nullObject(); assertThat(createdJsonView).isEqualTo(expectedJsonView); }