Merge branch 'master' into spring-cloud

This commit is contained in:
Spencer Gibb
2019-01-10 13:16:16 -05:00
8 changed files with 379 additions and 125 deletions

View File

@@ -20,6 +20,8 @@ import java.time.OffsetDateTime;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* An event that has been performed on an {@link Issue}.
@@ -28,6 +30,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*/
public class Event {
private static final Logger log = LoggerFactory.getLogger(Event.class);
private final Type type;
private final OffsetDateTime creationTime;
@@ -69,39 +73,9 @@ public class Event {
public enum Type {
/**
* The issue was closed by the actor.
* The issue was added to a project board.
*/
CLOSED("closed"),
/**
* The issue was reopened by the actor.
*/
REOPENED("reopened"),
/**
* The actor subscribed to receive notifications for an issue.
*/
SUBSCRIBED("subscribed"),
/**
* The actor unsubscribed from receibing notifications for an issue.
*/
UNSUBSCRIBED("unsubscribed"),
/**
* The issue was merged by the actor.
*/
MERGED("merged"),
/**
* The issue was referenced from a commit message.
*/
REFERENCED("referenced"),
/**
* The actor was {@code @mentioned} in an issue body.
*/
MENTIONED("mentioned"),
ADDED_TO_PROJECT("added_to_project"),
/**
* The issue was assigned to the actor.
@@ -109,45 +83,25 @@ public class Event {
ASSIGNED("assigned"),
/**
* The actor was unassigned from the issue.
* The issue was closed by the actor.
*/
UNASSIGNED("unassigned"),
CLOSED("closed"),
/**
* A label was added to the issue.
* A comment on the issue has been deleted by the actor.
*/
LABELED("labeled"),
COMMENT_DELETED("comment_deleted"),
/**
* A label was removed from the issue.
* The issue was created by converting a note in a project board to an issue.
*/
UNLABELED("unlabeled"),
/**
* The issue was added to a milestone.
*/
MILESTONED("milestoned"),
CONVERTED_NOTE_TO_ISSUE("converted_note_to_issue"),
/**
* The issue was removed from a milestone.
*/
DEMILESTONED("demilestoned"),
/**
* The issue title was changed.
*/
RENAMED("renamed"),
/**
* The issue was locked by the actor.
*/
LOCKED("locked"),
/**
* The issue was unlocked by the actor.
*/
UNLOCKED("unlocked"),
/**
* The pull request's branch was deleted.
*/
@@ -159,16 +113,106 @@ public class Event {
HEAD_REF_RESTORED("head_ref_restored"),
/**
* Something was added to project.
* A label was added to the issue.
*/
ADDED_TO_PROJECT("added_to_project"),
LABELED("labeled"),
/**
* Something was removed from project.
* The issue was locked by the actor.
*/
REMOVED_FROM_PROJECT("removed_from_project");
LOCKED("locked"),
private String type;
/**
* The issue was marked as a duplicate.
*/
MARKED_AS_DUPLICATE("marked_as_duplicate"),
/**
* The actor was {@code @mentioned} in an issue body.
*/
MENTIONED("mentioned"),
/**
* The issue was merged by the actor.
*/
MERGED("merged"),
/**
* The issue was added to a milestone.
*/
MILESTONED("milestoned"),
/**
* The issue was moved between columns in a project board.
*/
MOVED_COLUMNS_IN_PROJECT("moved_columns_in_project"),
/**
* The issue was referenced from a commit message.
*/
REFERENCED("referenced"),
/**
* The issue was removed from a project board.
*/
REMOVED_FROM_PROJECT("removed_from_project"),
/**
* The issue title was changed.
*/
RENAMED("renamed"),
/**
* The issue was reopened by the actor.
*/
REOPENED("reopened"),
/**
* The actor dismissed a review from the pull request.
*/
REVIEW_DISMISSED("review_dismissed"),
/**
* The actor requested a review from the subject on the pull request.
*/
REVIEW_REQUESTED("review_requested"),
/**
* The actor removed the review request from the subject on the pull request.
*/
REVIEW_REQUEST_REMOVED("review_request_removed"),
/**
* The actor subscribed to receive notifications for an issue.
*/
SUBSCRIBED("subscribed"),
/**
* The actor was unassigned from the issue.
*/
UNASSIGNED("unassigned"),
/**
* A label was removed from the issue.
*/
UNLABELED("unlabeled"),
/**
* The issue was unlocked by the actor.
*/
UNLOCKED("unlocked"),
/**
* The issue was unmarked as a duplicate.
*/
UNMARKED_AS_DUPLICATE("unmarked_as_duplicate"),
/**
* The actor unsubscribed from receiving notifications for an issue.
*/
UNSUBSCRIBED("unsubscribed");
private final String type;
Type(String type) {
this.type = type;
@@ -180,8 +224,10 @@ public class Event {
return value;
}
}
throw new IllegalArgumentException(
"'" + type + "' is not a valid event type");
if (log.isInfoEnabled()) {
log.info("Received unknown event type '" + type + "'");
}
return null;
}
}

View File

@@ -221,7 +221,7 @@ public class GitHubTemplateTests {
assertThat(pageOne.getContent()).hasSize(12);
Page<Event> pageTwo = pageOne.next();
assertThat(pageTwo).isNotNull();
assertThat(pageTwo.getContent()).hasSize(3);
assertThat(pageTwo.getContent()).hasSize(4);
}
@Test

View File

@@ -79,5 +79,34 @@
"commit_id": "ffd6e8d7eb944d8a3613e40e6aa1f6aa57127046",
"commit_url": "https://api.github.com/repos/spring-projects/spring-boot/commits/ffd6e8d7eb944d8a3613e40e6aa1f6aa57127046",
"created_at": "2015-12-02T14:02:24Z"
},
{
"actor": {
"avatar_url": "https://avatars0.githubusercontent.com/u/317776?v=4",
"events_url": "https://api.github.com/users/spring-projects/events{/privacy}",
"followers_url": "https://api.github.com/users/spring-projects/followers",
"following_url": "https://api.github.com/users/spring-projects/following{/other_user}",
"gists_url": "https://api.github.com/users/spring-projects/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/spring-projects",
"id": 317776,
"login": "spring-projects",
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMxNzc3Ng==",
"organizations_url": "https://api.github.com/users/spring-projects/orgs",
"received_events_url": "https://api.github.com/users/spring-projects/received_events",
"repos_url": "https://api.github.com/users/spring-projects/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/spring-projects/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/spring-projects/subscriptions",
"type": "Organization",
"url": "https://api.github.com/users/spring-projects"
},
"commit_id": null,
"commit_url": null,
"created_at": "2018-12-04T13:51:24Z",
"event": "comment_deleted",
"id": 2004328133,
"node_id": "MDE5OkNvbW1lbnREZWxldGVkRXZlbnQyMDA0MzI4MTMz",
"url": "https://api.github.com/repos/spring-projects/spring-boot/issues/events/2004328133"
}
]