ImmutableAccessControlList implements AccessControlList { @Override public AccessControlList setForAllAuthorizationSubjects(final Permissions permissions) { checkNotNull(permissions, "set with the permissions to set"); final AccessControlList result; if (entries.isEmpty()) { result = this; } else if (permissions.isEmpty()) { result = ImmutableAccessControlList.empty(); } else { final Set<AclEntry> newAclEntries = stream() .map(AclEntry::getAuthorizationSubject) .map(authSubject -> AccessControlListModelFactory.newAclEntry(authSubject, permissions)) .collect(Collectors.toSet()); result = of(newAclEntries); } return result; } 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 tryToSetNullPermissionsForAllAuthorizationSubjects() { underTest.setForAllAuthorizationSubjects(null); }
@Test public void setPermissionsForAllAuthorizationSubjects() { underTest = AccessControlList.newBuilder() .set(newAclEntry(KNOWN_AUTH_SUBJECT_FOO, Permission.READ, Permission.WRITE, Permission.ADMINISTRATE)) .set(newAclEntry(KNOWN_AUTH_SUBJECT_BAR, Permission.READ)) .set(newAclEntry(KNOWN_AUTH_SUBJECT_BAZ, Permission.WRITE)) .build(); assertThat(underTest).hasSize(3); final Permissions newPermissions = ThingsModelFactory.newPermissions(Permission.READ); underTest = underTest.setForAllAuthorizationSubjects(newPermissions); assertThat(underTest) .hasSize(3) .containsOnly(toAclEntry(KNOWN_AUTH_SUBJECT_FOO.getId(), Permission.READ), toAclEntry(KNOWN_AUTH_SUBJECT_BAR.getId(), Permission.READ), toAclEntry(KNOWN_AUTH_SUBJECT_BAZ.getId(), Permission.READ)); }