Skip to content

Commit

Permalink
Merge pull request #111 from cielowu/master
Browse files Browse the repository at this point in the history
Add attachments into Task model
  • Loading branch information
rossgrambo-zz authored Sep 11, 2020
2 parents 0a8c011 + 90cfa6d commit fc8b386
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/asana/models/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ public static class Membership {
public Collection<Heart> hearts;
@SerializedName("num_hearts")
public int numHearts;

public Collection<Attachment> attachments;
}
37 changes: 37 additions & 0 deletions src/test/java/com/asana/resources/TasksTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.asana.resources;

import com.asana.AsanaTest;
import com.asana.models.Attachment;
import com.asana.models.Task;

import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.Assert.assertEquals;

public class TasksTest extends AsanaTest {
@Test
public void testGetTaskWithAttachments() throws IOException {
String res = "{ \"data\": {\"gid\": 1, \"name\": \"test task\", \"attachments\": " +
"[{\"gid\": 2, \"name\": \"test attachment\"}] } }";
dispatcher
.registerResponse("GET", "http://app/tasks/1?opt_fields=gid,name,attachments.name")
.code(200)
.content(res);

Task task = client.tasks
.findById("1")
.option("fields", Arrays.asList("gid", "name", "attachments.name"))
.execute();

assertEquals("1", task.gid);
assertEquals("test task", task.name);
assertEquals(1, task.attachments.size());
Attachment attachment = new ArrayList<>(task.attachments).get(0);
assertEquals("2", attachment.gid);
assertEquals("test attachment", attachment.name);
}
}

0 comments on commit fc8b386

Please sign in to comment.