diff --git a/src/main/java/com/asana/models/Task.java b/src/main/java/com/asana/models/Task.java index 0fb8f54..0e487e4 100644 --- a/src/main/java/com/asana/models/Task.java +++ b/src/main/java/com/asana/models/Task.java @@ -77,4 +77,6 @@ public static class Membership { public Collection hearts; @SerializedName("num_hearts") public int numHearts; + + public Collection attachments; } diff --git a/src/test/java/com/asana/resources/TasksTest.java b/src/test/java/com/asana/resources/TasksTest.java new file mode 100644 index 0000000..aa9e127 --- /dev/null +++ b/src/test/java/com/asana/resources/TasksTest.java @@ -0,0 +1,37 @@ +package com.asana.resources; + +import com.asana.AsanaTest; +import com.asana.models.Attachment; +import com.asana.models.Task; +import com.sun.tools.javac.util.List; + +import org.junit.Test; + +import java.io.IOException; +import java.util.ArrayList; + +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", List.of("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); + } +}