@Test public void testGetCardAttachment() { //Given Attachment mockAttachement = new Attachment(); mockAttachement.setId("idAttach"); when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockAttachement); //When Attachment cardAttachment = trello.getCardAttachment("idCard", "idAttach"); assertThat(cardAttachment).isNotNull(); assertThat(cardAttachment.getId()).isEqualTo("idAttach"); verify(httpClient).get(eq("https://api.trello.com/1/cards/{cardId}/attachments/{attachmentId}?key={applicationKey}&token={userToken}"), eq(Attachment.class), eq("idCard"), eq("idAttach"), eq(""), eq("")); verifyNoMoreInteractions(httpClient); }
@Override public List<Attachment> getCardAttachments(String cardId, Argument... args) { List<Attachment> attachments = Arrays.asList(get(createUrl(GET_CARD_ATTACHMENTS).params(args).asString(), Attachment[].class, cardId)); for (Attachment attachment : attachments) { attachment.setInternalTrello(this); } return attachments; }
@Override public void addUrlAttachmentToCard(String idCard, String url) { postForObject(createUrl(ADD_ATTACHMENT_TO_CARD).asString(), new Attachment(url), Attachment.class, idCard); }
@Test public void testGetCardAttachments() { List<Attachment> cardAttachments = trello.getCardAttachments(CARD_ID); assertThat(cardAttachments).isNotNull(); assertThat(cardAttachments).hasSize(1); assertThat(cardAttachments.get(0).getId()).isEqualTo("519902b653ac28d57e00ec3b"); }
@Test public void testGetCardAttachment() { Attachment cardAttachment = trello.getCardAttachment(CARD_ID, "519902b653ac28d57e00ec3b"); assertThat(cardAttachment).isNotNull(); assertThat(cardAttachment.getId()).isEqualTo("519902b653ac28d57e00ec3b"); }
@Test public void testGetCardAttachments() { //Given Attachment action1 = new Attachment(); action1.setId("idAttach1"); Attachment action2 = new Attachment(); action1.setId("idAttach2"); Attachment action3 = new Attachment(); action1.setId("idAttach3"); when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(new Attachment[]{action1, action2, action3}); //When List<Attachment> cardAttachments = trello.getCardAttachments("idCard"); //Then assertThat(cardAttachments).isNotNull(); assertThat(cardAttachments).hasSize(3); assertThat(cardAttachments.get(0).getId()).isEqualTo("idAttach3"); verify(httpClient).get(eq("https://api.trello.com/1/cards/{cardId}/attachments?key={applicationKey}&token={userToken}"), eq(Attachment[].class), eq("idCard"), eq(""), eq("")); verifyNoMoreInteractions(httpClient); }
@Override public List<Attachment> getCardAttachments(String cardId, Argument... args) { List<Attachment> attachments = Arrays.asList(get(createUrl(GET_CARD_ATTACHMENTS).params(args).asString(), Attachment[].class, cardId)); for (Attachment attachment : attachments) { attachment.setInternalTrello(this); } return attachments; }
@Override public Attachment getCardAttachment(String cardId, String attachmentId, Argument... args) { Attachment attachment = get(createUrl(GET_CARD_ATTACHMENT).params(args).asString(), Attachment.class, cardId, attachmentId); attachment.setInternalTrello(this); return attachment; }
@Override public Attachment getCardAttachment(String cardId, String attachmentId, Argument... args) { Attachment attachment = get(createUrl(GET_CARD_ATTACHMENT).params(args).asString(), Attachment.class, cardId, attachmentId); attachment.setInternalTrello(this); return attachment; }