TrieBasedPolicyEnforcer implements Enforcer { @Override public JsonObject buildJsonView(final ResourceKey resourceKey, final Iterable<JsonField> jsonFields, final AuthorizationContext authorizationContext, final Permissions permissions) { checkResourceKey(resourceKey); checkNotNull(jsonFields, "JSON fields"); checkPermissions(permissions); final JsonKey typeKey = JsonKey.of(resourceKey.getResourceType()); if (inheritedTrie.hasChild(typeKey)) { final PolicyTrie start = inheritedTrie.seekToLeastAncestor(PolicyTrie.getJsonKeyIterator(resourceKey)); return start.buildJsonView(jsonFields, authorizationContext.getAuthorizationSubjectIds(), permissions); } else { return JsonFactory.newObject(); } } private  TrieBasedPolicyEnforcer(final Iterable<PolicyEntry> policy); static TrieBasedPolicyEnforcer newInstance(final Policy policy); @Override boolean hasUnrestrictedPermissions(final ResourceKey resourceKey,
            final AuthorizationContext authorizationContext, final Permissions permissions); @Override boolean hasPartialPermissions(final ResourceKey resourceKey, final AuthorizationContext authorizationContext,
            final Permissions permissions); @Override EffectedSubjectIds getSubjectIdsWithPermission(final ResourceKey resourceKey,
            final Permissions permissions); @Override EffectedSubjects getSubjectsWithPermission(final ResourceKey resourceKey, final Permissions permissions); @Override Set<String> getSubjectIdsWithPartialPermission(final ResourceKey resourceKey,
            final Permissions permissions); @Override Set<AuthorizationSubject> getSubjectsWithPartialPermission(final ResourceKey resourceKey,
            final Permissions permissions); @Override JsonObject buildJsonView(final ResourceKey resourceKey,
            final Iterable<JsonField> jsonFields,
            final AuthorizationContext authorizationContext,
            final Permissions permissions);  }
@Test public void buildJsonView() { final TrieBasedPolicyEnforcer underTest = TrieBasedPolicyEnforcer.newInstance(defaultPolicy(PolicyId.of("namespace", "id"))); final JsonObject createdJsonView = underTest.buildJsonView( ResourceKey.newInstance("foo", "bar"), JsonFactory.nullObject(), AuthorizationContext.newInstance(DittoAuthorizationContextType.UNSPECIFIED, AuthorizationSubject.newInstance("itsMe")), Permissions.none()); final JsonObject expectedJsonView = JsonFactory.nullObject(); assertThat(createdJsonView).isEqualTo(expectedJsonView); }