aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-05-12 16:52:18 (EDT)
committerChristian Trutz2011-05-12 16:52:18 (EDT)
commited34e491f53478844b88f61f4313168db586d78f (patch)
treebe3f959902fc9f0bbd3c519dcac991df50c15f80
parent675f6e47212164c49f9d81bf8d00702ea4d3b38a (diff)
downloadegit-github-ed34e491f53478844b88f61f4313168db586d78f.zip
egit-github-ed34e491f53478844b88f61f4313168db586d78f.tar.gz
egit-github-ed34e491f53478844b88f61f4313168db586d78f.tar.bz2
Unit tests for Repository.refs/changes/96/3396/1
Change-Id: I770a575c60f9a51d94210d02eb6e3816fb04c051 Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
-rwxr-xr-xorg.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryTest.java45
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Repository.java9
2 files changed, 50 insertions, 4 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryTest.java
new file mode 100755
index 0000000..e0feb28
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.Repository;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+/**
+ * Tests for {@link Repository}.
+ */
+public class RepositoryTest {
+
+ private static final Gson gson = new GsonBuilder().setDateFormat(
+ "yyyy-MM-dd").create();
+
+ @Test
+ public void getCreatedAt_ReferenceMutableObject() {
+ Repository repository = gson.fromJson("{createdAt : '2003-10-10'}",
+ Repository.class);
+ repository.getCreatedAt().setTime(0);
+ assertTrue(repository.getCreatedAt().getTime() != 0);
+ }
+
+ @Test
+ public void getPushedAt_ReferenceMutableObject() {
+ Repository repository = gson.fromJson("{pushedAt : '2003-10-10'}",
+ Repository.class);
+ repository.getPushedAt().setTime(0);
+ assertTrue(repository.getPushedAt().getTime() != 0);
+ }
+
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Repository.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Repository.java
index badf176..7ea72d5 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Repository.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Repository.java
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.egit.github.core;
-import com.google.gson.annotations.SerializedName;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
+import com.google.gson.annotations.SerializedName;
+
/**
* GitHub Repository class.
*/
@@ -207,14 +207,15 @@ public class Repository {
* @return createdAt
*/
public Date getCreatedAt() {
- return this.createdAt;
+ return this.createdAt != null ? new Date(this.createdAt.getTime())
+ : null;
}
/**
* @return pushedAt
*/
public Date getPushedAt() {
- return this.pushedAt;
+ return this.pushedAt != null ? new Date(this.pushedAt.getTime()) : null;
}
/**