Skip to content

Commit

Permalink
Merge branch 'annotatePojoClass' into changesFromCodeReview2
Browse files Browse the repository at this point in the history
  • Loading branch information
kasunsiyambalapitiya committed Mar 31, 2017
2 parents 2ce10d0 + 5d3ae06 commit 673a71a
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ private void saveRepoNames(String jsonText, String commitHash, String gitHubToke
} catch (JsonSyntaxException e) {
throw new CodeQualityMatricesException(e.getMessage(), e.getCause());
}
searchCommitPojo.getItems()
.forEach(recordItem -> repoLocation.add(recordItem.getRepository().getFull_name()));
searchCommitPojo.getContainingRepositories()
.forEach(recordItem -> repoLocation.add(recordItem.getRepository().getRepositoryLocation()));

logger.debug("Repositories having the given commit are successfully saved in an List");
SdkGitHubClient sdkGitHubClient = new SdkGitHubClient(gitHubToken);
Expand Down Expand Up @@ -271,12 +271,15 @@ private void readBlameForSelectedFile(String jsonText, List<String> changedRange
Map<Integer, Set<String>> ageWithParentCommit = new HashMap<>();
while (endLineNo >= startingLineNo) {
int finalStartingLineNo = startingLineNo; // to make a effective final variable
finalGraphQlResponse.getData().getRepository().getObject().getBlame().getRanges().stream()

finalGraphQlResponse.getResponse().getRepository().getFile().getBlame().getRanges().stream()

.filter(graphqlRange -> (graphqlRange.getStartingLine() <= finalStartingLineNo &&
graphqlRange.getEndingLine() >= finalStartingLineNo))
.forEach(graphqlRange -> {
int age = graphqlRange.getAge();
String url = graphqlRange.getCommit().getHistory().getEdges().get(1).getNode().getUrl();
String url = graphqlRange.getCommit().getHistory().getCommits().get(1).getDetails()
.getUrl();
/* get(1) is used directly as there are only 2 elements in the List<Edge> and last
resembles the parent commit
*/
Expand Down Expand Up @@ -352,7 +355,9 @@ private void saveAuthorCommits(String jsonText, String oldRange, List<String> li
endLineNo = Integer.parseInt(StringUtils.substringAfter(oldFileRange, ","));
while (endLineNo >= startingLineNo) {
int finalStartingLineNo = startingLineNo; // to make a effective final variable
graphQlResponse.getData().getRepository().getObject().getBlame().getRanges().stream()

graphQlResponse.getResponse().getRepository().getFile().getBlame().getRanges().stream()

.filter(graphqlRange -> (graphqlRange.getStartingLine() <= finalStartingLineNo &&
graphqlRange.getEndingLine() >= finalStartingLineNo))
.forEach(graphqlRange -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ private Map<String, Set<Integer>> savePrNumberAndRepoName(String jsonText) throw
Map<String, Set<Integer>> prNoWithRepoName = new HashMap<>();
try {
IssueApiResponse issueApiResponse = gson.fromJson(jsonText, IssueApiResponse.class);
issueApiResponse.getItems().parallelStream()
.filter(searchItem -> GITHUB_REVIEW_API_CLOSED_STATE.equals(searchItem.getState()))
issueApiResponse.getIssue().parallelStream()
.filter(searchItem -> GITHUB_REVIEW_API_CLOSED_STATE.equals(searchItem.getStateOfThePr()))

.filter(searchItem -> StringUtils.contains(searchItem.getRepositoryUrl(), "/wso2/"))
.forEach(searchItem -> {
String repositoryName = StringUtils.substringAfter(searchItem.getRepositoryUrl(),
"repos/");
int pullRequestNo = searchItem.getNumber();
int pullRequestNo = searchItem.getPrNumber();
prNoWithRepoName.putIfAbsent(repositoryName, new HashSet<>());
if (!prNoWithRepoName.get(repositoryName).contains(pullRequestNo)) {
prNoWithRepoName.get(repositoryName).add(pullRequestNo);
Expand Down Expand Up @@ -126,12 +127,12 @@ private void saveReviewers(Map<String, Set<Integer>> prNoWithRepoName, String gi
List<ReviewApiResponse> reviews = gson.fromJson(jsonText, List.class);
// to filter Approved users
reviews.parallelStream()
.filter(review -> GITHUB_REVIEW_APPROVED.equals(review.getState()))
.filter(review -> GITHUB_REVIEW_APPROVED.equals(review.getReviewState()))
.forEach(review -> approvedReviewers.add(review.getReviewer().getName()));
logger.debug("Users who approved the pull requests which introduce bug lines to the " +
"code base are successfully saved to approvedReviewers list");
reviews.parallelStream()
.filter(review -> GITHUB_REVIEW_COMMENTED.equals(review.getState()))
.filter(review -> GITHUB_REVIEW_COMMENTED.equals(review.getReviewState()))
.forEach(review -> commentedReviewers.add(review.getReviewer().getName()));
logger.debug("Users who commented on the pull requests which introduce bug lines to " +
"the code base are successfully saved to approvedReviewers list");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphQlResponse {
private GraphqlData data;
@SerializedName("data")
private GraphqlData response;

public GraphqlData getData() {
return data;
public GraphqlData getResponse() {
return response;
}

public void setData(GraphqlData data) {
this.data = data;
public void setResponse(GraphqlData response) {
this.response = response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlAuthor {
@SerializedName("name")
private String name;
private String email;

public String getName() {
return name;
Expand All @@ -32,12 +34,4 @@ public String getName() {
public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlBlame {

@SerializedName("ranges")
private List<GraphqlRange> ranges;

public List<GraphqlRange> getRanges() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlCommit {
@SerializedName("author")
private GraphqlAuthor author;
@SerializedName("history")
private GraphqlHistory history;
@SerializedName("url")
private String url;

public GraphqlAuthor getAuthor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlData {
@SerializedName("repository")
private GraphqlRepository repository;

public GraphqlRepository getRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlEdge {
private GraphqlNode node;
@SerializedName("node")
private GraphqlNode details;

public GraphqlNode getNode() {
return node;
public GraphqlNode getDetails() {
return details;
}

public void setNode(GraphqlNode node) {
this.node = node;
public void setDetails(GraphqlNode details) {
this.details = details;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlHistory {
private List<GraphqlEdge> edges;
@SerializedName("edges")
private List<GraphqlEdge> commits;

public List<GraphqlEdge> getEdges() {
return edges;
public List<GraphqlEdge> getCommits() {
return commits;
}

public void setEdges(List<GraphqlEdge> edges) {
this.edges = edges;
public void setCommits(List<GraphqlEdge> commits) {
this.commits = commits;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlNode {
@SerializedName("url")
private String url;

public String getUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlObject {
@SerializedName("blame")
private GraphqlBlame blame;

public GraphqlBlame getBlame() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlRange {
@SerializedName("startingLine")
private int startingLine;
@SerializedName("endingLine")
private int endingLine;
@SerializedName("age")
private int age;
@SerializedName("commit")
private GraphqlCommit commit;

public int getStartingLine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlRepository {
private GraphqlObject object;
@SerializedName("object")
private GraphqlObject file;

public GraphqlObject getObject() {
return object;
public GraphqlObject getFile() {
return file;
}

public void setObject(GraphqlObject object) {
this.object = object;
public void setFile(GraphqlObject file) {
this.file = file;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
* Pojo class used for parsing JSON response received from github REST API
*/
public class IssueApiResponse {
private List<SearchItem> items;
@SerializedName("items")
private List<SearchItem> issue;

public List<SearchItem> getItems() {
return items;
public List<SearchItem> getIssue() {
return issue;
}

public void setItems(List<SearchItem> items) {
this.items = items;
public void setIssue(List<SearchItem> issue) {
this.issue = issue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github REST API
*/
public class Repository {
private String full_name;
@SerializedName("full_name")
private String repositoryLocation;

public String getFull_name() {
return full_name;
public String getRepositoryLocation() {
return repositoryLocation;
}

public void setFull_name(String full_name) {
this.full_name = full_name;
public void setRepositoryLocation(String repositoryLocation) {
this.repositoryLocation = repositoryLocation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

package com.wso2.code.quality.matrices.model;

import com.google.gson.annotations.SerializedName;

/**
* Pojo class used for parsing JSON response received from github graphql API
*/
public class GraphqlItem {

public class RepositoryItem {
@SerializedName("repository")
private Repository repository;

public Repository getRepository() {
Expand Down
Loading

0 comments on commit 673a71a

Please sign in to comment.