diff options
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); + } } |