diff options
| author | Kevin Sawicki | 2011-04-27 19:15:55 +0000 |
|---|---|---|
| committer | Kevin Sawicki | 2011-04-27 19:15:55 +0000 |
| commit | a4642193cb73b4c89f51640087033b124e67d725 (patch) | |
| tree | 0e687bd89e1955dced4f8d3afff01ce5b3f74836 | |
| parent | f1928ad3d1cfdbb83bc4e30a11488a1b3d1bf7c5 (diff) | |
| download | egit-github-a4642193cb73b4c89f51640087033b124e67d725.tar.gz egit-github-a4642193cb73b4c89f51640087033b124e67d725.tar.xz egit-github-a4642193cb73b4c89f51640087033b124e67d725.zip | |
Remove use of gist repo field.
It was a duplicate of the id field and is
being dropped from the API.
Change-Id: I0c3f12e2f95939ed256153c4f1d80b7db9ed77df
Signed-off-by: Kevin Sawicki <kevin@github.com>
6 files changed, 19 insertions, 28 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java index 8cabb81f..e84e7a49 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java @@ -42,8 +42,6 @@ public class Gist { private String id; - private String repo; - private String url; private User user; @@ -146,18 +144,11 @@ public class Gist { } /** - * @return repo - */ - public String getRepo() { - return this.repo; - } - - /** - * @param repo + * @param id * @return this gist */ - public Gist setRepo(String repo) { - this.repo = repo; + public Gist setId(String id) { + this.id = id; return this; } diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java index 7b301b4f..9ed8c69d 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java @@ -98,11 +98,11 @@ public class GistService { * @throws IOException */ public Gist updateGist(Gist gist) throws IOException { - Assert.isNotNull(gist, "Gist cannot be null"); - String repo = gist.getRepo(); - Assert.isNotNull(repo, "Repository cannot be null"); + Assert.isNotNull(gist, "Gist cannot be null"); //$NON-NLS-1$ + String id = gist.getId(); + Assert.isNotNull(id, "Gist id cannot be null"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_GISTS); - uri.append('/').append(repo).append(IGitHubConstants.SUFFIX_JSON); + uri.append('/').append(id).append(IGitHubConstants.SUFFIX_JSON); return this.client.put(uri.toString(), gist, Gist.class); } diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java index 03bc94c1..15bb525a 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java @@ -90,7 +90,7 @@ public class GistAttachmentHandler extends AbstractTaskAttachmentHandler { throws CoreException { TaskAttachmentMapper mapper = TaskAttachmentMapper .createFrom(attachmentAttribute); - Gist gist = new Gist().setRepo(task.getTaskId()); + Gist gist = new Gist().setId(task.getTaskId()); gist.setDescription(attachmentAttribute.getParentAttribute() .getAttribute(GistAttribute.DESCRIPTION.getId()).getValue()); GistFile file = new GistFile(); diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java index 29498d25..93e10fdd 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java @@ -126,12 +126,12 @@ public class GistConnector extends AbstractRepositoryConnector { .getAttributeMapper(repository); Gist gist = service.getGist(taskId); TaskData data = new TaskData(mapper, getConnectorKind(), - repository.getUrl(), gist.getRepo()); + repository.getUrl(), gist.getId()); data.setPartial(false); this.dataHandler.fillTaskData(repository, data, gist); if (gist.getComments() > 0) this.dataHandler.fillComments(repository, data, - service.getComments(gist.getRepo())); + service.getComments(gist.getId())); return data; } catch (IOException e) { @@ -184,7 +184,7 @@ public class GistConnector extends AbstractRepositoryConnector { .getAttributeMapper(repository); for (Gist gist : service.getGists(user)) { TaskData data = new TaskData(mapper, getConnectorKind(), - repository.getUrl(), gist.getRepo()); + repository.getUrl(), gist.getId()); data.setPartial(true); this.dataHandler.fillTaskData(repository, data, gist); collector.accept(data); diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java index bbf71973..420e7d94 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java @@ -91,7 +91,7 @@ public class GistTaskDataHandler extends AbstractTaskDataHandler { * @return url */ public String getGistUrl(String repositoryUrl, Gist gist) { - return repositoryUrl + '/' + gist.getRepo(); + return repositoryUrl + '/' + gist.getId(); } /** @@ -107,7 +107,7 @@ public class GistTaskDataHandler extends AbstractTaskDataHandler { TaskAttributeMapper mapper = data.getAttributeMapper(); TaskAttribute key = GistAttribute.KEY.create(data); - mapper.setValue(key, gist.getRepo()); + mapper.setValue(key, gist.getId()); TaskAttribute description = GistAttribute.DESCRIPTION.create(data); String gistDescription = gist.getDescription(); @@ -220,7 +220,7 @@ public class GistTaskDataHandler extends AbstractTaskDataHandler { GistService service = new GistService(client); TaskAttribute root = taskData.getRoot(); - gist.setRepo(taskData.getTaskId()); + gist.setId(taskData.getTaskId()); gist.setDescription(root .getAttribute(GistAttribute.DESCRIPTION.getId()).getValue()); @@ -231,7 +231,7 @@ public class GistTaskDataHandler extends AbstractTaskDataHandler { throw new CoreException(GitHub.createErrorStatus(e)); } response = new RepositoryResponse(ResponseKind.TASK_CREATED, - gist.getRepo()); + gist.getId()); } else { try { String newComment = root.getAttribute( diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java index 0d95bae3..e751ab59 100644 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java @@ -112,18 +112,18 @@ public class GistServiceTest { } @Test(expected = AssertionFailedException.class) - public void updateGist_NullRepository() throws IOException { + public void updateGist_NullId() throws IOException { Gist gist = new Gist(); - gist.setRepo(null); + gist.setId(null); gistService.updateGist(gist); } @Test public void updateGist_OK() throws IOException { Gist gist = new Gist(); - gist.setRepo("test_repository"); + gist.setId("123"); gistService.updateGist(gist); - verify(gitHubClient).put("/gists/test_repository.json", gist, + verify(gitHubClient).put("/gists/123.json", gist, Gist.class); } |
