Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-11-10 17:13:17 +0000
committerKevin Sawicki2011-11-10 17:13:17 +0000
commit84519b20ec835c68b4c3af6a19e7d54682f5846f (patch)
tree2b4642716934924e92a6f90f79f8e68569088735
parent4f0bfa459a79b4b75d7493af49b286c4b702edb7 (diff)
downloadegit-github-84519b20ec835c68b4c3af6a19e7d54682f5846f.tar.gz
egit-github-84519b20ec835c68b4c3af6a19e7d54682f5846f.tar.xz
egit-github-84519b20ec835c68b4c3af6a19e7d54682f5846f.zip
Add missing files and stats from RepositoryCommit class
Change-Id: I888ec6b7e3c09177a29bbf5d8f45bf4859eb1ea6 Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java96
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatsTest.java44
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryCommitTest.java11
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStats.java71
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryCommit.java36
5 files changed, 231 insertions, 27 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 7cb91439..7e0642b6 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
@@ -20,33 +20,75 @@ import org.junit.runners.Suite.SuiteClasses;
* All headless unit tests of GitHub Java API
*/
@RunWith(Suite.class)
-@SuiteClasses({ BlobTest.class, CollaboratorServiceTest.class,
- CommentTest.class, CommitCommentTest.class, CommitFileTest.class,
- CommitServiceTest.class, CommitTest.class, CommitUserTest.class,
- ContributorTest.class, DataServiceTest.class, DateFormatterTest.class,
- DateUtilTests.class, DeployKeyServiceTest.class,
- DownloadServiceTest.class, DownloadTest.class,
- DownloadResourceTest.class, EncodingUtilsTest.class,
- FieldErrorTest.class, GistChangeStatusTest.class, GistFileTest.class,
- GistRevisionTest.class, GistServiceTest.class, GistTest.class,
- GitHubClientTest.class, GsonUtilsTest.class, IdTest.class,
- IssueEventTest.class, IssueServiceTest.class, IssueTest.class,
- KeyTest.class, LabelComparatorTest.class, LabelServiceTest.class,
- LabelTest.class, LanguageTest.class, MergeStatusTest.class,
- MilestoneComparatorTest.class, MilestoneServiceTest.class,
- MilestoneTest.class, OrganizationServiceTest.class,
- PagedRequestTest.class, PullRequestMarkerTest.class,
- PullRequestServiceTest.class, PullRequestTest.class,
- ReferenceTest.class, RepositoryBranchTest.class,
- RepositoryCommitTest.class, RepositoryHookResponseTest.class,
- RepositoryHookTest.class, RepositoryIdTest.class,
- RepositoryServiceTest.class, RepositoryTagTest.class,
- RepositoryTest.class, RequestErrorTest.class,
- RequestExceptionTest.class, SearchRepositoryTest.class,
- ShaResourceTest.class, TagTest.class, TeamServiceTest.class,
- TeamTest.class, TreeEntryTest.class, TreeTest.class,
- TypedResourceTest.class, UrlUtilsTest.class, UserPlanTest.class,
- UserServiceTest.class, UserTest.class, WatcherServiceTest.class })
+@SuiteClasses({ BlobTest.class, //
+ CollaboratorServiceTest.class, //
+ CommentTest.class, //
+ CommitCommentTest.class, //
+ CommitFileTest.class, //
+ CommitServiceTest.class, //
+ CommitStatsTest.class, //
+ CommitTest.class, //
+ CommitUserTest.class, //
+ ContributorTest.class, //
+ DataServiceTest.class, //
+ DateFormatterTest.class, //
+ DateUtilTests.class, //
+ DeployKeyServiceTest.class, //
+ DownloadServiceTest.class, //
+ DownloadTest.class, //
+ DownloadResourceTest.class, //
+ EncodingUtilsTest.class, //
+ FieldErrorTest.class, //
+ GistChangeStatusTest.class, //
+ GistFileTest.class, //
+ GistRevisionTest.class, //
+ GistServiceTest.class, //
+ GistTest.class, //
+ GitHubClientTest.class, //
+ GsonUtilsTest.class, //
+ IdTest.class, //
+ IssueEventTest.class, //
+ IssueServiceTest.class, //
+ IssueTest.class, //
+ KeyTest.class, //
+ LabelComparatorTest.class, //
+ LabelServiceTest.class, //
+ LabelTest.class, //
+ LanguageTest.class, //
+ MergeStatusTest.class, //
+ MilestoneComparatorTest.class, //
+ MilestoneServiceTest.class, //
+ MilestoneTest.class, //
+ OrganizationServiceTest.class, //
+ PagedRequestTest.class, //
+ PullRequestMarkerTest.class, //
+ PullRequestServiceTest.class, //
+ PullRequestTest.class, //
+ ReferenceTest.class, //
+ RepositoryBranchTest.class, //
+ RepositoryCommitTest.class, //
+ RepositoryHookResponseTest.class, //
+ RepositoryHookTest.class, //
+ RepositoryIdTest.class, //
+ RepositoryServiceTest.class, //
+ RepositoryTagTest.class, //
+ RepositoryTest.class, //
+ RequestErrorTest.class, //
+ RequestExceptionTest.class, //
+ SearchRepositoryTest.class, //
+ ShaResourceTest.class, //
+ TagTest.class, //
+ TeamServiceTest.class, //
+ TeamTest.class, //
+ TreeEntryTest.class, //
+ TreeTest.class, //
+ TypedResourceTest.class, //
+ UrlUtilsTest.class, //
+ UserPlanTest.class, //
+ UserServiceTest.class, //
+ UserTest.class, //
+ WatcherServiceTest.class //
+})
public class AllHeadlessTests {
}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatsTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatsTest.java
new file mode 100644
index 00000000..f01ac517
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatsTest.java
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * 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:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.egit.github.core.CommitStats;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class CommitStatsTest {
+
+ /**
+ * Test default state of commit stats
+ */
+ @Test
+ public void defaultState() {
+ CommitStats stats = new CommitStats();
+ assertEquals(0, stats.getAdditions());
+ assertEquals(0, stats.getDeletions());
+ assertEquals(0, stats.getTotal());
+ }
+
+ /**
+ * Test updating commit stats fields
+ */
+ @Test
+ public void updateFields() {
+ CommitStats stats = new CommitStats();
+ assertEquals(10, stats.setAdditions(10).getAdditions());
+ assertEquals(36, stats.setDeletions(36).getDeletions());
+ assertEquals(123, stats.setTotal(123).getTotal());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryCommitTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryCommitTest.java
index 8952beba..2d6d2209 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryCommitTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryCommitTest.java
@@ -14,8 +14,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import org.eclipse.egit.github.core.Commit;
+import org.eclipse.egit.github.core.CommitFile;
+import org.eclipse.egit.github.core.CommitStats;
import org.eclipse.egit.github.core.RepositoryCommit;
import org.eclipse.egit.github.core.User;
import org.junit.Test;
@@ -34,8 +38,10 @@ public class RepositoryCommitTest {
assertNull(commit.getAuthor());
assertNull(commit.getCommit());
assertNull(commit.getCommitter());
+ assertNull(commit.getFiles());
assertNull(commit.getParents());
assertNull(commit.getSha());
+ assertNull(commit.getStats());
assertNull(commit.getUrl());
}
@@ -55,5 +61,10 @@ public class RepositoryCommitTest {
commit.setParents(new ArrayList<Commit>()).getParents());
assertEquals("0a0", commit.setSha("0a0").getSha());
assertEquals("url", commit.setUrl("url").getUrl());
+ CommitStats stats = new CommitStats();
+ assertEquals(stats, commit.setStats(stats).getStats());
+ List<CommitFile> files = Arrays.asList(new CommitFile()
+ .setFilename("test.txt"));
+ assertEquals(files, commit.setFiles(files).getFiles());
}
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStats.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStats.java
new file mode 100644
index 00000000..78fc9d37
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStats.java
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.egit.github.core;
+
+/**
+ * Model class containing line differences introduced by a commit
+ */
+public class CommitStats {
+
+ private int additions;
+
+ private int deletions;
+
+ private int total;
+
+ /**
+ * @return additions
+ */
+ public int getAdditions() {
+ return additions;
+ }
+
+ /**
+ * @param additions
+ * @return this commit stats
+ */
+ public CommitStats setAdditions(int additions) {
+ this.additions = additions;
+ return this;
+ }
+
+ /**
+ * @return deletions
+ */
+ public int getDeletions() {
+ return deletions;
+ }
+
+ /**
+ * @param deletions
+ * @return this commit stats
+ */
+ public CommitStats setDeletions(int deletions) {
+ this.deletions = deletions;
+ return this;
+ }
+
+ /**
+ * @return total
+ */
+ public int getTotal() {
+ return total;
+ }
+
+ /**
+ * @param total
+ * @return this commit stats
+ */
+ public CommitStats setTotal(int total) {
+ this.total = total;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryCommit.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryCommit.java
index 294be8f9..71060ad3 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryCommit.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryCommit.java
@@ -25,8 +25,12 @@ public class RepositoryCommit implements Serializable {
private Commit commit;
+ private CommitStats stats;
+
private List<Commit> parents;
+ private List<CommitFile> files;
+
private String sha;
private String url;
@@ -52,6 +56,22 @@ public class RepositoryCommit implements Serializable {
}
/**
+ * @return stats
+ */
+ public CommitStats getStats() {
+ return stats;
+ }
+
+ /**
+ * @param stats
+ * @return this commit
+ */
+ public RepositoryCommit setStats(CommitStats stats) {
+ this.stats = stats;
+ return this;
+ }
+
+ /**
* @return parents
*/
public List<Commit> getParents() {
@@ -68,6 +88,22 @@ public class RepositoryCommit implements Serializable {
}
/**
+ * @return files
+ */
+ public List<CommitFile> getFiles() {
+ return files;
+ }
+
+ /**
+ * @param files
+ * @return this commit
+ */
+ public RepositoryCommit setFiles(List<CommitFile> files) {
+ this.files = files;
+ return this;
+ }
+
+ /**
* @return sha
*/
public String getSha() {

Back to the top