Skip to content

Commit

Permalink
Added caption_entities in Message
Browse files Browse the repository at this point in the history
  • Loading branch information
pengrad committed Oct 11, 2017
1 parent b05201a commit f964bf8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Message implements Serializable {
private String author_signature;
private String text;
private MessageEntity[] entities;
private MessageEntity[] caption_entities;
private Audio audio;
private Document document;
private Game game;
Expand Down Expand Up @@ -107,6 +108,10 @@ public MessageEntity[] entities() {
return entities;
}

public MessageEntity[] captionEntities() {
return caption_entities;
}

public Audio audio() {
return audio;
}
Expand Down Expand Up @@ -242,6 +247,8 @@ public boolean equals(Object o) {
if (text != null ? !text.equals(message.text) : message.text != null) return false;
// Probably incorrect - comparing Object[] arrays with Arrays.equals
if (!Arrays.equals(entities, message.entities)) return false;
// Probably incorrect - comparing Object[] arrays with Arrays.equals
if (!Arrays.equals(caption_entities, message.caption_entities)) return false;
if (audio != null ? !audio.equals(message.audio) : message.audio != null) return false;
if (document != null ? !document.equals(message.document) : message.document != null) return false;
if (game != null ? !game.equals(message.game) : message.game != null) return false;
Expand Down Expand Up @@ -305,6 +312,7 @@ public String toString() {
", author_signature='" + author_signature + '\'' +
", text='" + text + '\'' +
", entities=" + Arrays.toString(entities) +
", caption_entities=" + Arrays.toString(caption_entities) +
", audio=" + audio +
", document=" + document +
", game=" + game +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public void sendAudio() throws IOException {
AudioTest.checkAudio(message.audio());

byte[] bytes = Files.readAllBytes(new File(audioFile).toPath());
String cap = "cap", title = "title", performer = "performer";
String cap = "http://ya.ru", title = "title", performer = "performer";
int duration = 100;
SendAudio sendAudio = new SendAudio(chatId, bytes).duration(duration).caption(cap).performer(performer).title(title);
message = bot.execute(sendAudio).message();
Expand All @@ -473,6 +473,11 @@ public void sendAudio() throws IOException {
assertEquals((Integer) 100, audio.duration());
assertEquals(performer, audio.performer());
assertEquals(title, audio.title());

MessageEntity captionEntity = message.captionEntities()[0];
assertEquals(MessageEntity.Type.url, captionEntity.type());
assertEquals((Integer) 0, captionEntity.offset());
assertEquals((Integer) 12, captionEntity.length());
}

@Test
Expand Down

0 comments on commit f964bf8

Please sign in to comment.