Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 00000000..e0feb281
--- /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 badf1760..7ea72d5d 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;
}
/**

Back to the top