Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-06-25 13:11:46 -0400
committerKevin Sawicki2012-06-25 13:11:46 -0400
commitdbf1fb5cb319c71380a235239d4901042f9a6ee0 (patch)
tree19657acb4fc3ca0b0ce38b11c26306572308bb82
parent39d3e9f9e24931241cf5dc5a5e8ec1700a6c36ef (diff)
downloadegit-github-dbf1fb5cb319c71380a235239d4901042f9a6ee0.tar.gz
egit-github-dbf1fb5cb319c71380a235239d4901042f9a6ee0.tar.xz
egit-github-dbf1fb5cb319c71380a235239d4901042f9a6ee0.zip
Add service support for editing a milestone
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneServiceTest.java26
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java22
2 files changed, 48 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneServiceTest.java
index f68f4a4f..b991d165 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneServiceTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneServiceTest.java
@@ -396,4 +396,30 @@ public class MilestoneServiceTest {
request.setUri("/repos/user/repo/milestones/15");
verify(gitHubClient).get(request);
}
+
+ /**
+ * Edit milestone with null milestone
+ *
+ * @throws IOException
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void editMilestoneNullUser() throws IOException {
+ milestoneService.editMilestone(RepositoryId.create("a", "b"), null);
+ }
+
+ /**
+ * Edit milestone
+ *
+ * @throws IOException
+ */
+ @Test
+ public void editMilestone() throws IOException {
+ Milestone milestone = new Milestone();
+ milestone.setNumber(1234);
+ milestone.setTitle("a milestone");
+ milestoneService
+ .editMilestone(RepositoryId.create("a", "b"), milestone);
+ verify(gitHubClient).post("/repos/a/b/milestones/1234", milestone,
+ Milestone.class);
+ }
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java
index 0a958b87..cea69459 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java
@@ -293,4 +293,26 @@ public class MilestoneService extends GitHubService {
uri.append('/').append(milestone);
client.delete(uri.toString());
}
+
+ /**
+ * Edit the given milestone in the given repository
+ *
+ * @param repository
+ * @param milestone
+ * @return edited milestone
+ * @throws IOException
+ */
+ public Milestone editMilestone(IRepositoryIdProvider repository,
+ Milestone milestone) throws IOException {
+ String repoId = getId(repository);
+ if (milestone == null)
+ throw new IllegalArgumentException("Milestone cannot be null"); //$NON-NLS-1$
+
+ StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
+ uri.append('/').append(repoId);
+ uri.append(SEGMENT_MILESTONES);
+ uri.append('/').append(milestone.getNumber());
+
+ return client.post(uri.toString(), milestone, Milestone.class);
+ }
}

Back to the top