ImmutableAccessControlList implements AccessControlList { public static AccessControlList fromJson(final JsonObject jsonObject) { checkNotNull(jsonObject, "JSON object"); final Set<AclEntry> aclEntries = new HashSet<>(); for (final JsonField jsonField : jsonObject) { final JsonKey jsonKey = jsonField.getKey(); if (!jsonKey.equals(JsonSchemaVersion.getJsonKey())) { aclEntries.add(AccessControlListModelFactory.newAclEntry(jsonKey, jsonField.getValue())); } } return new ImmutableAccessControlList(aclEntries); } private  ImmutableAccessControlList(final Map<AuthorizationSubject, AclEntry> theEntries); private  ImmutableAccessControlList(final Collection<AclEntry> theEntries); static AccessControlList empty(); static AccessControlList of(final AclEntry entry, final AclEntry... furtherEntries); static AccessControlList of(final Iterable<AclEntry> entries); static AccessControlList fromJson(final JsonObject jsonObject); @Override AccessControlList merge(final AclEntry entry); @Override AccessControlList merge(final AuthorizationSubject authorizationSubject, final Permission permission,
            final Permission... furtherPermissions); @Override AccessControlList merge(final Permission permission, final AuthorizationSubject authorizationSubject,
            final AuthorizationSubject... furtherAuthorizationSubjects); @Override AccessControlList setEntry(final AclEntry aclEntry); @Override AccessControlList setForAllAuthorizationSubjects(final Permissions permissions); @Override Set<AuthorizationSubject> getAuthorizedSubjectsFor(final Permission permission,
            final Permission... furtherPermissions); @Override boolean hasPermission(final AuthorizationContext authorizationContext, final Permission permission,
            final Permission... furtherPermissions); @Override boolean hasPermission(final AuthorizationSubject authorizationSubject, final Permission permission,
            final Permission... furtherPermissions); @Override Set<AuthorizationSubject> getAuthorizedSubjectsFor(final Permissions expectedPermissions); @Override boolean contains(final AuthorizationSubject authorizationSubject); @Override Optional<AclEntry> getEntryFor(final AuthorizationSubject authorizationSubject); @Override Permissions getPermissionsOf(final AuthorizationSubject authorizationSubject); @Override AccessControlList removeEntry(final AclEntry entry); @Override AccessControlList removePermission(final AuthorizationSubject authorizationSubject,
            final Permission permission, final Permission... furtherPermissions); @Override AccessControlList removeAllPermissionsOf(final AuthorizationSubject authorizationSubject); @Override boolean isEmpty(); @Override int getSize(); @Override Set<AclEntry> getEntriesSet(); @Override Stream<AclEntry> stream(); @Override Iterator<AclEntry> iterator(); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test(expected = NullPointerException.class) public void tryToCreateAclFromNullJsonObject() { ImmutableAccessControlList.fromJson((JsonObject) null); }
@Test public void createAccessControlListFromValidJson() { final JsonObject jsonObject = JsonFactory.newObjectBuilder() .set("ed420ff0-b1c96661e4-9070-3863bbc77d82", JsonFactory.newObjectBuilder() .set(Permission.READ.toJsonKey(), true) .set(Permission.WRITE.toJsonKey(), true) .set(Permission.ADMINISTRATE.toJsonKey(), false) .build()) .set("edca04a0-b1c96661e4-9070-3863bbc77d82", JsonFactory.newObjectBuilder() .set(Permission.READ.toJsonKey(), true) .set(Permission.WRITE.toJsonKey(), false) .set(Permission.ADMINISTRATE.toJsonKey(), false) .build()) .build(); final AccessControlList underTest = ImmutableAccessControlList.fromJson(jsonObject); assertThat(underTest).containsOnly( toAclEntry("ed420ff0-b1c96661e4-9070-3863bbc77d82", Permission.READ, Permission.WRITE), toAclEntry("edca04a0-b1c96661e4-9070-3863bbc77d82", Permission.READ)); }