@Override public List<Action> getBoardActions(String boardId, Argument... args) { List<Action> actions = Arrays.asList(get(createUrl(GET_BOARD_ACTIONS).params(args).asString(), Action[].class, boardId)); for (Action action : actions) { action.setInternalTrello(this); } return actions; }
@Test public void testGetBoardActions() { // Given Action action1 = new Action(); action1.setId("idAction1"); Action action2 = new Action(); action1.setId("idAction2"); Action action3 = new Action(); action1.setId("idAction3"); when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(new Action[] { action1, action2, action3 }); // When List<Action> boardActions = trello.getBoardActions("idBoard"); // Then assertThat(boardActions).isNotNull(); assertThat(boardActions).hasSize(3); assertThat(boardActions.get(0).getId()).isEqualTo("idAction3"); verify(httpClient).get(eq("https://api.trello.com/1/boards/{boardId}/actions?key={applicationKey}&token={userToken}"), eq(Action[].class), eq("idBoard"), eq(""), eq("")); verifyNoMoreInteractions(httpClient); }
@Test public void testGetActionById() { //Given Action mockAction = new Action(); mockAction.setId("idAction"); mockAction.setType("createCard"); when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockAction); //When Action action = trello.getAction("idAction"); //Then assertThat(action).isNotNull(); assertThat(action.getId()).isEqualTo("idAction"); assertThat(action.getType()).isEqualTo("createCard"); verify(httpClient).get(eq("https://api.trello.com/1/actions/{actionId}?key={applicationKey}&token={userToken}"), eq(Action.class), eq("idAction"), eq(""), eq("")); verifyNoMoreInteractions(httpClient); }
@Test public void testGetMemberActions() { // Given Action action1 = new Action(); action1.setId("1"); Action action2 = new Action(); action2.setId("2"); when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(new Action[] { action1, action2 }); // When List<Action> memberActions = trello.getMemberActions("idMember"); // Then assertThat(memberActions) .isNotNull() .hasSize(2) .containsExactly(action1, action2); verify(httpClient).get(eq("https://api.trello.com/1/members/{userId}/actions?key={applicationKey}&token={userToken}"), eq(Action[].class), eq("idMember"), eq(""), eq("")); verifyNoMoreInteractions(httpClient); } }
@Test public void testGetCardActions() { List<Action> cardActions = trello.getCardActions(CARD_ID); assertThat(cardActions).isNotNull(); assertThat(cardActions).hasSize(1); assertThat(cardActions.get(0).getId()).isEqualTo("5199029a7c4f3ca30a00136a"); }
@Test public void testGetBoardMemberActivityComments() { List<CardWithActions> commentActivity = trello.getBoardMemberActivity(BOARD_ID, "5187a69eabd0b7305100beaa", "commentCard"); assertThat(commentActivity).isNotNull(); assertThat(commentActivity).hasSize(1); assertThat(commentActivity.get(0).getActions()).isNotNull(); assertThat(commentActivity.get(0).getActions()).hasSize(1); assertThat(commentActivity.get(0).getActions().get(0)).isNotNull(); assertThat(commentActivity.get(0).getActions().get(0).getData()).isNotNull(); assertThat(commentActivity.get(0).getActions().get(0).getData().getText()).isNotNull(); assertThat(commentActivity.get(0).getActions().get(0).getData().getText()) .isEqualToIgnoringCase("a comment"); } }
@Test public void testGetBoardActions() { List<Action> boardActions = trello.getBoardActions(BOARD_ID); assertThat(boardActions).isNotNull(); assertThat(boardActions).hasSize(26); assertThat(boardActions.get(0).getId()).isEqualTo("51990c2143453ab27e0087d5"); }
@Override public List<Action> getCardActions(String cardId, Argument... args) { List<Action> actions = Arrays.asList(get(createUrl(GET_CARD_ACTIONS).params(args).asString(), Action[].class, cardId)); for (Action action : actions) { action.setInternalTrello(this); } return actions; }
@Test public void testGetCardActions() { //Given Action action1 = new Action(); action1.setId("idAction1"); Action action2 = new Action(); action1.setId("idAction2"); Action action3 = new Action(); action1.setId("idAction3"); when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(new Action[]{action1, action2, action3}); //When List<Action> cardActions = trello.getCardActions("idCard"); //Then assertThat(cardActions).isNotNull(); assertThat(cardActions).hasSize(3); assertThat(cardActions.get(0).getId()).isEqualTo("idAction3"); verify(httpClient).get(eq("https://api.trello.com/1/cards/{cardId}/actions?key={applicationKey}&token={userToken}"), eq(Action[].class), eq("idCard"), eq(""), eq("")); verifyNoMoreInteractions(httpClient); }
@Override public List<Action> getCardActions(String cardId, Argument... args) { List<Action> actions = Arrays.asList(get(createUrl(GET_CARD_ACTIONS).params(args).asString(), Action[].class, cardId)); for (Action action : actions) { action.setInternalTrello(this); } return actions; }
@Override public List<Action> getBoardActions(String boardId, Argument... args) { List<Action> actions = Arrays.asList(get(createUrl(GET_BOARD_ACTIONS).params(args).asString(), Action[].class, boardId)); for (Action action : actions) { action.setInternalTrello(this); } return actions; }
@Override public List<Action> getMemberActions(String userId, Argument... args) { List<Action> actions = Arrays.asList(get(createUrl(GET_MEMBER_ACTIONS).params(args).asString(), Action[].class, userId)); for (Action action : actions) { action.setInternalTrello(this); } return actions; }
@Override public Action getAction(String actionId, Argument... args) { Action action = get(createUrl(GET_ACTION).params(args).asString(), Action.class, actionId); action.setInternalTrello(this); return action; }
@Override public Action getAction(String actionId, Argument... args) { Action action = get(createUrl(GET_ACTION).params(args).asString(), Action.class, actionId); action.setInternalTrello(this); return action; }