public GitCommit deserialize(JsonObject jsonObject) { final String commitId = jsonObject.getString("commitId"); final String email = jsonObject.getString("email"); final String author = jsonObject.getString("author"); final String message = jsonObject.getString("message"); return new GitCommit(commitId, email, author, message); } }
public GitCommit deserialize(JsonObject jsonObject) { final String commitId = jsonObject.getString("commitId"); final String email = jsonObject.getString("email"); final String author = jsonObject.getString("author"); final String message = jsonObject.getString("message"); return new GitCommit(commitId, email, author, message); } }
public GitCommit deserialize(JsonObject jsonObject) { final String commitId = jsonObject.getString("commitId"); final String email = jsonObject.getString("email"); final String author = jsonObject.getString("author"); final String message = jsonObject.getString("message"); return new GitCommit(commitId, email, author, message); } }
/** * Parses GitHub JsonObject in accordance to the API * @param contributor Represent project contribution: https://developer.github.com/v3/repos/#list-contributors and * @param user Represent user: https://developer.github.com/v3/users/#get-a-single-user * @return Contributor object based on project contribution and user */ public static ProjectContributor toContributor(JsonObject contributor, JsonObject user) { String name = user.getString("name"); String login = user.getString("login"); String profileUrl = contributor.getString("html_url"); Integer numberOfContributors = contributor.getInteger("contributions"); return new DefaultProjectContributor(textOrEmpty(name), login, profileUrl, numberOfContributors); }
/** * Parses GitHub JsonObject in accordance to the API * @param contributor Represent project contribution: https://developer.github.com/v3/repos/#list-contributors and * @param user Represent user: https://developer.github.com/v3/users/#get-a-single-user * @return Contributor object based on project contribution and user */ public static ProjectContributor toContributor(JsonObject contributor, JsonObject user) { String name = user.getString("name"); String login = user.getString("login"); String profileUrl = contributor.getString("html_url"); Integer numberOfContributors = contributor.getInteger("contributions"); return new DefaultProjectContributor(textOrEmpty(name), login, profileUrl, numberOfContributors); }
/** * Parses GitHub JsonObject in accordance to the API * @param contributor Represent project contribution: https://developer.github.com/v3/repos/#list-contributors and * @param user Represent user: https://developer.github.com/v3/users/#get-a-single-user * @return Contributor object based on project contribution and user */ public static ProjectContributor toContributor(JsonObject contributor, JsonObject user) { String name = user.getString("name"); String login = user.getString("login"); String profileUrl = contributor.getString("html_url"); Integer numberOfContributors = contributor.getInteger("contributions"); return new DefaultProjectContributor(textOrEmpty(name), login, profileUrl, numberOfContributors); }
private boolean allStatusesPassed(JsonObject status) { if (status.getString("state").equals("success")) { return true; } if (hasErrorStates(status)) { Collection<JsonObject> statuses = status.getCollection("statuses"); JsonObject firstError = findFirstError(statuses); if (firstError != null) { throw new RuntimeException(String.format( "Pull request %s cannot be merged. %s. You can check details here: %s", task.getPullRequestUrl(), firstError.getString("description"), firstError.getString("targetUrl"))); } } return false; }
private boolean allStatusesPassed(JsonObject status) { if (status.getString("state").equals("success")) { return true; } if (hasErrorStates(status)) { Collection<JsonObject> statuses = status.getCollection("statuses"); JsonObject firstError = findFirstError(statuses); if (firstError != null) { throw new RuntimeException(String.format( "Pull request %s cannot be merged. %s. You can check details here: %s", task.getPullRequestUrl(), firstError.getString("description"), firstError.getString("targetUrl"))); } } return false; }
public DefaultImprovement deserialize(JsonObject jsonObject) { final Long id = jsonObject.getLong("id"); final String title = jsonObject.getString("title"); final String url = jsonObject.getString("url"); final Collection<String> labels = jsonObject.getCollection("labels"); final boolean isPullRequest = jsonObject.getBoolean("isPullRequest"); return new DefaultImprovement(id, title, url, labels, isPullRequest); } }
public DefaultImprovement deserialize(JsonObject jsonObject) { final Long id = jsonObject.getLong("id"); final String title = jsonObject.getString("title"); final String url = jsonObject.getString("url"); final Collection<String> labels = jsonObject.getCollection("labels"); final boolean isPullRequest = jsonObject.getBoolean("isPullRequest"); return new DefaultImprovement(id, title, url, labels, isPullRequest); } }
public DefaultImprovement deserialize(JsonObject jsonObject) { final Long id = jsonObject.getLong("id"); final String title = jsonObject.getString("title"); final String url = jsonObject.getString("url"); final Collection<String> labels = jsonObject.getCollection("labels"); final boolean isPullRequest = jsonObject.getBoolean("isPullRequest"); return new DefaultImprovement(id, title, url, labels, isPullRequest); } }
public static PullRequest toPullRequest(JsonObject pullRequest) { JsonObject head = (JsonObject) pullRequest.get("head"); String url = pullRequest.getString("url"); int prNumber = pullRequest.getInteger("number"); PullRequest openPullRequest = new PullRequest(); openPullRequest.setRef(head.getString("ref")); openPullRequest.setSha(head.getString("sha")); openPullRequest.setNumber(prNumber); openPullRequest.setUrl(url); return openPullRequest; }
public ContributorsSet deserialize() { String json = ""; ContributorsSet set = new DefaultContributorsSet(); try { json = IOUtil.readFully(file); LOG.info("Deserialize contributors from: {}", json); JsonArray array = (JsonArray) Jsoner.deserialize(json); for (Object object : array) { JsonObject jsonObject = (JsonObject) object; String name = jsonObject.getString("name"); String login = jsonObject.getString("login"); String profileUrl = jsonObject.getString("profileUrl"); set.addContributor(new DefaultContributor(name, login, profileUrl)); } } catch (Exception e) { throw new RuntimeException("Can't deserialize JSON: " + json, e); } return set; } }
public static PullRequest toPullRequest(JsonObject pullRequest) { JsonObject head = (JsonObject) pullRequest.get("head"); String url = pullRequest.getString("url"); int prNumber = pullRequest.getInteger("number"); PullRequest openPullRequest = new PullRequest(); openPullRequest.setRef(head.getString("ref")); openPullRequest.setSha(head.getString("sha")); openPullRequest.setNumber(prNumber); openPullRequest.setUrl(url); return openPullRequest; }
public ProjectContributorsSet deserialize(String json) { ProjectContributorsSet set = new DefaultProjectContributorsSet(); try { LOG.debug("Deserialize project contributors from: {}", json); JsonArray array = (JsonArray) Jsoner.deserialize(json); for (Object object : array) { JsonObject jsonObject = (JsonObject) object; String name = jsonObject.getString("name"); String login = jsonObject.getString("login"); String profileUrl = jsonObject.getString("profileUrl"); Integer numberOfContributions = jsonObject.getInteger("numberOfContributions"); set.addContributor(new DefaultProjectContributor(name, login, profileUrl, numberOfContributions)); } } catch (Exception e) { throw new RuntimeException("Can't deserialize JSON: " + json, e); } return set; } }
public ProjectContributorsSet deserialize(String json) { ProjectContributorsSet set = new DefaultProjectContributorsSet(); try { LOG.debug("Deserialize project contributors from: {}", json); JsonArray array = (JsonArray) Jsoner.deserialize(json); for (Object object : array) { JsonObject jsonObject = (JsonObject) object; String name = jsonObject.getString("name"); String login = jsonObject.getString("login"); String profileUrl = jsonObject.getString("profileUrl"); Integer numberOfContributions = jsonObject.getInteger("numberOfContributions"); set.addContributor(new DefaultProjectContributor(name, login, profileUrl, numberOfContributions)); } } catch (Exception e) { throw new RuntimeException("Can't deserialize JSON: " + json, e); } return set; } }
/** * Creates a Gist with the given fileContent and uploads it. * Returns the url that you can use to access the uploaded Gist. * * @param fileContent the content which will be uploaded */ public String uploadFile(String fileName, String fileContent) throws Exception { String body = getBody(fileName, fileContent); String response = gitHubApi.post("/gists", body); JsonObject responseJson = (JsonObject) Jsoner.deserialize(response); return responseJson.getString("html_url"); }
/** * Creates a Gist with the given fileContent and uploads it. * Returns the url that you can use to access the uploaded Gist. * * @param fileContent the content which will be uploaded */ public String uploadFile(String fileName, String fileContent) throws Exception { String body = getBody(fileName, fileContent); String response = gitHubApi.post("/gists", body); JsonObject responseJson = (JsonObject) Jsoner.deserialize(response); return responseJson.getString("html_url"); }