Skip to content

Commit fc8b386

Browse files
Merge pull request #111 from cielowu/master
Add attachments into Task model
2 parents 0a8c011 + 90cfa6d commit fc8b386

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/main/java/com/asana/models/Task.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ public static class Membership {
7777
public Collection<Heart> hearts;
7878
@SerializedName("num_hearts")
7979
public int numHearts;
80+
81+
public Collection<Attachment> attachments;
8082
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.asana.resources;
2+
3+
import com.asana.AsanaTest;
4+
import com.asana.models.Attachment;
5+
import com.asana.models.Task;
6+
7+
import org.junit.Test;
8+
9+
import java.io.IOException;
10+
import java.util.ArrayList;
11+
import java.util.Arrays;
12+
13+
import static org.junit.Assert.assertEquals;
14+
15+
public class TasksTest extends AsanaTest {
16+
@Test
17+
public void testGetTaskWithAttachments() throws IOException {
18+
String res = "{ \"data\": {\"gid\": 1, \"name\": \"test task\", \"attachments\": " +
19+
"[{\"gid\": 2, \"name\": \"test attachment\"}] } }";
20+
dispatcher
21+
.registerResponse("GET", "http://app/tasks/1?opt_fields=gid,name,attachments.name")
22+
.code(200)
23+
.content(res);
24+
25+
Task task = client.tasks
26+
.findById("1")
27+
.option("fields", Arrays.asList("gid", "name", "attachments.name"))
28+
.execute();
29+
30+
assertEquals("1", task.gid);
31+
assertEquals("test task", task.name);
32+
assertEquals(1, task.attachments.size());
33+
Attachment attachment = new ArrayList<>(task.attachments).get(0);
34+
assertEquals("2", attachment.gid);
35+
assertEquals("test attachment", attachment.name);
36+
}
37+
}

0 commit comments

Comments
 (0)