Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/FieldError.java97
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java18
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java19
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java2
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java5
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java34
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java15
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Messages.java12
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/MilestoneService.java3
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestError.java8
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java16
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/messages.properties4
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java10
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java12
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java8
15 files changed, 189 insertions, 74 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/FieldError.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/FieldError.java
new file mode 100644
index 00000000..6e38c775
--- /dev/null
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/FieldError.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.mylyn.github.internal;
+
+import java.text.MessageFormat;
+
+/**
+ * Field error
+ */
+public class FieldError {
+
+ /**
+ * CODE_INVALID
+ */
+ public static final String CODE_INVALID = "invalid"; //$NON-NLS-1$
+
+ /**
+ * CODE_MISSING
+ */
+ public static final String CODE_MISSING = "missing"; //$NON-NLS-1$
+
+ /**
+ * CODE_MISSING_FIELD
+ */
+ public static final String CODE_MISSING_FIELD = "missing_field"; //$NON-NLS-1$
+
+ /**
+ * CODE_ALREADY_EXISTS
+ */
+ public static final String CODE_ALREADY_EXISTS = "already_exists"; //$NON-NLS-1$
+
+ private String code;
+
+ private String field;
+
+ private String resource;
+
+ private String value;
+
+ /**
+ * @return code
+ */
+ public String getCode() {
+ return this.code;
+ }
+
+ /**
+ * @return field
+ */
+ public String getField() {
+ return this.field;
+ }
+
+ /**
+ * @return resource
+ */
+ public String getResource() {
+ return this.resource;
+ }
+
+ /**
+ * @return value
+ */
+ public String getValue() {
+ return this.value;
+ }
+
+ /**
+ * Format into human-readable error message
+ *
+ * @return error
+ */
+ public String format() {
+ if (CODE_INVALID.equals(code))
+ if (value != null)
+ return MessageFormat
+ .format(Messages.FieldError_InvalidFieldWithValue,
+ value, field);
+ else
+ return MessageFormat.format(Messages.FieldError_InvalidField,
+ field, value);
+ else if (CODE_MISSING_FIELD.equals(code))
+ return MessageFormat
+ .format(Messages.FieldError_MissingField, field);
+ else
+ return MessageFormat.format(Messages.FieldError_ResourceError,
+ field, resource);
+ }
+}
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 7ed5925c..31ade336 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
@@ -43,7 +43,7 @@ public class GistService extends GitHubService {
public Gist getGist(String id) throws IOException {
Assert.isNotNull(id, "Gist id cannot be null");
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_GISTS);
- uri.append('/').append(id).append(IGitHubConstants.SUFFIX_JSON);
+ uri.append('/').append(id);
GitHubRequest request = new GitHubRequest();
request.setUri(uri);
request.setType(Gist.class);
@@ -61,8 +61,7 @@ public class GistService extends GitHubService {
Assert.isNotNull(user, "User cannot be null");
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_USERS);
uri.append('/').append(user);
- uri.append(IGitHubConstants.SEGMENT_GISTS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_GISTS);
ListResourceCollector<Gist> collector = new ListResourceCollector<Gist>();
PagedRequest<Gist> request = new PagedRequest<Gist>(collector);
request.setUri(uri).setType(new TypeToken<List<Gist>>() {
@@ -88,8 +87,7 @@ public class GistService extends GitHubService {
uri.append(IGitHubConstants.SEGMENT_USERS);
uri.append('/').append(login);
}
- uri.append(IGitHubConstants.SEGMENT_GISTS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_GISTS);
return this.client.post(uri.toString(), gist, Gist.class);
}
@@ -105,8 +103,8 @@ public class GistService extends GitHubService {
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(id).append(IGitHubConstants.SUFFIX_JSON);
- return this.client.put(uri.toString(), gist, Gist.class);
+ uri.append('/').append(id);
+ return this.client.post(uri.toString(), gist, Gist.class);
}
/**
@@ -123,8 +121,7 @@ public class GistService extends GitHubService {
Assert.isNotNull(comment, "Gist comment cannot be null");
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_GISTS);
uri.append('/').append(gistId);
- uri.append(IGitHubConstants.SEGMENT_COMMENTS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_COMMENTS);
Map<String, String> params = new HashMap<String, String>(1, 1);
params.put(IssueService.FIELD_BODY, comment);
@@ -142,8 +139,7 @@ public class GistService extends GitHubService {
Assert.isNotNull(gistId, "Gist id cannot be null");
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_GISTS);
uri.append('/').append(gistId);
- uri.append(IGitHubConstants.SEGMENT_COMMENTS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_COMMENTS);
ListResourceCollector<Comment> collector = new ListResourceCollector<Comment>();
PagedRequest<Comment> request = new PagedRequest<Comment>(collector);
request.setUri(uri).setType(new TypeToken<List<Comment>>() {
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
index ad5cd005..cc35e983 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
@@ -10,6 +10,11 @@
*******************************************************************************/
package org.eclipse.mylyn.github.internal;
+import com.google.gson.FieldNamingPolicy;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParseException;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -35,11 +40,6 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.protocol.Protocol;
import org.eclipse.core.runtime.Assert;
-import com.google.gson.FieldNamingPolicy;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonParseException;
-
/**
* Client class for interacting with GitHub HTTP/JSON API.
*/
@@ -58,7 +58,7 @@ public class GitHubClient {
private Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateFormatter())
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
- .create();
+ .serializeNulls().create();
private boolean sendCredentials = false;
@@ -162,7 +162,12 @@ public class GitHubClient {
if (stream == null)
throw new JsonParseException("Empty body"); //$NON-NLS-1$
InputStreamReader reader = new InputStreamReader(stream);
- return this.gson.fromJson(reader, type);
+ try {
+ return this.gson.fromJson(reader, type);
+ } catch (JsonParseException jpe) {
+ jpe.printStackTrace();
+ throw new IOException(jpe);
+ }
}
/**
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
index fb7d6492..4cd1d26a 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
@@ -229,6 +229,8 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
String assigneeValue = getAttributeValue(taskData,
GitHubTaskAttributes.ASSIGNEE);
if (assigneeValue != null) {
+ if (assigneeValue.trim().length() == 0)
+ assigneeValue = null;
User assignee = new User().setName(assigneeValue);
issue.setAssignee(assignee);
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
index 99cc89ec..a084d2c7 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
@@ -76,11 +76,6 @@ public interface IGitHubConstants {
String SEGMENT_V2_API = "/api/v2/json"; //$NON-NLS-1$
/**
- * SUFFIX_JSON
- */
- String SUFFIX_JSON = ".json"; //$NON-NLS-1$
-
- /**
* HOST_API
*/
String HOST_API = "api.github.com"; //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
index b3ceb1e9..e203eeb7 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
@@ -100,7 +100,7 @@ public class IssueService extends GitHubService {
IGitHubConstants.SEGMENT_REPOS);
builder.append('/').append(user).append('/').append(repository);
builder.append(IGitHubConstants.SEGMENT_ISSUES);
- builder.append('/').append(id).append(IGitHubConstants.SUFFIX_JSON);
+ builder.append('/').append(id);
GitHubRequest request = new GitHubRequest();
request.setUri(builder.toString());
request.setType(Issue.class);
@@ -126,8 +126,7 @@ public class IssueService extends GitHubService {
builder.append('/').append(user).append('/').append(repository);
builder.append(IGitHubConstants.SEGMENT_ISSUES);
builder.append('/').append(id);
- builder.append(IGitHubConstants.SEGMENT_COMMENTS).append(
- IGitHubConstants.SUFFIX_JSON);
+ builder.append(IGitHubConstants.SEGMENT_COMMENTS);
ListResourceCollector<Comment> collector = new ListResourceCollector<Comment>();
PagedRequest<Comment> request = new PagedRequest<Comment>(collector);
request.setUri(builder.toString()).setType(
@@ -153,8 +152,7 @@ public class IssueService extends GitHubService {
StringBuilder builder = new StringBuilder(
IGitHubConstants.SEGMENT_REPOS);
builder.append('/').append(user).append('/').append(repository);
- builder.append(IGitHubConstants.SEGMENT_ISSUES).append(
- IGitHubConstants.SUFFIX_JSON);
+ builder.append(IGitHubConstants.SEGMENT_ISSUES);
ListResourceCollector<Issue> collector = new ListResourceCollector<Issue>();
PagedRequest<Issue> request = new PagedRequest<Issue>(collector);
request.setParams(filterData).setUri(builder.toString());
@@ -168,15 +166,16 @@ public class IssueService extends GitHubService {
* Create issue map for issue
*
* @param issue
+ * @param newIssue
* @return map
*/
- protected Map<String, String> createIssueMap(Issue issue) {
+ protected Map<String, String> createIssueMap(Issue issue, boolean newIssue) {
Map<String, String> params = new HashMap<String, String>();
if (issue != null) {
params.put(FIELD_BODY, issue.getBody());
params.put(FIELD_TITLE, issue.getTitle());
User assignee = issue.getAssignee();
- if (assignee != null)
+ if (assignee != null && !newIssue)
params.put(FILTER_ASSIGNEE, assignee.getName());
Milestone milestone = issue.getMilestone();
@@ -184,8 +183,10 @@ public class IssueService extends GitHubService {
int number = milestone.getNumber();
if (number > 0)
params.put(FILTER_MILESTONE, Integer.toString(number));
- else
- params.put(FILTER_MILESTONE, ""); //$NON-NLS-1$
+ else {
+ if (!newIssue)
+ params.put(FILTER_MILESTONE, null);
+ }
}
}
return params;
@@ -206,10 +207,9 @@ public class IssueService extends GitHubService {
Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
uri.append('/').append(user).append('/').append(repository);
- uri.append(IGitHubConstants.SEGMENT_ISSUES).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_ISSUES);
- Map<String, String> params = createIssueMap(issue);
+ Map<String, String> params = createIssueMap(issue, true);
return this.client.post(uri.toString(), params, Issue.class);
}
@@ -230,15 +230,14 @@ public class IssueService extends GitHubService {
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
uri.append('/').append(user).append('/').append(repository);
uri.append(IGitHubConstants.SEGMENT_ISSUES);
- uri.append('/').append(issue.getNumber())
- .append(IGitHubConstants.SUFFIX_JSON);
+ uri.append('/').append(issue.getNumber());
- Map<String, String> params = createIssueMap(issue);
+ Map<String, String> params = createIssueMap(issue, false);
String state = issue.getState();
if (state != null) {
params.put(FILTER_STATE, state);
}
- return this.client.put(uri.toString(), params, Issue.class);
+ return this.client.post(uri.toString(), params, Issue.class);
}
/**
@@ -260,8 +259,7 @@ public class IssueService extends GitHubService {
uri.append('/').append(user).append('/').append(repository);
uri.append(IGitHubConstants.SEGMENT_ISSUES);
uri.append('/').append(issueId);
- uri.append(IGitHubConstants.SEGMENT_COMMENTS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_COMMENTS);
Map<String, String> params = new HashMap<String, String>(1, 1);
params.put(FIELD_BODY, comment);
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java
index f1e5ceed..876afd33 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java
@@ -46,8 +46,7 @@ public class LabelService extends GitHubService {
Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
uri.append('/').append(user).append('/').append(repository);
- uri.append(IGitHubConstants.SEGMENT_LABELS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_LABELS);
ListResourceCollector<Label> collector = new ListResourceCollector<Label>();
PagedRequest<Label> request = new PagedRequest<Label>(collector);
request.setUri(uri).setType(new TypeToken<List<Label>>() {
@@ -74,12 +73,11 @@ public class LabelService extends GitHubService {
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
uri.append('/').append(user).append('/').append(repository);
uri.append(IGitHubConstants.SEGMENT_ISSUES).append('/').append(issueId);
- uri.append(IGitHubConstants.SEGMENT_LABELS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_LABELS);
- TypeToken<List<Label>> labelToken = new TypeToken<List<Label>>() {
- };
- return this.client.put(uri.toString(), labels, labelToken.getType());
+ return this.client.put(uri.toString(), labels,
+ new TypeToken<List<Label>>() {
+ }.getType());
}
/**
@@ -98,8 +96,7 @@ public class LabelService extends GitHubService {
Assert.isNotNull(label, "Label cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
uri.append('/').append(user).append('/').append(repository);
- uri.append(IGitHubConstants.SEGMENT_LABELS).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_LABELS);
return this.client.post(uri.toString(), label, Label.class);
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Messages.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Messages.java
index 23d71594..59617861 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Messages.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Messages.java
@@ -20,6 +20,18 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.mylyn.github.internal.messages"; //$NON-NLS-1$
/** */
+ public static String FieldError_InvalidField;
+
+ /** */
+ public static String FieldError_InvalidFieldWithValue;
+
+ /** */
+ public static String FieldError_MissingField;
+
+ /** */
+ public static String FieldError_ResourceError;
+
+ /** */
public static String GitHubRepositoryConnector_LabelConnector;
/** */
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/MilestoneService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/MilestoneService.java
index cfe3751c..c2f1459a 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/MilestoneService.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/MilestoneService.java
@@ -49,8 +49,7 @@ public class MilestoneService extends GitHubService {
Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
uri.append('/').append(user).append('/').append(repository);
- uri.append(IGitHubConstants.SEGMENT_MILESTONES).append(
- IGitHubConstants.SUFFIX_JSON);
+ uri.append(IGitHubConstants.SEGMENT_MILESTONES);
ListResourceCollector<Milestone> collector = new ListResourceCollector<Milestone>();
PagedRequest<Milestone> request = new PagedRequest<Milestone>(collector);
if (state != null)
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestError.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestError.java
index 0ba922ca..4efb7871 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestError.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestError.java
@@ -14,14 +14,14 @@ import java.util.List;
/**
* GitHub request error class
- *
+ *
* @author Kevin Sawicki (kevin@github.com)
*/
public class RequestError {
private String message;
- private List<String> errors;
+ private List<FieldError> errors;
/**
* @return message
@@ -32,10 +32,10 @@ public class RequestError {
/**
* Get errors
- *
+ *
* @return list of errors
*/
- public List<String> getErrors() {
+ public List<FieldError> getErrors() {
return this.errors;
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java
index e36122e3..1386180c 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.github.internal;
import java.io.IOException;
+import java.util.List;
/**
* Request exception class that wraps an {@link RequestError} object.
@@ -34,11 +35,24 @@ public class RequestException extends IOException {
* @param status
*/
public RequestException(RequestError error, int status) {
- super(error.getMessage());
+ super();
this.error = error;
this.status = status;
}
+ @Override
+ public String getMessage() {
+ StringBuilder message = new StringBuilder(error.getMessage());
+ List<FieldError> errors = error.getErrors();
+ if (errors != null && errors.size() > 0) {
+ message.append(':');
+ for (FieldError error : errors)
+ message.append(' ').append(error.format()).append(',');
+ message.deleteCharAt(message.length() - 1);
+ }
+ return message.toString();
+ }
+
/**
* Get error
*
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/messages.properties b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/messages.properties
index 942b9551..77706e84 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/messages.properties
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/messages.properties
@@ -1,3 +1,7 @@
+FieldError_InvalidField=Invalid value for field {1}
+FieldError_InvalidFieldWithValue=Invalid value of {0} for field {1}
+FieldError_MissingField=Missing required field {0}
+FieldError_ResourceError=Error with field {0} in {1} resource
GitHubRepositoryConnector_LabelConnector=GitHub Issues
GitHubRepositoryConnector_TaskQuerying=Querying repository...
GitHubRepositoryConnector_TaskUpdatingLabels=Updating labels
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 f7715205..833cecf3 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
@@ -86,7 +86,7 @@ public class GistServiceTest {
Gist gist = new Gist();
gist.setUser(null);
gistService.createGist(gist);
- verify(gitHubClient).post("/gists.json", gist, Gist.class);
+ verify(gitHubClient).post("/gists", gist, Gist.class);
}
@Test
@@ -96,8 +96,7 @@ public class GistServiceTest {
user.setLogin("test_user");
gist.setUser(user);
gistService.createGist(gist);
- verify(gitHubClient).post("/users/test_user/gists.json", gist,
- Gist.class);
+ verify(gitHubClient).post("/users/test_user/gists", gist, Gist.class);
}
@Test(expected = AssertionFailedException.class)
@@ -126,7 +125,7 @@ public class GistServiceTest {
Gist gist = new Gist();
gist.setId("123");
gistService.updateGist(gist);
- verify(gitHubClient).put("/gists/123.json", gist, Gist.class);
+ verify(gitHubClient).post("/gists/123", gist, Gist.class);
}
@Test(expected = AssertionFailedException.class)
@@ -145,8 +144,7 @@ public class GistServiceTest {
Map<String, String> params = new HashMap<String, String>(1, 1);
params.put(IssueService.FIELD_BODY, "test_comment");
- verify(gitHubClient).post("/gists/1/comments.json", params,
- Comment.class);
+ verify(gitHubClient).post("/gists/1/comments", params, Comment.class);
}
@Test(expected = AssertionFailedException.class)
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java
index 203183ea..c11f2e71 100644
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java
@@ -122,8 +122,7 @@ public class IssueServiceTest {
@Test
public void createIssue_NullIssue() throws IOException {
issueService.createIssue("test_user", "test_repository", null);
- verify(gitHubClient).post(
- "/repos/test_user/test_repository/issues.json",
+ verify(gitHubClient).post("/repos/test_user/test_repository/issues",
new HashMap<String, String>(), Issue.class);
}
@@ -155,9 +154,8 @@ public class IssueServiceTest {
params.put(IssueService.FIELD_TITLE, "test_title");
params.put(IssueService.FIELD_BODY, "test_body");
params.put(IssueService.FILTER_STATE, "test_state");
- verify(gitHubClient).put(
- "/repos/test_user/test_repository/issues/1.json", params,
- Issue.class);
+ verify(gitHubClient).post("/repos/test_user/test_repository/issues/1",
+ params, Issue.class);
}
@Test(expected = AssertionFailedException.class)
@@ -183,7 +181,7 @@ public class IssueServiceTest {
Map<String, String> params = new HashMap<String, String>();
params.put(IssueService.FIELD_BODY, "test_comment");
verify(gitHubClient).post(
- "/repos/test_user/test_repository/issues/1/comments.json",
- params, Comment.class);
+ "/repos/test_user/test_repository/issues/1/comments", params,
+ Comment.class);
}
}
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java
index d15fb336..543c8eca 100644
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/LabelServiceTest.java
@@ -95,7 +95,7 @@ public class LabelServiceTest {
TypeToken<List<Label>> labelsToken = new TypeToken<List<Label>>() {
};
verify(gitHubClient).put(
- "/repos/test_user/test_repository/issues/1/labels.json", null,
+ "/repos/test_user/test_repository/issues/1/labels", null,
labelsToken.getType());
}
@@ -106,8 +106,8 @@ public class LabelServiceTest {
TypeToken<List<Label>> labelsToken = new TypeToken<List<Label>>() {
};
verify(gitHubClient).put(
- "/repos/test_user/test_repository/issues/1/labels.json",
- labels, labelsToken.getType());
+ "/repos/test_user/test_repository/issues/1/labels", labels,
+ labelsToken.getType());
}
@Test(expected = AssertionFailedException.class)
@@ -130,7 +130,7 @@ public class LabelServiceTest {
Label label = new Label();
labelService.createLabel("test_user", "test_repository", label);
verify(gitHubClient).post(
- "/repos/test_user/test_repository/labels.json", label,
+ "/repos/test_user/test_repository/labels", label,
Label.class);
}
}

Back to the top