aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-05-06 08:33:28 (EDT)
committerChris Aniszczyk2011-05-06 10:01:56 (EDT)
commitae81bd433ef66f15ccc9993ba27aae37f537427c (patch)
tree63641a37ee35b3bfffd2847315fd8e0d4fd61522
parent84c7ade8ea08be53cc97e396f8ab326002916586 (diff)
downloadegit-github-ae81bd433ef66f15ccc9993ba27aae37f537427c.zip
egit-github-ae81bd433ef66f15ccc9993ba27aae37f537427c.tar.gz
egit-github-ae81bd433ef66f15ccc9993ba27aae37f537427c.tar.bz2
Add CommentTestrefs/changes/50/3350/2
Change-Id: I4162c7b5e9b81d3dad11ae5e6fc8cdef878a2ee7 Signed-off-by: Christian Trutz <christian.trutz@gmail.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Comment.java10
-rw-r--r--org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF1
-rwxr-xr-xorg.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java47
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java8
4 files changed, 60 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Comment.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Comment.java
index 1a37ddc..cabb24d 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Comment.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Comment.java
@@ -14,7 +14,7 @@ import java.util.Date;
/**
* GitHub issue comment class.
- *
+ *
* @author Kevin Sawicki (kevin@github.com)
*/
public class Comment {
@@ -33,14 +33,18 @@ public class Comment {
* @return createdAt
*/
public Date getCreatedAt() {
- return this.createdAt;
+ // see EI_EXPOSE_REP at
+ // http://findbugs.sourceforge.net/bugDescriptions.html
+ return new Date(this.createdAt.getTime());
}
/**
* @return updatedAt
*/
public Date getUpdatedAt() {
- return this.updatedAt;
+ // see EI_EXPOSE_REP at
+ // http://findbugs.sourceforge.net/bugDescriptions.html
+ return new Date(this.updatedAt.getTime());
}
/**
diff --git a/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF
index 16d752d..8d67c59 100644
--- a/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Bundle-Vendor: Eclipse EGit
Import-Package: com.google.gson;version="1.6.0",
com.google.gson.reflect;version="1.6.0",
org.apache.commons.httpclient;version="3.1.0",
+ org.apache.commons.logging;version="1.0.4",
org.mockito;version="1.8.4",
org.mockito.runners;version="1.8.4",
org.mockito.stubbing;version="1.8.4"
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java
new file mode 100755
index 0000000..f22dc02
--- /dev/null
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.mylyn.github.internal;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+/**
+ * Unit tests for {@link Comment}
+ */
+@SuppressWarnings("restriction")
+@RunWith(MockitoJUnitRunner.class)
+public class CommentTest {
+
+ private static final Gson gson = new GsonBuilder().setDateFormat(
+ "yyyy-MM-dd").create();
+
+ @Test
+ public void getCreatedAt_ReferenceMutableObject() {
+ Comment comment = gson.fromJson("{createdAt : '2003-10-10'}",
+ Comment.class);
+ comment.getCreatedAt().setTime(0);
+ assertTrue(comment.getCreatedAt().getTime() != 0);
+ }
+
+ @Test
+ public void getUpdatedAt_ReferenceMutableObject() {
+ Comment comment = gson.fromJson("{updatedAt : '2003-10-10'}",
+ Comment.class);
+ comment.getUpdatedAt().setTime(0);
+ assertTrue(comment.getUpdatedAt().getTime() != 0);
+ }
+}
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java
index cf4c4e9..4fadbb4 100644
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.mylyn.github.tests;
+import org.eclipse.mylyn.github.internal.CommentTest;
import org.eclipse.mylyn.github.internal.GistServiceTest;
import org.eclipse.mylyn.github.internal.GitHubClientTest;
import org.eclipse.mylyn.github.internal.IssueServiceTest;
@@ -23,9 +24,10 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({ GitHubClientTest.class, IssueServiceTest.class,
- LabelServiceTest.class, MilestoneServiceTest.class,
- GistServiceTest.class, PullRequestServiceTest.class })
+@SuiteClasses({ CommentTest.class, GitHubClientTest.class,
+ IssueServiceTest.class, LabelServiceTest.class,
+ MilestoneServiceTest.class, GistServiceTest.class,
+ PullRequestServiceTest.class })
public class AllHeadlessTests {
}