Skip to content

Commit 3496baf

Browse files
committed
Implement get checklist
1 parent 7302c1a commit 3496baf

5 files changed

Lines changed: 118 additions & 0 deletions

File tree

src/main/java/com/julienvey/trello/Trello.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ List<CardWithActions> getBoardMemberActivity(String boardId, String memberId,
7979

8080
TList getList(String listId, Argument... args);
8181

82+
/* CheckLists */
83+
84+
CheckList getCheckList(String checkListId, Argument... args);
85+
8286
/////////////////
8387

8488
Card createCard(String listId, Card card);

src/main/java/com/julienvey/trello/impl/TrelloImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,15 @@ public TList getList(String listId, Argument... args) {
258258
return tList;
259259
}
260260

261+
/* CheckLists */
262+
263+
@Override
264+
public CheckList getCheckList(String checkListId, Argument... args) {
265+
CheckList checkList = get(createUrl(GET_CHECK_LIST).params(args).asString(), CheckList.class, checkListId);
266+
checkList.setInternalTrello(this);
267+
return checkList;
268+
}
269+
261270
/* Others */
262271

263272
@Override

src/main/java/com/julienvey/trello/impl/TrelloUrl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public class TrelloUrl {
3636

3737
public static final String GET_LIST = "/lists/{listId}?";
3838

39+
public static final String GET_CHECK_LIST = "/checklists/{checkListId}?";
40+
3941
public static final String CREATE_CARD = "/cards?pos=top&";
4042
public static final String GET_MEMBER = "/members/{username}?";
4143
public static final String ADD_LABEL_TO_CARD = "/cards/{cardId}/labels?";
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.julienvey.trello.integration;
2+
3+
import com.julienvey.trello.Trello;
4+
import com.julienvey.trello.TrelloHttpClient;
5+
import com.julienvey.trello.domain.CheckList;
6+
import com.julienvey.trello.impl.TrelloImpl;
7+
import com.julienvey.trello.impl.http.ApacheHttpClient;
8+
import com.julienvey.trello.impl.http.AsyncTrelloHttpClient;
9+
import com.julienvey.trello.impl.http.RestTemplateHttpClient;
10+
import org.junit.Before;
11+
import org.junit.Test;
12+
import org.junit.runner.RunWith;
13+
import org.junit.runners.Parameterized;
14+
15+
import java.util.Arrays;
16+
import java.util.Collection;
17+
18+
import static org.fest.assertions.Assertions.assertThat;
19+
20+
@RunWith(Parameterized.class)
21+
public class CheckListGetITCase {
22+
23+
private static final String TEST_APPLICATION_KEY = "db555c528ce160c33305d2ea51ae1197";
24+
public static final String CHECK_LIST_ID = "51990272b1740a191800e5af";
25+
26+
private Trello trello;
27+
28+
private TrelloHttpClient httpClient;
29+
30+
@Parameterized.Parameters
31+
public static Collection<Object[]> data() {
32+
return Arrays.asList(new Object[][]{{new ApacheHttpClient()}, {new AsyncTrelloHttpClient()}, {new RestTemplateHttpClient()}});
33+
}
34+
35+
public CheckListGetITCase(TrelloHttpClient httpClient) {
36+
this.httpClient = httpClient;
37+
}
38+
39+
@Before
40+
public void setUp() {
41+
trello = new TrelloImpl(TEST_APPLICATION_KEY, "", httpClient);
42+
}
43+
44+
@Test
45+
public void testGetCheckList(){
46+
CheckList checkList = trello.getCheckList(CHECK_LIST_ID);
47+
48+
assertThat(checkList).isNotNull();
49+
assertThat(checkList.getId()).isEqualTo(CHECK_LIST_ID);
50+
}
51+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.julienvey.trello.unit;
2+
3+
import com.julienvey.trello.Trello;
4+
import com.julienvey.trello.TrelloHttpClient;
5+
import com.julienvey.trello.domain.Card;
6+
import com.julienvey.trello.domain.CheckList;
7+
import com.julienvey.trello.impl.TrelloImpl;
8+
import org.junit.Before;
9+
import org.junit.Test;
10+
import org.mockito.Mockito;
11+
12+
import static org.fest.assertions.Assertions.assertThat;
13+
import static org.mockito.Matchers.any;
14+
import static org.mockito.Matchers.anyString;
15+
import static org.mockito.Matchers.anyVararg;
16+
import static org.mockito.Matchers.eq;
17+
import static org.mockito.Mockito.verify;
18+
import static org.mockito.Mockito.verifyNoMoreInteractions;
19+
import static org.mockito.Mockito.when;
20+
21+
public class CheckListGetUnitTest {
22+
23+
private Trello trello;
24+
25+
private TrelloHttpClient httpClient;
26+
27+
@Before
28+
public void setUp() {
29+
httpClient = Mockito.mock(TrelloHttpClient.class);
30+
trello = new TrelloImpl("", "", httpClient);
31+
}
32+
33+
@Test
34+
public void testGetCheckList() {
35+
//Given
36+
CheckList mockCheckList = new CheckList();
37+
mockCheckList.setId("idCheckList");
38+
39+
when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockCheckList);
40+
41+
//When
42+
CheckList checkList = trello.getCheckList("idCheckList");
43+
44+
//Then
45+
assertThat(checkList).isNotNull();
46+
assertThat(checkList.getId()).isEqualTo("idCheckList");
47+
48+
verify(httpClient).get(eq("https://api.trello.com/1/checklists/{checkListId}?key={applicationKey}&token={userToken}"),
49+
eq(CheckList.class), eq("idCheckList"), eq(""), eq(""));
50+
verifyNoMoreInteractions(httpClient);
51+
}
52+
}

0 commit comments

Comments
 (0)