private void populateMapWithLong(JSONObject jsonObject, HashMap<String, Long> hashMap) throws JSONException { Iterator keys = jsonObject.keys(); while (keys.hasNext()) { String key = keys.next().toString(); hashMap.put(key, jsonObject.getLong(key)); } }
@Nullable public static Long getOptionalLong(JSONObject jsonObject, String attributeName) throws JSONException { return jsonObject.has(attributeName) ? jsonObject.getLong(attributeName) : null; }
@Nullable public static Long getOptionalLong(final JSONObject jsonObject, final String attributeName) throws JSONException { return jsonObject.has(attributeName) ? jsonObject.getLong(attributeName) : null; }
@Override public BasicIssue parse(JSONObject json) throws JSONException { final URI selfUri = JsonParseUtil.getSelfUri(json); final String key = json.getString("key"); final Long id = json.getLong("id"); return new BasicIssue(selfUri, key, id); } }
@Override public ProjectRole parse(final JSONObject json) throws JSONException { final URI self = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String name = json.getString("name"); final String description = json.getString("description"); final Optional<JSONArray> roleActorsOpt = JsonParseUtil.getOptionalArray(json, "actors"); final Collection<RoleActor> roleActors = roleActorsOpt.isPresent() ? JsonParseUtil.parseJsonArray(roleActorsOpt.get(), roleActorJsonParser) : ImmutableSet.<RoleActor>of(); return new ProjectRole(id, self, name, description, roleActors); }
@Override public ProjectRole parse(final JSONObject json) throws JSONException { final URI self = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String name = json.getString("name"); final String description = json.getString("description"); final Optional<JSONArray> roleActorsOpt = JsonParseUtil.getOptionalArray(json, "actors"); final Collection<RoleActor> roleActors = roleActorsOpt.isPresent() ? JsonParseUtil.parseJsonArray(roleActorsOpt.get(), roleActorJsonParser) : ImmutableSet.<RoleActor>of(); return new ProjectRole(id, self, name, description, roleActors); }
@Override public BasicIssue parse(JSONObject json) throws JSONException { final URI selfUri = JsonParseUtil.getSelfUri(json); final String key = json.getString("key"); final Long id = json.getLong("id"); return new BasicIssue(selfUri, key, id); } }
@Override public ProjectRole parse(final JSONObject json) throws JSONException { final URI self = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String name = json.getString("name"); final String description = json.getString("description"); final Optional<JSONArray> roleActorsOpt = JsonParseUtil.getOptionalArray(json, "actors"); final Collection<RoleActor> roleActors = roleActorsOpt.isPresent() ? JsonParseUtil.parseJsonArray(roleActorsOpt.get(), roleActorJsonParser) : ImmutableSet.<RoleActor>of(); return new ProjectRole(id, self, name, description, roleActors); }
@Override public SecurityLevel parse(final JSONObject json) throws JSONException { final URI self = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String description = json.getString("description"); final String name = json.getString("name"); return new SecurityLevel(self, id, name, description); } }
@Override public Page<V> parse(final JSONObject json) throws JSONException { return new Page<>(json.getLong("startAt"), json.getInt("maxResults"), json.getBoolean("isLast"), valuesParser.parse(json.getJSONArray("values"))); } }
protected String validateGetNewApplicationJsonResponse(JSONObject json) throws JSONException { String appId = json.getString("application-id"); assertTrue(!appId.isEmpty()); JSONObject maxResources = json.getJSONObject("maximum-resource-capability"); long memory = maxResources.getLong("memory"); long vCores = maxResources.getLong("vCores"); assertTrue(memory != 0); assertTrue(vCores != 0); return appId; }
public void verifyAMSingleTask(JSONObject info, Task task) throws JSONException { assertEquals("incorrect number of elements", 9, info.length()); verifyTaskGeneric(task, info.getString("id"), info.getString("state"), info.getString("type"), info.getString("successfulAttempt"), info.getLong("startTime"), info.getLong("finishTime"), info.getLong("elapsedTime"), (float) info.getDouble("progress"), info.getString("status")); }
@Override public IssueType parse(JSONObject json) throws JSONException { final URI selfUri = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String name = json.getString("name"); final boolean isSubtask = json.getBoolean("subtask"); final String iconUrl = JsonParseUtil.getOptionalString(json, "iconUrl"); final URI iconUri = iconUrl == null ? null : JsonParseUtil.parseURI(iconUrl); final String description = JsonParseUtil.getOptionalString(json, "description"); return new IssueType(selfUri, id, name, isSubtask, description, iconUri); } }
@Override public IssueType parse(JSONObject json) throws JSONException { final URI selfUri = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String name = json.getString("name"); final boolean isSubtask = json.getBoolean("subtask"); final String iconUrl = JsonParseUtil.getOptionalString(json, "iconUrl"); final URI iconUri = iconUrl == null ? null : JsonParseUtil.parseURI(iconUrl); final String description = JsonParseUtil.getOptionalString(json, "description"); return new IssueType(selfUri, id, name, isSubtask, description, iconUri); } }
public void verifyAMInfo(JSONObject info, AppContext ctx) throws JSONException { assertEquals("incorrect number of elements", 5, info.length()); verifyAMInfoGeneric(ctx, info.getString("appId"), info.getString("user"), info.getString("name"), info.getLong("startedOn"), info.getLong("elapsedTime")); }
public static DelegationToken getDelegationTokenFromJson(JSONObject json) throws JSONException { DelegationToken ret = new DelegationToken(); if (json.has("token")) { ret.setToken(json.getString("token")); } else if (json.has("expiration-time")) { ret.setNextExpirationTime(json.getLong("expiration-time")); } return ret; }
public static DelegationToken getDelegationTokenFromJson(JSONObject json) throws JSONException { DelegationToken ret = new DelegationToken(); if (json.has("token")) { ret.setToken(json.getString("token")); } else if (json.has("expiration-time")) { ret.setNextExpirationTime(json.getLong("expiration-time")); } return ret; }
private void verifyAppAttemptsInfo(JSONObject info, RMAppAttempt appAttempt, String user) throws Exception { assertEquals("incorrect number of elements", 10, info.length()); verifyAppAttemptInfoGeneric(appAttempt, info.getInt("id"), info.getLong("startTime"), info.getString("containerId"), info.getString("nodeHttpAddress"), info.getString("nodeId"), info.getString("logsLink"), user); }
protected static void verifyAppTimeoutJson(JSONObject json, ApplicationTimeoutType type, String expireTime, long timeOutFromNow) throws JSONException { assertEquals("incorrect number of elements", 3, json.length()); assertEquals(type.toString(), json.getString("type")); assertEquals(expireTime, json.getString("expiryTime")); assertTrue(json.getLong("remainingTimeInSeconds") <= timeOutFromNow); }
public void verifyJobAttempts(JSONObject info, Job job) throws JSONException { JSONArray attempts = info.getJSONArray("jobAttempt"); assertEquals("incorrect number of elements", 2, attempts.length()); for (int i = 0; i < attempts.length(); i++) { JSONObject attempt = attempts.getJSONObject(i); verifyJobAttemptsGeneric(job, attempt.getString("nodeHttpAddress"), attempt.getString("nodeId"), attempt.getInt("id"), attempt.getLong("startTime"), attempt.getString("containerId"), attempt.getString("logsLink")); } }