Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.github.core.tests/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java5
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitCommentPayloadTest.java43
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CreatePayloadTest.java48
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DeletePayloadTest.java43
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DownloadPayloadTest.java43
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventFormatterTest.java54
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventPayloadTest.java29
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventServiceTest.java202
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventTest.java75
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/FollowPayloadTest.java43
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkApplyPayloadTest.java45
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkPayloadTest.java43
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GistPayloadTest.java45
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPageTest.java49
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPayloadTest.java47
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueCommentPayloadTest.java49
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssuesPayloadTest.java45
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MemberPayloadTest.java45
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestPayloadTest.java47
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java53
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamAddPayloadTest.java51
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/WatchPayloadTest.java41
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/live/EventTest.java119
-rw-r--r--org.eclipse.egit.github.core/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/GollumPage.java112
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java128
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GsonUtils.java8
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java4
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CommitCommentPayload.java42
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CreatePayload.java93
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DeletePayload.java57
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DownloadPayload.java41
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java159
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/EventPayload.java24
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/FollowPayload.java41
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkApplyPayload.java75
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkPayload.java41
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GistPayload.java59
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GollumPayload.java42
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssueCommentPayload.java78
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssuesPayload.java59
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/MemberPayload.java59
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PublicPayload.java22
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PullRequestPayload.java78
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java96
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/TeamAddPayload.java79
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/WatchPayload.java39
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/EventService.java505
49 files changed, 3207 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core.tests/META-INF/MANIFEST.MF b/org.eclipse.egit.github.core.tests/META-INF/MANIFEST.MF
index 745945a4..c03eb907 100644
--- a/org.eclipse.egit.github.core.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.github.core.tests/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@ Import-Package: com.google.gson;version="[1.6.0,2.0.0)",
com.google.gson.reflect;version="[1.6.0,2.0.0)",
org.eclipse.egit.github.core;version="[1.3.0,1.4.0)",
org.eclipse.egit.github.core.client;version="[1.3.0,1.4.0)",
+ org.eclipse.egit.github.core.event;version="[1.3.0,1.4.0)",
org.eclipse.egit.github.core.service;version="[1.3.0,1.4.0)",
org.eclipse.egit.github.core.util;version="[1.3.0,1.4.0)",
org.mockito;version="[1.8.4,2.0.0)",
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
index fcb0ea5c..402a2df2 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
@@ -40,6 +40,10 @@ import org.junit.runners.Suite.SuiteClasses;
DownloadTest.class, //
DownloadResourceTest.class, //
EncodingUtilsTest.class, //
+ EventFormatterTest.class, //
+ EventPayloadTest.class, //
+ EventServiceTest.class, //
+ EventTest.class, //
FieldErrorTest.class, //
GistChangeStatusTest.class, //
GistFileTest.class, //
@@ -47,6 +51,7 @@ import org.junit.runners.Suite.SuiteClasses;
GistServiceTest.class, //
GistTest.class, //
GitHubClientTest.class, //
+ GollumPageTest.class, //
GsonUtilsTest.class, //
IdTest.class, //
IssueEventTest.class, //
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitCommentPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitCommentPayloadTest.java
new file mode 100644
index 00000000..2c1c1d26
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitCommentPayloadTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Comment;
+import org.eclipse.egit.github.core.event.CommitCommentPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link CommitCommentPayload}
+ */
+public class CommitCommentPayloadTest {
+
+ /**
+ * Test default state of CommitCommentPayload
+ */
+ @Test
+ public void defaultState() {
+ CommitCommentPayload payload = new CommitCommentPayload();
+ assertNull(payload.getComment());
+ }
+
+ /**
+ * Test updating CommitCommentPayload fields
+ */
+ @Test
+ public void updateFields() {
+ CommitCommentPayload payload = new CommitCommentPayload();
+ Comment comment = new Comment().setBody("comment");
+ assertEquals(comment, payload.setComment(comment).getComment());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CreatePayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CreatePayloadTest.java
new file mode 100644
index 00000000..e58c32a1
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CreatePayloadTest.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.event.CreatePayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link CreatePayload}
+ */
+public class CreatePayloadTest {
+
+ /**
+ * Test default state of CreatePayload
+ */
+ @Test
+ public void defaultState() {
+ CreatePayload payload = new CreatePayload();
+ assertNull(payload.getRefType());
+ assertNull(payload.getRef());
+ assertNull(payload.getMasterBranch());
+ assertNull(payload.getDescription());
+ }
+
+ /**
+ * Test updating CreatePayload fields
+ */
+ @Test
+ public void updateFields() {
+ CreatePayload payload = new CreatePayload();
+ assertEquals("branch", payload.setRefType("branch").getRefType());
+ assertEquals("ref", payload.setRef("ref").getRef());
+ assertEquals("master", payload.setMasterBranch("master").getMasterBranch());
+ assertEquals("description",
+ payload.setDescription("description").getDescription());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DeletePayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DeletePayloadTest.java
new file mode 100644
index 00000000..ffed2d32
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DeletePayloadTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.event.DeletePayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link DeletePayload}
+ */
+public class DeletePayloadTest {
+
+ /**
+ * Test default state of DeletePayload
+ */
+ @Test
+ public void defaultState() {
+ DeletePayload payload = new DeletePayload();
+ assertNull(payload.getRefType());
+ assertNull(payload.getRef());
+ }
+
+ /**
+ * Test updating DeletePayload fields
+ */
+ @Test
+ public void updateFields() {
+ DeletePayload payload = new DeletePayload();
+ assertEquals("branch", payload.setRefType("branch").getRefType());
+ assertEquals("ref", payload.setRef("ref").getRef());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DownloadPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DownloadPayloadTest.java
new file mode 100644
index 00000000..97f517b6
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DownloadPayloadTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Download;
+import org.eclipse.egit.github.core.event.DownloadPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link DownloadPayload}
+ */
+public class DownloadPayloadTest {
+
+ /**
+ * Test default state of DownloadPayload
+ */
+ @Test
+ public void defaultState() {
+ DownloadPayload payload = new DownloadPayload();
+ assertNull(payload.getDownload());
+ }
+
+ /**
+ * Test updating DownloadPayload fields
+ */
+ @Test
+ public void updateFields() {
+ DownloadPayload payload = new DownloadPayload();
+ Download download = new Download().setName("download");
+ assertEquals(download, payload.setDownload(download).getDownload());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventFormatterTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventFormatterTest.java
new file mode 100644
index 00000000..d507f30d
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventFormatterTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.egit.github.core.client.EventFormatter;
+import org.eclipse.egit.github.core.event.EventPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link EventFormatter} and subclasses
+ */
+public class EventFormatterTest {
+
+ /**
+ * Create instance of EventFormatter
+ */
+ @Test
+ public void createEventFormatterInstance() {
+ EventFormatter formatter = new EventFormatter();
+ assertNotNull(formatter.getEventCreator());
+ assertNotNull(formatter.getPayloadDeserializer());
+ }
+
+ /**
+ * Create instance of Event
+ */
+ @Test
+ public void createEventInstance() {
+ EventFormatter formatter = new EventFormatter();
+ assertNotNull(formatter.getEventCreator().createInstance(null));
+ }
+
+ /**
+ * Unknown event payload returned as EventPayload
+ */
+ @Test
+ public void unknownPayload() {
+ EventFormatter formatter = new EventFormatter();
+ formatter.getEventCreator().createInstance(null);
+ EventPayload payload = formatter.getPayloadDeserializer().deserialize(null, null, null);
+ assertTrue(payload instanceof EventPayload);
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventPayloadTest.java
new file mode 100644
index 00000000..811b0ad7
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventPayloadTest.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Tests for all subclasses of EventPayload
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ CommitCommentPayloadTest.class, CreatePayloadTest.class,
+ DeletePayloadTest.class, DownloadPayloadTest.class, FollowPayloadTest.class,
+ ForkApplyPayloadTest.class, ForkPayloadTest.class, GistPayloadTest.class,
+ GollumPayloadTest.class, IssueCommentPayloadTest.class, IssuesPayloadTest.class,
+ MemberPayloadTest.class, PullRequestPayloadTest.class, PushPayloadTest.class,
+ TeamAddPayloadTest.class, WatchPayloadTest.class })
+public class EventPayloadTest {
+ //EventPayload is an empty class, no tests to run.
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventServiceTest.java
new file mode 100644
index 00000000..c0269c90
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventServiceTest.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+
+import java.io.IOException;
+
+import org.eclipse.egit.github.core.RepositoryId;
+import org.eclipse.egit.github.core.client.GitHubClient;
+import org.eclipse.egit.github.core.client.GitHubRequest;
+import org.eclipse.egit.github.core.client.GitHubResponse;
+import org.eclipse.egit.github.core.client.PageIterator;
+import org.eclipse.egit.github.core.event.Event;
+import org.eclipse.egit.github.core.service.EventService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+/**
+ * Unit tests of {@link EventService}
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class EventServiceTest {
+
+ @Mock
+ private GitHubClient gitHubClient;
+
+ @Mock
+ private GitHubResponse response;
+
+ private EventService eventService;
+
+ /**
+ * Test case set up
+ *
+ * @throws IOException
+ */
+ @Before
+ public void before() throws IOException {
+ doReturn(response).when(gitHubClient).get(any(GitHubRequest.class));
+ eventService = new EventService(gitHubClient);
+ }
+
+ /**
+ * Create service with null client
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void constructorNullArgument() {
+ new EventService(null);
+ }
+
+ /**
+ * Create default service
+ */
+ @Test
+ public void defaultConstructor() {
+ assertNotNull(new EventService().getClient());
+ }
+
+ /**
+ * Page public events
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pagePublicEvents() throws IOException {
+ PageIterator<Event> iterator = eventService.pagePublicEvents();
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/events"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page events for repository
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageRepsitoryEvents() throws IOException {
+ RepositoryId repo = new RepositoryId("user", "repo");
+ PageIterator<Event> iterator = eventService.pageEvents(repo);
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/repos/user/repo/events"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page events for network of repositories
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageNetworkEvents() throws IOException {
+ RepositoryId repo = new RepositoryId("user", "repo");
+ PageIterator<Event> iterator = eventService.pageNetworkEvents(repo);
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/networks/user/repo/events"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page events for org
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageOrgEvents() throws IOException {
+ PageIterator<Event> iterator = eventService.pageOrgEvents("org");
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/orgs/org/events"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page received events for user
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageUserReceivedEvents() throws IOException {
+ PageIterator<Event> iterator = eventService.pageUserReceivedEvents("user");
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/users/user/received_events"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page public received events for user
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pagePublicUserReceivedEvents() throws IOException {
+ PageIterator<Event> iterator = eventService.pageUserReceivedEvents("user", true);
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/users/user/received_events/public"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page events for user
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageUserEvents() throws IOException {
+ PageIterator<Event> iterator = eventService.pageUserEvents("user");
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/users/user/events"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page public events for user
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pagePublicUserEvents() throws IOException {
+ PageIterator<Event> iterator = eventService.pageUserEvents("user", true);
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/users/user/events/public"), iterator
+ .getRequest().generateUri());
+ }
+
+ /**
+ * Page org events for user
+ *
+ * @throws IOException
+ */
+ @Test
+ public void pageUserOrgEvents() throws IOException {
+ PageIterator<Event> iterator = eventService.pageUserOrgEvents("user", "org");
+ assertNotNull(iterator);
+ assertTrue(iterator.hasNext());
+ assertEquals(Utils.page("/users/user/events/orgs/org"), iterator
+ .getRequest().generateUri());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventTest.java
new file mode 100644
index 00000000..4a62bd7a
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EventTest.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.User;
+import org.eclipse.egit.github.core.event.Event;
+import org.eclipse.egit.github.core.event.EventPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link Event}
+ */
+public class EventTest {
+
+ /**
+ * Test default state of event
+ */
+ @Test
+ public void defaultState() {
+ Event event = new Event();
+ assertNull(event.getType());
+ assertNull(event.getPayload());
+ assertNull(event.getRepo());
+ assertNull(event.getActor());
+ assertNull(event.getOrg());
+ assertNull(event.getCreatedAt());
+ assertFalse(event.isPublic());
+ }
+
+ /**
+ * Test updating event fields
+ */
+ @Test
+ public void updateFields() {
+ Event event = new Event();
+ assertEquals("PushEvent", event.setType("PushEvent").getType());
+ EventPayload payload = new EventPayload();
+ assertEquals(payload, event.setPayload(payload).getPayload());
+ Repository repo = new Repository().setName("repo");
+ assertEquals(repo, event.setRepo(repo).getRepo());
+ User actor = new User().setLogin("actor");
+ assertEquals(actor, event.setActor(actor).getActor());
+ User org = new User().setLogin("org");
+ assertEquals(org, event.setOrg(org).getOrg());
+ assertEquals(new Date(5000), event.setCreatedAt(new Date(5000)).getCreatedAt());
+ assertTrue(event.setPublic(true).isPublic());
+ }
+
+ /**
+ * Test non-mutable created at date
+ */
+ @Test
+ public void getCreatedAtReferenceMutableObject() {
+ Event event = new Event();
+ event.setCreatedAt(new Date(11111));
+ event.getCreatedAt().setTime(0);
+ assertTrue(event.getCreatedAt().getTime() != 0);
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/FollowPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/FollowPayloadTest.java
new file mode 100644
index 00000000..567f5de7
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/FollowPayloadTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.egit.github.core.User;
+import org.eclipse.egit.github.core.event.FollowPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link FollowPayload}
+ */
+public class FollowPayloadTest {
+
+ /**
+ * Test default state of FollowPayload
+ */
+ @Test
+ public void defaultState() {
+ FollowPayload payload = new FollowPayload();
+ assertNull(payload.getTarget());
+ }
+
+ /**
+ * Test updating FollowPayload fields
+ */
+ @Test
+ public void updateFields() {
+ FollowPayload payload = new FollowPayload();
+ User target = new User().setName("target");
+ assertEquals(target, payload.setTarget(target).getTarget());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkApplyPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkApplyPayloadTest.java
new file mode 100644
index 00000000..bfc4c913
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkApplyPayloadTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.event.ForkApplyPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link ForkApplyPayload}
+ */
+public class ForkApplyPayloadTest {
+
+ /**
+ * Test default state of ForkApplyPayload
+ */
+ @Test
+ public void defaultState() {
+ ForkApplyPayload payload = new ForkApplyPayload();
+ assertNull(payload.getHead());
+ assertNull(payload.getBefore());
+ assertNull(payload.getAfter());
+ }
+
+ /**
+ * Test updating ForkApplyPayload fields
+ */
+ @Test
+ public void updateFields() {
+ ForkApplyPayload payload = new ForkApplyPayload();
+ assertEquals("head", payload.setHead("head").getHead());
+ assertEquals("000", payload.setBefore("000").getBefore());
+ assertEquals("001", payload.setAfter("001").getAfter());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkPayloadTest.java
new file mode 100644
index 00000000..9e68251f
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/ForkPayloadTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.event.ForkPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link ForkPayload}
+ */
+public class ForkPayloadTest {
+
+ /**
+ * Test default state of ForkPayload
+ */
+ @Test
+ public void defaultState() {
+ ForkPayload payload = new ForkPayload();
+ assertNull(payload.getForkee());
+ }
+
+ /**
+ * Test updating ForkPayload fields
+ */
+ @Test
+ public void updateFields() {
+ ForkPayload payload = new ForkPayload();
+ Repository forkee = new Repository().setDescription("forkee");
+ assertEquals(forkee, payload.setForkee(forkee).getForkee());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GistPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GistPayloadTest.java
new file mode 100644
index 00000000..eb5e1375
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GistPayloadTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.egit.github.core.Gist;
+import org.eclipse.egit.github.core.event.GistPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link GistPayload}
+ */
+public class GistPayloadTest {
+
+ /**
+ * Test default state of GistPayload
+ */
+ @Test
+ public void defaultState() {
+ GistPayload payload = new GistPayload();
+ assertNull(payload.getAction());
+ assertNull(payload.getGist());
+ }
+
+ /**
+ * Test updating GistPayload fields
+ */
+ @Test
+ public void updateFields() {
+ GistPayload payload = new GistPayload();
+ Gist gist = new Gist().setId("id");
+ assertEquals("create", payload.setAction("create").getAction());
+ assertEquals(gist, payload.setGist(gist).getGist());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPageTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPageTest.java
new file mode 100644
index 00000000..cc291c93
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPageTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.egit.github.core.GollumPage;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link GollumPage}
+ */
+public class GollumPageTest {
+
+ /**
+ * Test default state of GollumPage
+ */
+ @Test
+ public void defaultState() {
+ GollumPage GollumPage = new GollumPage();
+ assertNull(GollumPage.getAction());
+ assertNull(GollumPage.getHtmlUrl());
+ assertNull(GollumPage.getPageName());
+ assertNull(GollumPage.getSha());
+ assertNull(GollumPage.getTitle());
+ }
+
+ /**
+ * Test updating GollumPage fields
+ */
+ @Test
+ public void updateFields() {
+ GollumPage GollumPage = new GollumPage();
+ assertEquals("create", GollumPage.setAction("create").getAction());
+ assertEquals("url://a", GollumPage.setHtmlUrl("url://a").getHtmlUrl());
+ assertEquals("page", GollumPage.setPageName("page").getPageName());
+ assertEquals("000", GollumPage.setSha("000").getSha());
+ assertEquals("title", GollumPage.setTitle("title").getTitle());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPayloadTest.java
new file mode 100644
index 00000000..a8648a86
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GollumPayloadTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.egit.github.core.GollumPage;
+import org.eclipse.egit.github.core.event.GollumPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link GollumPayload}
+ */
+public class GollumPayloadTest {
+
+ /**
+ * Test default state of GollumPayload
+ */
+ @Test
+ public void defaultState() {
+ GollumPayload payload = new GollumPayload();
+ assertNull(payload.getPages());
+ }
+
+ /**
+ * Test updating GollumPayload fields
+ */
+ @Test
+ public void updateFields() {
+ GollumPayload payload = new GollumPayload();
+ List<GollumPage> pages = new ArrayList<GollumPage>();
+ pages.add(new GollumPage().setPageName("page"));
+ assertEquals(pages, payload.setPages(pages).getPages());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueCommentPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueCommentPayloadTest.java
new file mode 100644
index 00000000..230b462c
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueCommentPayloadTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Comment;
+import org.eclipse.egit.github.core.Issue;
+import org.eclipse.egit.github.core.event.IssueCommentPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link IssueCommentPayload}
+ */
+public class IssueCommentPayloadTest {
+
+ /**
+ * Test default state of IssueCommentPayload
+ */
+ @Test
+ public void defaultState() {
+ IssueCommentPayload payload = new IssueCommentPayload();
+ assertNull(payload.getAction());
+ assertNull(payload.getIssue());
+ assertNull(payload.getComment());
+ }
+
+ /**
+ * Test updating IssueCommentPayload fields
+ */
+ @Test
+ public void updateFields() {
+ IssueCommentPayload payload = new IssueCommentPayload();
+ Issue issue = new Issue().setTitle("issue");
+ Comment comment = new Comment().setBody("comment");
+ assertEquals("create", payload.setAction("create").getAction());
+ assertEquals(issue, payload.setIssue(issue).getIssue());
+ assertEquals(comment, payload.setComment(comment).getComment());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssuesPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssuesPayloadTest.java
new file mode 100644
index 00000000..1c76d3a4
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssuesPayloadTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Issue;
+import org.eclipse.egit.github.core.event.IssuesPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link IssuesPayload}
+ */
+public class IssuesPayloadTest {
+
+ /**
+ * Test default state of IssuesPayload
+ */
+ @Test
+ public void defaultState() {
+ IssuesPayload payload = new IssuesPayload();
+ assertNull(payload.getAction());
+ assertNull(payload.getIssue());
+ }
+
+ /**
+ * Test updating IssuesPayload fields
+ */
+ @Test
+ public void updateFields() {
+ IssuesPayload payload = new IssuesPayload();
+ Issue issue = new Issue().setTitle("issue");
+ assertEquals("create", payload.setAction("create").getAction());
+ assertEquals(issue, payload.setIssue(issue).getIssue());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MemberPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MemberPayloadTest.java
new file mode 100644
index 00000000..b3e6808f
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MemberPayloadTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.egit.github.core.User;
+import org.eclipse.egit.github.core.event.MemberPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link MemberPayload}
+ */
+public class MemberPayloadTest {
+
+ /**
+ * Test default state of MemberPayload
+ */
+ @Test
+ public void defaultState() {
+ MemberPayload payload = new MemberPayload();
+ assertNull(payload.getMember());
+ assertNull(payload.getAction());
+ }
+
+ /**
+ * Test updating MemberPayload fields
+ */
+ @Test
+ public void updateFields() {
+ MemberPayload payload = new MemberPayload();
+ User member = new User().setLogin("member");
+ assertEquals(member, payload.setMember(member).getMember());
+ assertEquals("create", payload.setAction("create").getAction());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestPayloadTest.java
new file mode 100644
index 00000000..acbb9dda
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestPayloadTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.PullRequest;
+import org.eclipse.egit.github.core.event.PullRequestPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link PullRequestPayload}
+ */
+public class PullRequestPayloadTest {
+
+ /**
+ * Test default state of PullRequestPayload
+ */
+ @Test
+ public void defaultState() {
+ PullRequestPayload payload = new PullRequestPayload();
+ assertNull(payload.getAction());
+ assertEquals(0, payload.getNumber());
+ assertNull(payload.getPullRequest());
+ }
+
+ /**
+ * Test updating PullRequestPayload fields
+ */
+ @Test
+ public void updateFields() {
+ PullRequestPayload payload = new PullRequestPayload();
+ PullRequest pullRequest = new PullRequest().setTitle("pull");
+ assertEquals("create", payload.setAction("create").getAction());
+ assertEquals(9000, payload.setNumber(9000).getNumber());
+ assertEquals(pullRequest, payload.setPullRequest(pullRequest).getPullRequest());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java
new file mode 100644
index 00000000..e8ec3c78
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.egit.github.core.Commit;
+import org.eclipse.egit.github.core.event.PushPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link PushPayload}
+ */
+public class PushPayloadTest {
+
+ /**
+ * Test default state of PushPayload
+ */
+ @Test
+ public void defaultState() {
+ PushPayload payload = new PushPayload();
+ assertNull(payload.getHead());
+ assertNull(payload.getRef());
+ assertEquals(0, payload.getSize());
+ assertNull(payload.getCommits());
+ }
+
+ /**
+ * Test updating PushPayload fields
+ */
+ @Test
+ public void updateFields() {
+ PushPayload payload = new PushPayload();
+ List<Commit> commits = new ArrayList<Commit>();
+ commits.add(new Commit().setSha("000"));
+ assertEquals("head", payload.setHead("head").getHead());
+ assertEquals("ref", payload.setRef("ref").getRef());
+ assertEquals(9000, payload.setSize(9000).getSize());
+ assertEquals(commits, payload.setCommits(commits).getCommits());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamAddPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamAddPayloadTest.java
new file mode 100644
index 00000000..ad344de6
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamAddPayloadTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.Team;
+import org.eclipse.egit.github.core.User;
+import org.eclipse.egit.github.core.event.TeamAddPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link TeamAddPayload}
+ */
+public class TeamAddPayloadTest {
+
+ /**
+ * Test default state of TeamAddPayload
+ */
+ @Test
+ public void defaultState() {
+ TeamAddPayload payload = new TeamAddPayload();
+ assertNull(payload.getTeam());
+ assertNull(payload.getUser());
+ assertNull(payload.getRepo());
+ }
+
+ /**
+ * Test updating TeamAddPayload fields
+ */
+ @Test
+ public void updateFields() {
+ TeamAddPayload payload = new TeamAddPayload();
+ Team team = new Team().setName("team");
+ User user = new User().setLogin("user");
+ Repository repo = new Repository().setName("repo");
+ assertEquals(team, payload.setTeam(team).getTeam());
+ assertEquals(user, payload.setUser(user).getUser());
+ assertEquals(repo, payload.setRepo(repo).getRepo());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/WatchPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/WatchPayloadTest.java
new file mode 100644
index 00000000..7fb0eeaf
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/WatchPayloadTest.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.event.WatchPayload;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link WatchPayload}
+ */
+public class WatchPayloadTest {
+
+ /**
+ * Test default state of WatchPayload
+ */
+ @Test
+ public void defaultState() {
+ WatchPayload payload = new WatchPayload();
+ assertNull(payload.getAction());
+ }
+
+ /**
+ * Test updating WatchPayload fields
+ */
+ @Test
+ public void updateFields() {
+ WatchPayload payload = new WatchPayload();
+ assertEquals("create", payload.setAction("create").getAction());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/live/EventTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/live/EventTest.java
new file mode 100644
index 00000000..bbbead8e
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/live/EventTest.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests.live;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.eclipse.egit.github.core.client.PageIterator;
+import org.eclipse.egit.github.core.event.Event;
+import org.eclipse.egit.github.core.service.EventService;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link EventService}
+ */
+public class EventTest extends LiveTest {
+
+ /**
+ * Test paging through public gists
+ */
+ @Test
+ public void twoPublicEventPages() {
+ EventService service = new EventService(client);
+ PageIterator<Event> pages = service.pagePublicEvents(10);
+ assertNotNull(pages);
+ assertTrue(pages.hasNext());
+ Collection<Event> events = pages.next();
+ assertNotNull(events);
+ assertTrue(events.size() > 0);
+ for (Event event : events) {
+ assertNotNull(event);
+ assertNotNull(event.getCreatedAt());
+ assertNotNull(event.getPayload());
+ }
+ assertTrue(pages.hasNext());
+ events = pages.next();
+ assertNotNull(events);
+ assertTrue(events.size() > 0);
+ for (Event event : events) {
+ assertNotNull(event);
+ assertNotNull(event.getCreatedAt());
+ assertNotNull(event.getPayload());
+ }
+ }
+
+ /**
+ * Test paging current user's events
+ *
+ * @throws Exception
+ */
+ @Test
+ public void pageCurrentUsersEvents() throws Exception {
+ checkUser();
+ EventService service = new EventService(client);
+ Collection<Event> events = service.pageUserEvents(client.getUser(), false, 1).next();
+ assertNotNull(events);
+ assertTrue(events.size() > 0);
+ assertNotNull(events.toArray()[0]);
+ }
+
+ /**
+ * Test paging current user's public events
+ */
+ @Test
+ public void pageCurrentUsersPublicEvents() {
+ checkUser();
+ EventService service = new EventService(client);
+ Collection<Event> events = service.pageUserEvents(client.getUser(), true, 1).next();
+ assertNotNull(events);
+ assertTrue(events.size() > 0);
+ for (Event event : events) {
+ assertNotNull(event);
+ assertNotNull(event.getCreatedAt());
+ assertNotNull(event.getPayload());
+ }
+ }
+
+ /**
+ * Test paging current user's received events
+ */
+ @Test
+ public void pageCurrentUsersReceivedEvents() {
+ checkUser();
+ EventService service = new EventService(client);
+ Collection<Event> events = service.pageUserReceivedEvents(client.getUser(),
+ false, 1).next();
+ assertNotNull(events);
+ assertTrue(events.size() > 0);
+ assertNotNull(events.toArray()[0]);
+ }
+
+ /**
+ * Test paging current user's public received events
+ */
+ @Test
+ public void pageCurrentUsersPublicReceivedEvents() {
+ checkUser();
+ EventService service = new EventService(client);
+ Collection<Event> events = service.pageUserReceivedEvents(client.getUser(),
+ true, 1).next();
+ assertNotNull(events);
+ assertTrue(events.size() > 0);
+ for (Event event : events) {
+ assertNotNull(event);
+ assertNotNull(event.getCreatedAt());
+ assertNotNull(event.getPayload());
+ }
+ }
+}
diff --git a/org.eclipse.egit.github.core/META-INF/MANIFEST.MF b/org.eclipse.egit.github.core/META-INF/MANIFEST.MF
index 3a54338e..f9599683 100644
--- a/org.eclipse.egit.github.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.github.core/META-INF/MANIFEST.MF
@@ -11,5 +11,6 @@ Import-Package: com.google.gson;version="[1.6.0,2.0.0)",
com.google.gson.reflect;version="[1.6.0,2.0.0)"
Export-Package: org.eclipse.egit.github.core;version="1.3.0",
org.eclipse.egit.github.core.client;version="1.3.0",
+ org.eclipse.egit.github.core.event;version="1.3.0",
org.eclipse.egit.github.core.service;version="1.3.0",
org.eclipse.egit.github.core.util;version="1.3.0"
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/GollumPage.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/GollumPage.java
new file mode 100644
index 00000000..4c813f14
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/GollumPage.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core;
+
+import java.io.Serializable;
+
+/**
+ * Gollum Page model class.
+ */
+public class GollumPage implements Serializable {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = -5841603600916978606L;
+
+ private String pageName;
+
+ private String title;
+
+ private String action;
+
+ private String sha;
+
+ private String htmlUrl;
+
+ /**
+ * @return pageName
+ */
+ public String getPageName() {
+ return pageName;
+ }
+
+ /**
+ * @param pageName
+ * @return this page
+ */
+ public GollumPage setPageName(String pageName) {
+ this.pageName = pageName;
+ return this;
+ }
+
+ /**
+ * @return title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title
+ * @return this page
+ */
+ public GollumPage setTitle(String title) {
+ this.title = title;
+ return this;
+ }
+
+ /**
+ * @return action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action
+ * @return this page
+ */
+ public GollumPage setAction(String action) {
+ this.action = action;
+ return this;
+ }
+
+ /**
+ * @return sha
+ */
+ public String getSha() {
+ return sha;
+ }
+
+ /**
+ * @param sha
+ * @return this page
+ */
+ public GollumPage setSha(String sha) {
+ this.sha = sha;
+ return this;
+ }
+
+ /**
+ * @return htmlUrl
+ */
+ public String getHtmlUrl() {
+ return htmlUrl;
+ }
+
+ /**
+ * @param htmlUrl
+ * @return this page
+ */
+ public GollumPage setHtmlUrl(String htmlUrl) {
+ this.htmlUrl = htmlUrl;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java
new file mode 100644
index 00000000..74a3ec12
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.client;
+
+import com.google.gson.InstanceCreator;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+import java.lang.reflect.Type;
+
+import org.eclipse.egit.github.core.event.CommitCommentPayload;
+import org.eclipse.egit.github.core.event.CreatePayload;
+import org.eclipse.egit.github.core.event.DeletePayload;
+import org.eclipse.egit.github.core.event.DownloadPayload;
+import org.eclipse.egit.github.core.event.Event;
+import org.eclipse.egit.github.core.event.EventPayload;
+import org.eclipse.egit.github.core.event.FollowPayload;
+import org.eclipse.egit.github.core.event.ForkApplyPayload;
+import org.eclipse.egit.github.core.event.ForkPayload;
+import org.eclipse.egit.github.core.event.GistPayload;
+import org.eclipse.egit.github.core.event.GollumPayload;
+import org.eclipse.egit.github.core.event.IssueCommentPayload;
+import org.eclipse.egit.github.core.event.IssuesPayload;
+import org.eclipse.egit.github.core.event.MemberPayload;
+import org.eclipse.egit.github.core.event.PublicPayload;
+import org.eclipse.egit.github.core.event.PullRequestPayload;
+import org.eclipse.egit.github.core.event.PushPayload;
+import org.eclipse.egit.github.core.event.TeamAddPayload;
+import org.eclipse.egit.github.core.event.WatchPayload;
+
+/**
+ * Formats an event's payload with the appropriate class given a certain event
+ * type
+ */
+public class EventFormatter {
+
+ private class PayloadDeserializer implements JsonDeserializer<EventPayload> {
+
+ public EventPayload deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) throws JsonParseException {
+ String type = event.get().getType();
+ Class<? extends EventPayload> clazz = EventPayload.class;
+ if ("CommitCommentEvent".equals(type))
+ clazz = CommitCommentPayload.class;
+ else if ("CreateEvent".equals(type))
+ clazz = CreatePayload.class;
+ else if ("DeleteEvent".equals(type))
+ clazz = DeletePayload.class;
+ else if ("DownloadEvent".equals(type))
+ clazz = DownloadPayload.class;
+ else if ("FollowEvent".equals(type))
+ clazz = FollowPayload.class;
+ else if ("ForkEvent".equals(type))
+ clazz = ForkPayload.class;
+ else if ("ForkApplyEvent".equals(type))
+ clazz = ForkApplyPayload.class;
+ else if ("GistEvent".equals(type))
+ clazz = GistPayload.class;
+ else if ("GollumEvent".equals(type))
+ clazz = GollumPayload.class;
+ else if ("IssueCommentEvent".equals(type))
+ clazz = IssueCommentPayload.class;
+ else if ("IssuesEvent".equals(type))
+ clazz = IssuesPayload.class;
+ else if ("MemberEvent".equals(type))
+ clazz = MemberPayload.class;
+ else if ("PublicEvent".equals(type))
+ clazz = PublicPayload.class;
+ else if ("PullRequestEvent".equals(type))
+ clazz = PullRequestPayload.class;
+ else if ("PushEvent".equals(type))
+ clazz = PushPayload.class;
+ else if ("TeamAddEvent".equals(type))
+ clazz = TeamAddPayload.class;
+ else if ("WatchEvent".equals(type))
+ clazz = WatchPayload.class;
+
+ // payload not recognized
+ if (clazz == EventPayload.class)
+ return new EventPayload();
+
+ return context.deserialize(json, clazz);
+ }
+ }
+
+ private class EventCreator implements InstanceCreator<Event> {
+
+ public Event createInstance(Type type) {
+ final Event event = new Event();
+ EventFormatter.this.event.set(event);
+ return event;
+ }
+ }
+
+ private final ThreadLocal<Event> event = new ThreadLocal<Event>();
+
+ private final PayloadDeserializer payloadDeserializer = new PayloadDeserializer();
+
+ private final EventCreator eventCreator = new EventCreator();
+
+ /**
+ * Get deserializer for {@link EventPayload} objects
+ *
+ * @return deserializer
+ */
+ public JsonDeserializer<EventPayload> getPayloadDeserializer() {
+ return payloadDeserializer;
+ }
+
+ /**
+ * Get instance creator for {@link Event} objects
+ *
+ * @return instance creator
+ */
+ public InstanceCreator<Event> getEventCreator() {
+ return eventCreator;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GsonUtils.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GsonUtils.java
index ad233077..6adb331d 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GsonUtils.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GsonUtils.java
@@ -19,6 +19,9 @@ import java.io.Reader;
import java.lang.reflect.Type;
import java.util.Date;
+import org.eclipse.egit.github.core.event.Event;
+import org.eclipse.egit.github.core.event.EventPayload;
+
/**
* Gson utilities.
*/
@@ -48,6 +51,11 @@ public abstract class GsonUtils {
public static final Gson createGson(final boolean serializeNulls) {
final GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, new DateFormatter());
+ EventFormatter eventFormatter = new EventFormatter();
+ builder.registerTypeAdapter(Event.class,
+ eventFormatter.getEventCreator());
+ builder.registerTypeAdapter(EventPayload.class,
+ eventFormatter.getPayloadDeserializer());
builder.setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES);
if (serializeNulls)
builder.serializeNulls();
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
index 50bb83e2..9051c303 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
@@ -127,6 +127,8 @@ public interface IGitHubConstants {
/** */
String SEGMENT_MILESTONES = "/milestones"; //$NON-NLS-1$
/** */
+ String SEGMENT_NETWORKS = "/networks"; //$NON-NLS-1$
+ /** */
String SEGMENT_ORGANIZATIONS = "/organizations"; //$NON-NLS-1$
/** */
String SEGMENT_ORGS = "/orgs"; //$NON-NLS-1$
@@ -137,6 +139,8 @@ public interface IGitHubConstants {
/** */
String SEGMENT_PULLS = "/pulls"; //$NON-NLS-1$
/** */
+ String SEGMENT_RECEIVED_EVENTS = "/received_events"; //$NON-NLS-1$
+ /** */
String SEGMENT_REFS = "/refs"; //$NON-NLS-1$
/** */
String SEGMENT_REPOS = "/repos"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CommitCommentPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CommitCommentPayload.java
new file mode 100644
index 00000000..7a3983a4
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CommitCommentPayload.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.Comment;
+
+/**
+ * CommitCommentEvent payload model class.
+ */
+public class CommitCommentPayload extends EventPayload implements
+ Serializable {
+
+ private static final long serialVersionUID = -2606554911096551099L;
+
+ private Comment comment;
+
+ /**
+ * @return comment
+ */
+ public Comment getComment() {
+ return comment;
+ }
+
+ /**
+ * @param comment
+ * @return this CommitCommentPayload
+ */
+ public CommitCommentPayload setComment(Comment comment) {
+ this.comment = comment;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CreatePayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CreatePayload.java
new file mode 100644
index 00000000..8ee565fb
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/CreatePayload.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+/**
+ * CreateEvent payload model class.
+ */
+public class CreatePayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -7033027645721954674L;
+
+ private String refType;
+
+ private String ref;
+
+ private String masterBranch;
+
+ private String description;
+
+ /**
+ * @return refType
+ */
+ public String getRefType() {
+ return refType;
+ }
+
+ /**
+ * @param refType
+ * @return this CreatePayload
+ */
+ public CreatePayload setRefType(String refType) {
+ this.refType = refType;
+ return this;
+ }
+
+ /**
+ * @return ref
+ */
+ public String getRef() {
+ return ref;
+ }
+
+ /**
+ * @param ref
+ * @return this CreatePayload
+ */
+ public CreatePayload setRef(String ref) {
+ this.ref = ref;
+ return this;
+ }
+
+ /**
+ * @return masterBranch
+ */
+ public String getMasterBranch() {
+ return masterBranch;
+ }
+
+ /**
+ * @param masterBranch
+ * @return this CreatePayload
+ */
+ public CreatePayload setMasterBranch(String masterBranch) {
+ this.masterBranch = masterBranch;
+ return this;
+ }
+
+ /**
+ * @return description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description
+ * @return this CreatePayload
+ */
+ public CreatePayload setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DeletePayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DeletePayload.java
new file mode 100644
index 00000000..2015364e
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DeletePayload.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+/**
+ * DeleteEvent payload model class.
+ */
+public class DeletePayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -7571623946339106873L;
+
+ private String refType;
+
+ private String ref;
+
+ /**
+ * @return refType
+ */
+ public String getRefType() {
+ return refType;
+ }
+
+ /**
+ * @param refType
+ * @return this DeletePayload
+ */
+ public DeletePayload setRefType(String refType) {
+ this.refType = refType;
+ return this;
+ }
+
+ /**
+ * @return ref
+ */
+ public String getRef() {
+ return ref;
+ }
+
+ /**
+ * @param ref
+ * @return this DeletePayload
+ */
+ public DeletePayload setRef(String ref) {
+ this.ref = ref;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DownloadPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DownloadPayload.java
new file mode 100644
index 00000000..dff4337c
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/DownloadPayload.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.Download;
+
+/**
+ * DownloadEvent payload model class.
+ */
+public class DownloadPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 4246935370658381214L;
+
+ private Download download;
+
+ /**
+ * @return download
+ */
+ public Download getDownload() {
+ return download;
+ }
+
+ /**
+ * @param download
+ * @return this DownloadPayload
+ */
+ public DownloadPayload setDownload(Download download) {
+ this.download = download;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java
new file mode 100644
index 00000000..df813988
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.User;
+import org.eclipse.egit.github.core.util.DateUtils;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Event model class.
+ */
+public class Event implements Serializable {
+
+ private static final long serialVersionUID = 3633702964380402233L;
+
+ /**
+ * Make sure this is above payload.
+ * Payload deserialization depends on being able to read the type first.
+ */
+ private String type;
+
+ @SerializedName("public")
+ private boolean isPublic;
+
+ private EventPayload payload;
+
+ private Repository repo;
+
+ private User actor;
+
+ private User org;
+
+ private Date createdAt;
+
+ /**
+ * @return type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type
+ * @return this Event
+ */
+ public Event setType(String type) {
+ this.type = type;
+ return this;
+ }
+
+ /**
+ * @return isPublic
+ */
+ public boolean isPublic() {
+ return isPublic;
+ }
+
+ /**
+ * @param isPublic
+ * @return this Event
+ */
+ public Event setPublic(boolean isPublic) {
+ this.isPublic = isPublic;
+ return this;
+ }
+
+ /**
+ * @return the repo
+ */
+ public Repository getRepo() {
+ return repo;
+ }
+
+ /**
+ * @param repo
+ * @return this Event
+ */
+ public Event setRepo(Repository repo) {
+ this.repo = repo;
+ return this;
+ }
+
+ /**
+ * @return the actor
+ */
+ public User getActor() {
+ return actor;
+ }
+
+ /**
+ * @param actor
+ * @return this Event
+ */
+ public Event setActor(User actor) {
+ this.actor = actor;
+ return this;
+ }
+
+ /**
+ * @return the org
+ */
+ public User getOrg() {
+ return org;
+ }
+
+ /**
+ * @param org
+ * @return this Event
+ */
+ public Event setOrg(User org) {
+ this.org = org;
+ return this;
+ }
+
+ /**
+ * @return the createdAt
+ */
+ public Date getCreatedAt() {
+ return DateUtils.clone(createdAt);
+ }
+
+ /**
+ * @param createdAt
+ * @return this Event
+ */
+ public Event setCreatedAt(Date createdAt) {
+ this.createdAt = DateUtils.clone(createdAt);
+ return this;
+ }
+
+ /**
+ * @return payload
+ */
+ public EventPayload getPayload() {
+ return payload;
+ }
+
+ /**
+ * @param payload
+ * @return this event
+ */
+ public Event setPayload(EventPayload payload) {
+ this.payload = payload;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/EventPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/EventPayload.java
new file mode 100644
index 00000000..f68ae6f8
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/EventPayload.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+/**
+ * Parent class for event payloads
+ * @see <a href="http://developer.github.com/v3/events/types">GitHub Event
+ * types API documentation</a>
+ */
+public class EventPayload implements Serializable{
+
+ private static final long serialVersionUID = 1022083387039340606L;
+
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/FollowPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/FollowPayload.java
new file mode 100644
index 00000000..9b88b496
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/FollowPayload.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.User;
+
+/**
+ * FollowEvent payload model class.
+ */
+public class FollowPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -4345668254608800406L;
+
+ private User target;
+
+ /**
+ * @return target
+ */
+ public User getTarget() {
+ return target;
+ }
+
+ /**
+ * @param target
+ * @return this FollowPayload
+ */
+ public FollowPayload setTarget(User target) {
+ this.target = target;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkApplyPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkApplyPayload.java
new file mode 100644
index 00000000..9a863e3d
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkApplyPayload.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+/**
+ * ForkApplyEvent payload model class.
+ */
+public class ForkApplyPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -7527740351672699770L;
+
+ private String head;
+
+ private String before;
+
+ private String after;
+
+ /**
+ * @return head
+ */
+ public String getHead() {
+ return head;
+ }
+
+ /**
+ * @param head
+ * @return this ForkApplyPayload
+ */
+ public ForkApplyPayload setHead(String head) {
+ this.head = head;
+ return this;
+ }
+
+ /**
+ * @return before
+ */
+ public String getBefore() {
+ return before;
+ }
+
+ /**
+ * @param before
+ * @return this ForkApplyPayload
+ */
+ public ForkApplyPayload setBefore(String before) {
+ this.before = before;
+ return this;
+ }
+
+ /**
+ * @return after
+ */
+ public String getAfter() {
+ return after;
+ }
+
+ /**
+ * @param after
+ * @return this ForkApplyPayload
+ */
+ public ForkApplyPayload setAfter(String after) {
+ this.after = after;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkPayload.java
new file mode 100644
index 00000000..7b5cbd36
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ForkPayload.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.Repository;
+
+/**
+ * ForkEvent payload model class.
+ */
+public class ForkPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 2110456722558520113L;
+
+ private Repository forkee;
+
+ /**
+ * @return forkee
+ */
+ public Repository getForkee() {
+ return forkee;
+ }
+
+ /**
+ * @param forkee
+ * @return this ForkPayload
+ */
+ public ForkPayload setForkee(Repository forkee) {
+ this.forkee = forkee;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GistPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GistPayload.java
new file mode 100644
index 00000000..b2fc69f7
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GistPayload.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.Gist;
+
+/**
+ * GistEvent payload model class.
+ */
+public class GistPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 8916400800708594462L;
+
+ private String action;
+
+ private Gist gist;
+
+ /**
+ * @return action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action
+ * @return this GistPayload
+ */
+ public GistPayload setAction(String action) {
+ this.action = action;
+ return this;
+ }
+
+ /**
+ * @return gist
+ */
+ public Gist getGist() {
+ return gist;
+ }
+
+ /**
+ * @param gist
+ * @return this GistPayload
+ */
+ public GistPayload setGist(Gist gist) {
+ this.gist = gist;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GollumPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GollumPayload.java
new file mode 100644
index 00000000..c8b8ccff
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/GollumPayload.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.eclipse.egit.github.core.GollumPage;
+
+/**
+ * GollumEvent payload model class.
+ */
+public class GollumPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 7111499446827257290L;
+
+ private List<GollumPage> pages;
+
+ /**
+ * @return pages
+ */
+ public List<GollumPage> getPages() {
+ return pages;
+ }
+
+ /**
+ * @param pages
+ * @return this GollumPayload
+ */
+ public GollumPayload setPages(List<GollumPage> pages) {
+ this.pages = pages;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssueCommentPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssueCommentPayload.java
new file mode 100644
index 00000000..b272d76d
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssueCommentPayload.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.Comment;
+import org.eclipse.egit.github.core.Issue;
+
+/**
+ * IssueCommentEvent payload model class.
+ */
+public class IssueCommentPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 2661548417314120170L;
+
+ private String action;
+
+ private Issue issue;
+
+ private Comment comment;
+
+ /**
+ * @return action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action
+ * @return this IssueCommentPayload
+ */
+ public IssueCommentPayload setAction(String action) {
+ this.action = action;
+ return this;
+ }
+
+ /**
+ * @return issue
+ */
+ public Issue getIssue() {
+ return issue;
+ }
+
+ /**
+ * @param issue
+ * @return this IssueCommentPayload
+ */
+ public IssueCommentPayload setIssue(Issue issue) {
+ this.issue = issue;
+ return this;
+ }
+
+ /**
+ * @return comment
+ */
+ public Comment getComment() {
+ return comment;
+ }
+
+ /**
+ * @param comment
+ * @return this IssueCommentPayload
+ */
+ public IssueCommentPayload setComment(Comment comment) {
+ this.comment = comment;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssuesPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssuesPayload.java
new file mode 100644
index 00000000..eec591b0
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/IssuesPayload.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.Issue;
+
+/**
+ * IssuesEvent payload model class.
+ */
+public class IssuesPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 3210795492806809443L;
+
+ private String action;
+
+ private Issue issue;
+
+ /**
+ * @return action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action
+ * @return this IssuesPayload
+ */
+ public IssuesPayload setAction(String action) {
+ this.action = action;
+ return this;
+ }
+
+ /**
+ * @return issue
+ */
+ public Issue getIssue() {
+ return issue;
+ }
+
+ /**
+ * @param issue
+ * @return this IssuesPayload
+ */
+ public IssuesPayload setIssue(Issue issue) {
+ this.issue = issue;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/MemberPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/MemberPayload.java
new file mode 100644
index 00000000..64399a59
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/MemberPayload.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.User;
+
+/**
+ * MemberEvent payload model class.
+ */
+public class MemberPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -4261757812093447848L;
+
+ private User member;
+
+ private String action;
+
+ /**
+ * @return member
+ */
+ public User getMember() {
+ return member;
+ }
+
+ /**
+ * @param member
+ * @return this MemberPayload
+ */
+ public MemberPayload setMember(User member) {
+ this.member = member;
+ return this;
+ }
+
+ /**
+ * @return action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action
+ * @return this MemberPayload
+ */
+ public MemberPayload setAction(String action) {
+ this.action = action;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PublicPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PublicPayload.java
new file mode 100644
index 00000000..9758eca0
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PublicPayload.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+/**
+ * PublicEvent payload model class.
+ */
+public class PublicPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 5262549236565872052L;
+
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PullRequestPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PullRequestPayload.java
new file mode 100644
index 00000000..19a90241
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PullRequestPayload.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.PullRequest;
+
+/**
+ * PullRequestEvent payload model class.
+ */
+public class PullRequestPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -8234504270587265625L;
+
+ private String action;
+
+ private int number;
+
+ private PullRequest pullRequest;
+
+ /**
+ * @return action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action
+ * @return this PullRequestPayload
+ */
+ public PullRequestPayload setAction(String action) {
+ this.action = action;
+ return this;
+ }
+
+ /**
+ * @return number
+ */
+ public int getNumber() {
+ return number;
+ }
+
+ /**
+ * @param number
+ * @return this PullRequestPayload
+ */
+ public PullRequestPayload setNumber(int number) {
+ this.number = number;
+ return this;
+ }
+
+ /**
+ * @return pullRequest
+ */
+ public PullRequest getPullRequest() {
+ return pullRequest;
+ }
+
+ /**
+ * @param pullRequest
+ * @return this PullRequestPayload
+ */
+ public PullRequestPayload setPullRequest(PullRequest pullRequest) {
+ this.pullRequest = pullRequest;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java
new file mode 100644
index 00000000..069e0f48
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.eclipse.egit.github.core.Commit;
+
+/**
+ * PushEvent payload model class.
+ */
+public class PushPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -1542484898531583478L;
+
+ private String head;
+
+ private String ref;
+
+ private int size;
+
+ private List<Commit> commits;
+
+ /**
+ * @return head
+ */
+ public String getHead() {
+ return head;
+ }
+
+ /**
+ * @param head
+ * @return this PushEvent
+ */
+ public PushPayload setHead(String head) {
+ this.head = head;
+ return this;
+ }
+
+ /**
+ * @return ref
+ */
+ public String getRef() {
+ return ref;
+ }
+
+ /**
+ * @param ref
+ * @return this PushEvent
+ */
+ public PushPayload setRef(String ref) {
+ this.ref = ref;
+ return this;
+ }
+
+ /**
+ * @return size
+ */
+ public int getSize() {
+ return size;
+ }
+
+ /**
+ * @param size
+ * @return this PushEvent
+ */
+ public PushPayload setSize(int size) {
+ this.size = size;
+ return this;
+ }
+
+ /**
+ * @return commits
+ */
+ public List<Commit> getCommits() {
+ return commits;
+ }
+
+ /**
+ * @param commits
+ * @return this PushEvent
+ */
+ public PushPayload setCommits(List<Commit> commits) {
+ this.commits = commits;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/TeamAddPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/TeamAddPayload.java
new file mode 100644
index 00000000..5cb02474
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/TeamAddPayload.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.Team;
+import org.eclipse.egit.github.core.User;
+
+/**
+ * TeamAddEvent payload model class
+ */
+public class TeamAddPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = 7660176723347977144L;
+
+ private Team team;
+
+ private User user;
+
+ private Repository repo;
+
+ /**
+ * @return team
+ */
+ public Team getTeam() {
+ return team;
+ }
+
+ /**
+ * @param team
+ * @return this TeamAddPayload
+ */
+ public TeamAddPayload setTeam(Team team) {
+ this.team = team;
+ return this;
+ }
+
+ /**
+ * @return user
+ */
+ public User getUser() {
+ return user;
+ }
+
+ /**
+ * @param user
+ * @return this TeamAddPayload
+ */
+ public TeamAddPayload setUser(User user) {
+ this.user = user;
+ return this;
+ }
+
+ /**
+ * @return repo
+ */
+ public Repository getRepo() {
+ return repo;
+ }
+
+ /**
+ * @param repo
+ * @return this TeamAddPayload
+ */
+ public TeamAddPayload setRepo(Repository repo) {
+ this.repo = repo;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/WatchPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/WatchPayload.java
new file mode 100644
index 00000000..0dd4f061
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/WatchPayload.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.event;
+
+import java.io.Serializable;
+
+/**
+ * WatchEvent payload model class.
+ */
+public class WatchPayload extends EventPayload implements Serializable {
+
+ private static final long serialVersionUID = -1600566006173513492L;
+
+ private String action;
+
+ /**
+ * @return action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action
+ * @return this WatchPayload
+ */
+ public WatchPayload setAction(String action) {
+ this.action = action;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/EventService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/EventService.java
new file mode 100644
index 00000000..a464268e
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/EventService.java
@@ -0,0 +1,505 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jason Tsay (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.service;
+
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_EVENTS;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_NETWORKS;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_ORGS;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_PUBLIC;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_RECEIVED_EVENTS;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_USERS;
+
+import java.util.List;
+
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
+import org.eclipse.egit.github.core.client.GitHubClient;
+import org.eclipse.egit.github.core.client.PageIterator;
+import org.eclipse.egit.github.core.client.PagedRequest;
+import org.eclipse.egit.github.core.event.Event;
+
+import com.google.gson.reflect.TypeToken;
+
+/**
+ * Service class for interacting with Events
+ *
+ * @see <a href="http://developer.github.com/v3/events">GitHub Event API
+ * documentation</a>
+ * @see <a href="http://developer.github.com/v3/events/types">GitHub Event
+ * types API documentation</a>
+ */
+public class EventService extends GitHubService {
+
+ /**
+ * Create event service
+ */
+ public EventService() {
+ super();
+ }
+
+ /**
+ * Create event service
+ *
+ * @param client
+ */
+ public EventService(GitHubClient client) {
+ super(client);
+ }
+
+ /**
+ * Create page iterator for all public events
+ *
+ * @return events page iterator
+ */
+ public PageIterator<Event> pagePublicEvents() {
+ return pagePublicEvents(PagedRequest.PAGE_SIZE);
+ }
+
+ /**
+ * Create page iterator for all public events
+ *
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pagePublicEvents(final int size) {
+ return pagePublicEvents(PagedRequest.PAGE_FIRST, size);
+ }
+
+ /**
+ * Create page iterator for all public events
+ *
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pagePublicEvents(final int start, final int size) {
+ PagedRequest<Event> request = createPagedRequest(start, size);
+ request.setUri(SEGMENT_EVENTS);
+ request.setType(new TypeToken<List<Event>>() {
+ }.getType());
+ return createPageIterator(request);
+ }
+
+ /**
+ * Create page iterator for a given repo's events
+ *
+ * @param repository
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageEvents(IRepositoryIdProvider repository) {
+ return pageEvents(repository, PagedRequest.PAGE_SIZE);
+ }
+
+ /**
+ * Create page iterator for a given repo's events
+ *
+ * @param repository
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageEvents(IRepositoryIdProvider repository,
+ final int size) {
+ return pageEvents(repository, PagedRequest.PAGE_FIRST, size);
+ }
+
+ /**
+ * Create page iterator for a given repo's events
+ *
+ * @param repository
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageEvents(IRepositoryIdProvider repository,
+ final int start, final int size) {
+ PagedRequest<Event> request = createRepoEventRequest(repository, start, size);
+ return createPageIterator(request);
+ }
+
+ /**
+ * Create page iterator for a given repo network's events
+ *
+ * @param repository
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageNetworkEvents(IRepositoryIdProvider repository) {
+ return pageNetworkEvents(repository, PagedRequest.PAGE_SIZE);
+ }
+
+ /**
+ * Create page iterator for a given repo network's events
+ *
+ * @param repository
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageNetworkEvents(IRepositoryIdProvider repository,
+ final int size) {
+ return pageNetworkEvents(repository, PagedRequest.PAGE_FIRST, size);
+ }
+
+ /**
+ * Create page iterator for a given repo network's events
+ *
+ * @param repository
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageNetworkEvents(IRepositoryIdProvider repository,
+ final int start, final int size) {
+ PagedRequest<Event> request = createNetworkRepoEventRequest(repository,
+ start, size);
+ return createPageIterator(request);
+ }
+
+ /**
+ * Create page iterator for a given org's events
+ *
+ * @param org
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageOrgEvents(String org) {
+ return pageOrgEvents(org, PagedRequest.PAGE_SIZE);
+ }
+
+ /**
+ * Create page iterator for a given org's events
+ *
+ * @param org
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageOrgEvents(String org, final int size) {
+ return pageOrgEvents(org, PagedRequest.PAGE_FIRST, size);
+ }
+
+ /**
+ * Create page iterator for a given org's events
+ *
+ * @param org
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageOrgEvents(String org, final int start,
+ final int size) {
+ PagedRequest<Event> request = createOrgEventRequest(org, start, size);
+ return createPageIterator(request);
+ }
+
+ /**
+ * Create page iterator for a given user's received events
+ * Returns private events if authenticated as the user
+ *
+ * @param user
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserReceivedEvents(String user) {
+ return pageUserReceivedEvents(user, false);
+ }
+
+ /**
+ * Create page iterator for a given user's received events
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserReceivedEvents(String user, boolean isPublic) {
+ return pageUserReceivedEvents(user, isPublic, PagedRequest.PAGE_SIZE);
+ }
+
+
+ /**
+ * Create page iterator for a given user's received events
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserReceivedEvents(String user,
+ boolean isPublic, final int size) {
+ return pageUserReceivedEvents(user, isPublic, PagedRequest.PAGE_FIRST, size);
+ }
+
+ /**
+ * Create page iterator for a given user's received events
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserReceivedEvents(String user, boolean isPublic,
+ final int start, final int size) {
+ PagedRequest<Event> request = createUserReceivedEventRequest(user,
+ isPublic, start, size);
+ return createPageIterator(request);
+ }
+
+ /**
+ * Create page iterator for a given user's events
+ * Returns private events if authenticated as the user
+ *
+ * @param user
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserEvents(String user) {
+ return pageUserEvents(user, false);
+ }
+
+ /**
+ * Create page iterator for a given user's events
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserEvents(String user, boolean isPublic) {
+ return pageUserEvents(user, isPublic, PagedRequest.PAGE_SIZE);
+ }
+
+
+ /**
+ * Create page iterator for a given user's events
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserEvents(String user,
+ boolean isPublic, final int size) {
+ return pageUserEvents(user, isPublic, PagedRequest.PAGE_FIRST, size);
+ }
+
+ /**
+ * Create page iterator for a given user's events
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserEvents(String user, boolean isPublic,
+ final int start, final int size) {
+ PagedRequest<Event> request = createUserEventRequest(user,
+ isPublic, start, size);
+ return createPageIterator(request);
+ }
+
+ /**
+ * Create page iterator for a given user's orgs events
+ *
+ * @param user
+ * @param org
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserOrgEvents(String user, String org) {
+ return pageUserOrgEvents(user, org, PagedRequest.PAGE_SIZE);
+ }
+
+ /**
+ * Create page iterator for a given user's orgs events
+ *
+ * @param user
+ * @param org
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserOrgEvents(String user, String org, final int size) {
+ return pageUserOrgEvents(user, org, PagedRequest.PAGE_FIRST, size);
+ }
+
+ /**
+ * Create page iterator for a given user's orgs events
+ *
+ * @param user
+ * @param org
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ public PageIterator<Event> pageUserOrgEvents(String user, String org,
+ final int start, final int size) {
+ PagedRequest<Event> request = createUserOrgEventRequest(user, org, start, size);
+ return createPageIterator(request);
+ }
+
+ /**
+ * Create repo event page request
+ *
+ * @param repository
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ protected PagedRequest<Event> createRepoEventRequest(IRepositoryIdProvider
+ repository, int start, int size) {
+ final String repoId = getId(repository);
+ StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
+ uri.append('/').append(repoId);
+ uri.append(SEGMENT_EVENTS);
+ PagedRequest<Event> request = createPagedRequest(start, size);
+ request.setUri(uri).setType(new TypeToken<List<Event>>() {
+ }.getType());
+ return request;
+ }
+
+ /**
+ * Create network repo event page request
+ *
+ * @param repository
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ protected PagedRequest<Event> createNetworkRepoEventRequest(IRepositoryIdProvider
+ repository, int start, int size) {
+ final String repoId = getId(repository);
+ StringBuilder uri = new StringBuilder(SEGMENT_NETWORKS);
+ uri.append('/').append(repoId);
+ uri.append(SEGMENT_EVENTS);
+ PagedRequest<Event> request = createPagedRequest(start, size);
+ request.setUri(uri).setType(new TypeToken<List<Event>>() {
+ }.getType());
+ return request;
+ }
+
+ /**
+ * Create org event page request
+ *
+ * @param org
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ protected PagedRequest<Event> createOrgEventRequest(String org, int start,
+ int size) {
+ StringBuilder uri = new StringBuilder(SEGMENT_ORGS);
+ uri.append('/').append(org);
+ uri.append(SEGMENT_EVENTS);
+ PagedRequest<Event> request = createPagedRequest(start, size);
+ request.setUri(uri).setType(new TypeToken<List<Event>>() {
+ }.getType());
+ return request;
+ }
+
+ /**
+ * Create user received event page request
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ protected PagedRequest<Event> createUserReceivedEventRequest(String user,
+ boolean isPublic, int start, int size) {
+ StringBuilder uri = new StringBuilder(SEGMENT_USERS);
+ uri.append('/').append(user);
+ uri.append(SEGMENT_RECEIVED_EVENTS);
+ if (isPublic)
+ uri.append(SEGMENT_PUBLIC);
+ PagedRequest<Event> request = createPagedRequest(start, size);
+ request.setUri(uri).setType(new TypeToken<List<Event>>() {
+ }.getType());
+ return request;
+ }
+
+ /**
+ * Create user event page request
+ *
+ * @param user
+ * @param isPublic
+ * only include public events?
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ protected PagedRequest<Event> createUserEventRequest(String user, boolean isPublic,
+ int start, int size) {
+ StringBuilder uri = new StringBuilder(SEGMENT_USERS);
+ uri.append('/').append(user);
+ uri.append(SEGMENT_EVENTS);
+ if (isPublic)
+ uri.append(SEGMENT_PUBLIC);
+ PagedRequest<Event> request = createPagedRequest(start, size);
+ request.setUri(uri).setType(new TypeToken<List<Event>>() {
+ }.getType());
+ return request;
+ }
+
+ /**
+ * Create user's organization event page request
+ *
+ * @param user
+ * @param org
+ * @param start
+ * starting page number
+ * @param size
+ * size of page
+ * @return events page iterator
+ */
+ protected PagedRequest<Event> createUserOrgEventRequest(String user, String org,
+ int start, int size) {
+ StringBuilder uri = new StringBuilder(SEGMENT_USERS);
+ uri.append('/').append(user);
+ uri.append(SEGMENT_EVENTS).append(SEGMENT_ORGS);
+ uri.append('/').append(org);
+ PagedRequest<Event> request = createPagedRequest(start, size);
+ request.setUri(uri).setType(new TypeToken<List<Event>>() {
+ }.getType());
+ return request;
+ }
+}

Back to the top