aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-05-12 17:08:27 (EDT)
committerChristian Trutz2011-05-12 17:08:27 (EDT)
commit27eee5bce42e0bc35a19ca8892fd0e7454262ddc (patch)
treebc7616bfb572166fcb9df8f3abae2adc12ba8b9f
parented34e491f53478844b88f61f4313168db586d78f (diff)
downloadegit-github-27eee5bce42e0bc35a19ca8892fd0e7454262ddc.zip
egit-github-27eee5bce42e0bc35a19ca8892fd0e7454262ddc.tar.gz
egit-github-27eee5bce42e0bc35a19ca8892fd0e7454262ddc.tar.bz2
Unit tests for PullRequestDiscussion.refs/changes/97/3397/1
Change-Id: I44b76785b2cb7ccdaac94ca5459e8ee072ec8fa8 Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java7
-rwxr-xr-xorg.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestDiscussionTest.java61
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/PullRequestDiscussion.java12
3 files changed, 73 insertions, 7 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 54aaaaf..2410d63 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
@@ -28,9 +28,10 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({ CommentTest.class, GistTest.class, GistRevisionTest.class,
- IssueTest.class, MilestoneTest.class, GitHubClientTest.class,
- IssueServiceTest.class, LabelServiceTest.class,
+@SuiteClasses({ PullRequestDiscussionTest.class, RepositoryTest.class,
+ PullRequestTest.class, CommentTest.class, GistTest.class,
+ GistRevisionTest.class, IssueTest.class, MilestoneTest.class,
+ GitHubClientTest.class, IssueServiceTest.class, LabelServiceTest.class,
MilestoneServiceTest.class, GistServiceTest.class,
PullRequestServiceTest.class })
public class AllHeadlessTests {
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestDiscussionTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestDiscussionTest.java
new file mode 100755
index 0000000..34ba40c
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PullRequestDiscussionTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Christian Trutz
+ * 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:
+ * Christian Trutz - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.egit.github.core.PullRequestDiscussion;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+/**
+ * Tests for {@link PullRequestDiscussion}
+ */
+public class PullRequestDiscussionTest {
+
+ private static final Gson gson = new GsonBuilder().setDateFormat(
+ "yyyy-MM-dd").create();
+
+ @Test
+ public void getCreatedAt_ReferenceMutableObject() {
+ PullRequestDiscussion pullRequestDiscussion = gson.fromJson(
+ "{createdAt : '2003-10-10'}", PullRequestDiscussion.class);
+ pullRequestDiscussion.getCreatedAt().setTime(0);
+ assertTrue(pullRequestDiscussion.getCreatedAt().getTime() != 0);
+ }
+
+ @Test
+ public void getUpdatedAt_ReferenceMutableObject() {
+ PullRequestDiscussion pullRequestDiscussion = gson.fromJson(
+ "{updatedAt : '2003-10-10'}", PullRequestDiscussion.class);
+ pullRequestDiscussion.getUpdatedAt().setTime(0);
+ assertTrue(pullRequestDiscussion.getUpdatedAt().getTime() != 0);
+ }
+
+ @Test
+ public void getCommitedDate_ReferenceMutableObject() {
+ PullRequestDiscussion pullRequestDiscussion = gson.fromJson(
+ "{commitedDate : '2003-10-10'}", PullRequestDiscussion.class);
+ pullRequestDiscussion.getCommitedDate().setTime(0);
+ assertTrue(pullRequestDiscussion.getCommitedDate().getTime() != 0);
+ }
+
+ @Test
+ public void getAuthoredDate_ReferenceMutableObject() {
+ PullRequestDiscussion pullRequestDiscussion = gson.fromJson(
+ "{authoredDate : '2003-10-10'}", PullRequestDiscussion.class);
+ pullRequestDiscussion.getAuthoredDate().setTime(0);
+ assertTrue(pullRequestDiscussion.getAuthoredDate().getTime() != 0);
+ }
+
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/PullRequestDiscussion.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/PullRequestDiscussion.java
index 6581c42..eee46cd 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/PullRequestDiscussion.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/PullRequestDiscussion.java
@@ -56,28 +56,32 @@ public class PullRequestDiscussion {
* @return authoredDate
*/
public Date getAuthoredDate() {
- return this.authoredDate;
+ return this.authoredDate != null ? new Date(this.authoredDate.getTime())
+ : null;
}
/**
* @return commitedDate
*/
public Date getCommitedDate() {
- return this.commitedDate;
+ return this.commitedDate != null ? new Date(this.commitedDate.getTime())
+ : null;
}
/**
* @return createdAt
*/
public Date getCreatedAt() {
- return this.createdAt;
+ return this.createdAt != null ? new Date(this.createdAt.getTime())
+ : null;
}
/**
* @return updatedAt
*/
public Date getUpdatedAt() {
- return this.updatedAt;
+ return this.updatedAt != null ? new Date(this.updatedAt.getTime())
+ : null;
}
/**