Skip to content

If a task contains both a comment and a like then parsing would fail. #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import com.cdancy.bitbucket.rest.BitbucketUtils;
import com.google.auto.value.AutoValue;
import java.util.Map;

import com.google.gson.JsonElement;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;

@AutoValue
public abstract class TaskAnchor {

public abstract Map<String, String> properties();
public abstract Map<String, JsonElement> properties();

public abstract int id();

Expand All @@ -53,7 +55,7 @@ public abstract class TaskAnchor {

@SerializedNames({ "properties", "id", "version", "text",
"author", "createdDate", "updatedDate", "permittedOperations", "type" })
public static TaskAnchor create(final Map<String, String> properties,
public static TaskAnchor create(final Map<String, JsonElement> properties,
final int id,
final int version,
final String text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ public void testGetPullRequestActivities() throws Exception {
final Task task = comments.tasks().get(0);
assertThat(task.anchor().type()).isEqualTo("COMMENT");
assertThat(task.state()).isEqualTo("OPEN");
assertThat(task.anchor().properties().keySet().contains("likedBy"));
assertThat(task.anchor().properties().keySet().contains("repositoryId"));

final Map<String, ?> queryParams = ImmutableMap.of(startKeyword, "0", limitKeyword, 5);
assertSent(server, getMethod, restApiPath + BitbucketApiMetadata.API_VERSION
Expand Down
25 changes: 23 additions & 2 deletions src/test/resources/pull-request-activities.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"action":"COMMENTED",
"commentAction":"ADDED",
"comment":{
"properties":{
"properties":{
"repositoryId":59
},
"id":1465,
Expand Down Expand Up @@ -98,7 +98,28 @@
"tasks":[
{
"anchor":{
"properties":{
"properties":{
"likedBy": {
"total": 1,
"likers": [
{
"name": "example_user",
"emailAddress": "[email protected]",
"id": 1,
"displayName": "Example User",
"active": true,
"slug": "example_user",
"type": "NORMAL",
"links": {
"self": [
{
"href": "http://git.public.io/users/example_user"
}
]
}
}
]
},
"repositoryId":59
},
"id":1465,
Expand Down