MutablePermissions extends AbstractSet<Permission> implements Permissions { @Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); for (final Permission permission : Permission.values()) { jsonObjectBuilder.set(permission.toJsonKey(), JsonFactory.newValue(values.contains(permission))); } return jsonObjectBuilder.build(); } 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 public void createJsonRepresentationOfEmptyMutablePermissions() { final JsonValue actualJsonValue = underTest.toJson(); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); for (final Permission permission : Permission.values()) { jsonObjectBuilder.set(permission.toJsonKey(), false); } final JsonObject expectedJsonObject = jsonObjectBuilder.build(); assertThat(actualJsonValue).isEqualTo(expectedJsonObject); }
@Test public void createJsonRepresentationOfMutablePermissions() { underTest.addAll(EnumSet.allOf(Permission.class)); final JsonValue actualJsonValue = underTest.toJson(); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); for (final Permission permission : Permission.values()) { jsonObjectBuilder.set(permission.toJsonKey(), true); } final JsonObject expectedJsonObject = jsonObjectBuilder.build(); assertThat(actualJsonValue).isEqualTo(expectedJsonObject); }