VisibilityJsonParser implements JsonParser<Visibility> { @Override public Visibility parse(JSONObject json) throws JSONException { final String type = json.getString("type"); final Visibility.Type visibilityType; if (ROLE_TYPE.equalsIgnoreCase(type)) { visibilityType = Visibility.Type.ROLE; } else if (GROUP_TYPE.equalsIgnoreCase(type)) { visibilityType = Visibility.Type.GROUP; } else { throw new JSONException("[" + type + "] does not represent a valid visibility type. Expected [" + ROLE_TYPE + "] or [" + GROUP_TYPE + "]."); } final String value = json.getString("value"); return new Visibility(visibilityType, value); }  @Override Visibility parse(JSONObject json); @Nullable Visibility parseVisibility(JSONObject parentObject);  }
@Test public void testParse() throws Exception { VisibilityJsonParser parser = new VisibilityJsonParser(); assertEquals(Visibility.group("jira-users"), parser.parse(getJsonObjectFromResource("/json/visibility/group.json"))); assertEquals(Visibility.role("Developers"), parser.parse(getJsonObjectFromResource("/json/visibility/role.json"))); }