Skip to content

Commit 6dbd6af

Browse files
committed
ChosenInlineResult support
1 parent e98297f commit 6dbd6af

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
/**
4+
* stas
5+
* 1/20/16.
6+
*/
7+
public class ChosenInlineResult {
8+
9+
private String result_id;
10+
private User from;
11+
private String query;
12+
13+
ChosenInlineResult() {
14+
}
15+
16+
public String resultId() {
17+
return result_id;
18+
}
19+
20+
public User from() {
21+
return from;
22+
}
23+
24+
public String query() {
25+
return query;
26+
}
27+
28+
@Override
29+
public boolean equals(Object o) {
30+
if (this == o) return true;
31+
if (o == null || getClass() != o.getClass()) return false;
32+
33+
ChosenInlineResult that = (ChosenInlineResult) o;
34+
35+
if (result_id != null ? !result_id.equals(that.result_id) : that.result_id != null) return false;
36+
if (from != null ? !from.equals(that.from) : that.from != null) return false;
37+
return query != null ? query.equals(that.query) : that.query == null;
38+
39+
}
40+
41+
@Override
42+
public int hashCode() {
43+
return result_id != null ? result_id.hashCode() : 0;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
return "ChosenInlineResult{" +
49+
"result_id='" + result_id + '\'' +
50+
", from=" + from +
51+
", query='" + query + '\'' +
52+
'}';
53+
}
54+
}

src/main/java/com/pengrad/telegrambot/model/Update.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class Update {
99
private Integer update_id;
1010
private Message message;
1111
private InlineQuery inline_query;
12+
private ChosenInlineResult chosen_inline_result;
1213

1314
Update() {
1415
}
@@ -25,6 +26,10 @@ public InlineQuery inlineQuery() {
2526
return inline_query;
2627
}
2728

29+
public ChosenInlineResult chosenInlineResult() {
30+
return chosen_inline_result;
31+
}
32+
2833
@Override
2934
public boolean equals(Object o) {
3035
if (this == o) return true;
@@ -34,7 +39,9 @@ public boolean equals(Object o) {
3439

3540
if (update_id != null ? !update_id.equals(update.update_id) : update.update_id != null) return false;
3641
if (message != null ? !message.equals(update.message) : update.message != null) return false;
37-
return inline_query != null ? inline_query.equals(update.inline_query) : update.inline_query == null;
42+
if (inline_query != null ? !inline_query.equals(update.inline_query) : update.inline_query != null)
43+
return false;
44+
return chosen_inline_result != null ? chosen_inline_result.equals(update.chosen_inline_result) : update.chosen_inline_result == null;
3845
}
3946

4047
@Override
@@ -48,6 +55,7 @@ public String toString() {
4855
"update_id=" + update_id +
4956
", message=" + message +
5057
", inline_query=" + inline_query +
58+
", chosen_inline_result=" + chosen_inline_result +
5159
'}';
5260
}
5361
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.pengrad.telegrambot;
2+
3+
import com.pengrad.telegrambot.model.ChosenInlineResult;
4+
5+
import static org.junit.Assert.assertNotNull;
6+
7+
/**
8+
* stas
9+
* 1/20/16.
10+
*/
11+
public class ChosenInlineResultTest {
12+
13+
public static void check(ChosenInlineResult result) {
14+
assertNotNull(result.resultId());
15+
assertNotNull(result.query());
16+
UserTest.checkUser(result.from());
17+
}
18+
19+
}

src/test/java/com/pengrad/telegrambot/UpdateTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public static void check(List<Update> updates) {
1717
assertNotNull(update.updateId());
1818
if (update.message() != null) MessageTest.checkMessage(update.message());
1919
else if (update.inlineQuery() != null) InlineQueryTest.checkQuery(update.inlineQuery());
20-
else throw new RuntimeException("Both message and inlineQuery are null");
20+
else if (update.chosenInlineResult() != null) ChosenInlineResultTest.check(update.chosenInlineResult());
21+
else throw new RuntimeException("Message and inlineQuery and chosenInlineResult are null");
2122
}
2223
}
2324

0 commit comments

Comments
 (0)