MutablePermissions extends AbstractSet<Permission> implements Permissions { @Override public boolean add(final Permission permission) { checkNotNull(permission, "permission to be added"); return values.add(permission); } MutablePermissions(final Set<Permission> permissions);  MutablePermissions(final Collection<Permission> permissions); static Permissions none(); static Permissions all(); static Permissions of(final Permission permission, final Permission... furtherPermissions); @Override boolean contains(final Permission permission, final Permission... furtherPermissions); @Override boolean add(final Permission permission); @Override Iterator<Permission> iterator(); @Override int size(); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate); @Override JsonObject toJson(final JsonPointer pointer);  }
@Test(expected = NullPointerException.class) public void tryToAddNull() { underTest.add(null); }
@Test public void addNonExistingEntry() { final Permission read = Permission.READ; assertThat(underTest.add(read)).isTrue(); Assertions.assertThat(underTest).containsOnly(read); }
@Test public void addExistingEntryAgain() { underTest.add(Permission.READ); underTest.add(Permission.WRITE); assertThat(underTest.add(Permission.WRITE)).isFalse(); Assertions.assertThat(underTest).containsOnly(Permission.READ, Permission.WRITE); }
@Test public void removeExistingEntry() { final Permission write = Permission.WRITE; underTest.add(write); final Permission administrate = Permission.ADMINISTRATE; underTest.add(administrate); assertThat(underTest.remove(administrate)).isTrue(); Assertions.assertThat(underTest).containsOnly(write); }