Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-04-18 00:11:32 -0400
committerKevin Sawicki2012-04-18 00:11:32 -0400
commit6055c14acf8f5de6418404d6f6c3a53bd04dc920 (patch)
tree92dcd77a64bffa0964ecc65de32aebcbf22719ee
parent4c729e19506e4266184c2b9ef9ce84cda6d19424 (diff)
downloadegit-github-6055c14acf8f5de6418404d6f6c3a53bd04dc920.tar.gz
egit-github-6055c14acf8f5de6418404d6f6c3a53bd04dc920.tar.xz
egit-github-6055c14acf8f5de6418404d6f6c3a53bd04dc920.zip
Add RepositoryIssue model class that includes repository
This type of object is returned from IssueService for requests that don't require a repository id to be specified such as all the watched issues for the currently authenticated user. This new model class simply extends Issue and adds a single Repository field. Change-Id: I08829493fadd2493a6ff29d2e7dba6d8033de423
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueServiceTest.java5
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIssueTest.java43
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryIssue.java45
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/IssueService.java22
4 files changed, 103 insertions, 12 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueServiceTest.java
index cabb2ba9..b249c226 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueServiceTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/IssueServiceTest.java
@@ -26,6 +26,7 @@ import org.eclipse.egit.github.core.Comment;
import org.eclipse.egit.github.core.Issue;
import org.eclipse.egit.github.core.IssueEvent;
import org.eclipse.egit.github.core.RepositoryId;
+import org.eclipse.egit.github.core.RepositoryIssue;
import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.client.GitHubRequest;
import org.eclipse.egit.github.core.client.GitHubResponse;
@@ -691,7 +692,7 @@ public class IssueServiceTest {
*/
@Test
public void pageIssues() throws IOException {
- PageIterator<Issue> iterator = issueService.pageIssues();
+ PageIterator<RepositoryIssue> iterator = issueService.pageIssues();
assertNotNull(iterator);
assertTrue(iterator.hasNext());
assertEquals(Utils.page("/issues"), iterator.getRequest().generateUri());
@@ -733,7 +734,7 @@ public class IssueServiceTest {
*/
@Test
public void getCurrentUserIssues() throws IOException {
- List<Issue> issues = issueService.getIssues();
+ List<RepositoryIssue> issues = issueService.getIssues();
assertNotNull(issues);
assertTrue(issues.isEmpty());
}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIssueTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIssueTest.java
new file mode 100644
index 00000000..1709de70
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIssueTest.java
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * Copyright (c) 2012 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 static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.RepositoryIssue;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link RepositoryIssue}
+ */
+public class RepositoryIssueTest {
+
+ /**
+ * Test default state of issue
+ */
+ @Test
+ public void defaultState() {
+ RepositoryIssue issue = new RepositoryIssue();
+ assertNull(issue.getRepository());
+ }
+
+ /**
+ * Test updating issue fields
+ */
+ @Test
+ public void updateFields() {
+ RepositoryIssue issue = new RepositoryIssue();
+ Repository repo = new Repository();
+ assertEquals(repo, issue.setRepository(repo).getRepository());
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryIssue.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryIssue.java
new file mode 100644
index 00000000..146501fc
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/RepositoryIssue.java
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * Copyright (c) 2012 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;
+
+import org.eclipse.egit.github.core.service.IssueService;
+
+/**
+ * Extension of {@link Issue} that includes the {@link Repository} that the
+ * issue is in.
+ * <p>
+ * This type of issue is returned from {@link IssueService} calls that don't
+ * require an {@link IRepositoryIdProvider} to be specified and therefore the
+ * repository information is needed to correlate which issues occur in which
+ * repositories.
+ */
+public class RepositoryIssue extends Issue {
+
+ private static final long serialVersionUID = 6219926097588214812L;
+
+ private Repository repository;
+
+ /**
+ * @return repository
+ */
+ public Repository getRepository() {
+ return repository;
+ }
+
+ /**
+ * @param repository
+ * @return this issue
+ */
+ public RepositoryIssue setRepository(Repository repository) {
+ this.repository = repository;
+ return this;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/IssueService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/IssueService.java
index dee7be1e..aee17b14 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/IssueService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/IssueService.java
@@ -31,6 +31,7 @@ import org.eclipse.egit.github.core.Issue;
import org.eclipse.egit.github.core.IssueEvent;
import org.eclipse.egit.github.core.Label;
import org.eclipse.egit.github.core.Milestone;
+import org.eclipse.egit.github.core.RepositoryIssue;
import org.eclipse.egit.github.core.User;
import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.client.GitHubRequest;
@@ -174,7 +175,7 @@ public class IssueService extends GitHubService {
* @return non-null but possibly empty list of issues
* @throws IOException
*/
- public List<Issue> getIssues() throws IOException {
+ public List<RepositoryIssue> getIssues() throws IOException {
return getIssues(null);
}
@@ -185,7 +186,7 @@ public class IssueService extends GitHubService {
* @return non-null but possibly empty list of issues
* @throws IOException
*/
- public List<Issue> getIssues(Map<String, String> filterData)
+ public List<RepositoryIssue> getIssues(Map<String, String> filterData)
throws IOException {
return getAll(pageIssues(filterData));
}
@@ -195,7 +196,7 @@ public class IssueService extends GitHubService {
*
* @return iterator over pages of issues
*/
- public PageIterator<Issue> pageIssues() {
+ public PageIterator<RepositoryIssue> pageIssues() {
return pageIssues((Map<String, String>) null);
}
@@ -205,7 +206,8 @@ public class IssueService extends GitHubService {
* @param filterData
* @return iterator over pages of issues
*/
- public PageIterator<Issue> pageIssues(Map<String, String> filterData) {
+ public PageIterator<RepositoryIssue> pageIssues(
+ Map<String, String> filterData) {
return pageIssues(filterData, PAGE_SIZE);
}
@@ -216,8 +218,8 @@ public class IssueService extends GitHubService {
* @param size
* @return iterator over pages of issues
*/
- public PageIterator<Issue> pageIssues(Map<String, String> filterData,
- int size) {
+ public PageIterator<RepositoryIssue> pageIssues(
+ Map<String, String> filterData, int size) {
return pageIssues(filterData, PAGE_FIRST, size);
}
@@ -229,12 +231,12 @@ public class IssueService extends GitHubService {
* @param size
* @return iterator over pages of issues
*/
- public PageIterator<Issue> pageIssues(Map<String, String> filterData,
- int start, int size) {
- PagedRequest<Issue> request = createPagedRequest(start, size);
+ public PageIterator<RepositoryIssue> pageIssues(
+ Map<String, String> filterData, int start, int size) {
+ PagedRequest<RepositoryIssue> request = createPagedRequest(start, size);
request.setParams(filterData);
request.setUri(SEGMENT_ISSUES);
- request.setType(new TypeToken<List<Issue>>() {
+ request.setType(new TypeToken<List<RepositoryIssue>>() {
}.getType());
return createPageIterator(request);
}

Back to the top