Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.github.core.tests/src/org/eclipse')
-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
23 files changed, 1264 insertions, 0 deletions
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());
+ }
+ }
+}

Back to the top