@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 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 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); }
@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); }