Skip to content

Commit 0832bf1

Browse files
committed
Test more model classes
1 parent cdfd85c commit 0832bf1

24 files changed

+288
-298
lines changed

library/src/main/java/com/pengrad/telegrambot/model/business/BusinessConnection.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,25 @@ public Boolean isEnabled() {
4040
@Override
4141
public boolean equals(Object o) {
4242
if (this == o) return true;
43-
if (!(o instanceof BusinessConnection)) return false;
43+
if (o == null || getClass() != o.getClass()) return false;
4444
BusinessConnection that = (BusinessConnection) o;
45-
return Objects.equals(id, that.id)
46-
&& Objects.equals(user, that.user)
47-
&& Objects.equals(user_chat_id, that.user_chat_id)
48-
&& Objects.equals(date, that.date)
49-
&& Objects.equals(can_reply, that.can_reply)
50-
&& Objects.equals(is_enabled, that.is_enabled);
45+
return Objects.equals(id, that.id) && Objects.equals(user, that.user) && Objects.equals(user_chat_id, that.user_chat_id) && Objects.equals(date, that.date) && Objects.equals(can_reply, that.can_reply) && Objects.equals(is_enabled, that.is_enabled);
5146
}
5247

5348
@Override
5449
public int hashCode() {
55-
return id != null ? id.hashCode() : 0;
50+
return Objects.hash(id, user, user_chat_id, date, can_reply, is_enabled);
51+
}
52+
53+
@Override
54+
public String toString() {
55+
return "BusinessConnection{" +
56+
"id='" + id + '\'' +
57+
", user=" + user +
58+
", user_chat_id=" + user_chat_id +
59+
", date=" + date +
60+
", can_reply=" + can_reply +
61+
", is_enabled=" + is_enabled +
62+
'}';
5663
}
5764
}

library/src/main/java/com/pengrad/telegrambot/model/business/BusinessIntro.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ public Sticker sticker() {
2525
@Override
2626
public boolean equals(Object o) {
2727
if (this == o) return true;
28-
if (!(o instanceof BusinessIntro)) return false;
28+
if (o == null || getClass() != o.getClass()) return false;
2929
BusinessIntro that = (BusinessIntro) o;
30-
return Objects.equals(title, that.title)
31-
&& Objects.equals(message, that.message)
32-
&& Objects.equals(sticker, that.sticker);
30+
return Objects.equals(title, that.title) && Objects.equals(message, that.message) && Objects.equals(sticker, that.sticker);
3331
}
3432

3533
@Override
@@ -40,9 +38,9 @@ public int hashCode() {
4038
@Override
4139
public String toString() {
4240
return "BusinessIntro{" +
43-
"title='" + title + '\'' +
44-
", message='" + message + '\'' +
45-
", sticker=" + sticker +
46-
'}';
41+
"title='" + title + '\'' +
42+
", message='" + message + '\'' +
43+
", sticker=" + sticker +
44+
'}';
4745
}
4846
}

library/src/main/java/com/pengrad/telegrambot/model/business/BusinessLocation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public Location location() {
2020
@Override
2121
public boolean equals(Object o) {
2222
if (this == o) return true;
23-
if (!(o instanceof BusinessLocation)) return false;
23+
if (o == null || getClass() != o.getClass()) return false;
2424
BusinessLocation that = (BusinessLocation) o;
2525
return Objects.equals(address, that.address) && Objects.equals(location, that.location);
2626
}
@@ -33,8 +33,8 @@ public int hashCode() {
3333
@Override
3434
public String toString() {
3535
return "BusinessLocation{" +
36-
"address='" + address + '\'' +
37-
", location=" + location +
38-
'}';
36+
"address='" + address + '\'' +
37+
", location=" + location +
38+
'}';
3939
}
4040
}

library/src/main/java/com/pengrad/telegrambot/model/business/BusinessMessageDeleted.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,22 @@ public Integer[] messageIds() {
2626
@Override
2727
public boolean equals(Object o) {
2828
if (this == o) return true;
29-
if (!(o instanceof BusinessMessageDeleted)) return false;
29+
if (o == null || getClass() != o.getClass()) return false;
3030
BusinessMessageDeleted that = (BusinessMessageDeleted) o;
31-
return Objects.equals(business_connection_id, that.business_connection_id)
32-
&& Objects.equals(chat, that.chat)
33-
&& Arrays.equals(message_ids, that.message_ids);
31+
return Objects.equals(business_connection_id, that.business_connection_id) && Objects.equals(chat, that.chat) && Objects.deepEquals(message_ids, that.message_ids);
3432
}
3533

3634
@Override
3735
public int hashCode() {
38-
int result = Objects.hash(business_connection_id, chat);
39-
result = 31 * result + Arrays.hashCode(message_ids);
40-
return result;
36+
return Objects.hash(business_connection_id, chat, Arrays.hashCode(message_ids));
4137
}
4238

4339
@Override
4440
public String toString() {
4541
return "BusinessMessageDeleted{" +
46-
"business_connection_id='" + business_connection_id + '\'' +
47-
", chat=" + chat +
48-
", message_ids=" + Arrays.toString(message_ids) +
49-
'}';
42+
"business_connection_id='" + business_connection_id + '\'' +
43+
", chat=" + chat +
44+
", message_ids=" + Arrays.toString(message_ids) +
45+
'}';
5046
}
5147
}

library/src/main/java/com/pengrad/telegrambot/model/business/BusinessOpeningHours.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,21 @@ public BusinessOpeningHoursInterval[] openingHours() {
1919
@Override
2020
public boolean equals(Object o) {
2121
if (this == o) return true;
22-
if (!(o instanceof BusinessOpeningHours)) return false;
22+
if (o == null || getClass() != o.getClass()) return false;
2323
BusinessOpeningHours that = (BusinessOpeningHours) o;
24-
return Objects.equals(time_zone_name, that.time_zone_name) && Arrays.equals(opening_hours, that.opening_hours);
24+
return Objects.equals(time_zone_name, that.time_zone_name) && Objects.deepEquals(opening_hours, that.opening_hours);
2525
}
2626

2727
@Override
2828
public int hashCode() {
29-
int result = Objects.hash(time_zone_name);
30-
result = 31 * result + Arrays.hashCode(opening_hours);
31-
return result;
29+
return Objects.hash(time_zone_name, Arrays.hashCode(opening_hours));
3230
}
3331

3432
@Override
3533
public String toString() {
3634
return "BusinessOpeningHours{" +
37-
"time_zone_name='" + time_zone_name + '\'' +
38-
", opening_hours=" + Arrays.toString(opening_hours) +
39-
'}';
35+
"time_zone_name='" + time_zone_name + '\'' +
36+
", opening_hours=" + Arrays.toString(opening_hours) +
37+
'}';
4038
}
4139
}

library/src/main/java/com/pengrad/telegrambot/model/business/BusinessOpeningHoursInterval.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ public Integer closing_minute() {
1818
@Override
1919
public boolean equals(Object o) {
2020
if (this == o) return true;
21-
if (!(o instanceof BusinessOpeningHoursInterval)) return false;
21+
if (o == null || getClass() != o.getClass()) return false;
2222
BusinessOpeningHoursInterval that = (BusinessOpeningHoursInterval) o;
23-
return Objects.equals(opening_minute, that.opening_minute)
24-
&& Objects.equals(closing_minute, that.closing_minute);
23+
return Objects.equals(opening_minute, that.opening_minute) && Objects.equals(closing_minute, that.closing_minute);
2524
}
2625

2726
@Override
@@ -32,8 +31,8 @@ public int hashCode() {
3231
@Override
3332
public String toString() {
3433
return "BusinessOpeningHoursInterval{" +
35-
"opening_minute=" + opening_minute +
36-
", closing_minute=" + closing_minute +
37-
'}';
34+
"opening_minute=" + opening_minute +
35+
", closing_minute=" + closing_minute +
36+
'}';
3837
}
3938
}

library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillFreeformGradient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.pengrad.telegrambot.model.chatbackground;
22

33
import java.util.Arrays;
4+
import java.util.Objects;
45

56
public class BackgroundFillFreeformGradient extends BackgroundFill {
67

@@ -21,20 +22,20 @@ public Integer[] colors() {
2122
public boolean equals(Object o) {
2223
if (this == o) return true;
2324
if (o == null || getClass() != o.getClass()) return false;
25+
if (!super.equals(o)) return false;
2426
BackgroundFillFreeformGradient that = (BackgroundFillFreeformGradient) o;
25-
return Arrays.equals(colors, that.colors);
27+
return Objects.deepEquals(colors, that.colors);
2628
}
2729

2830
@Override
2931
public int hashCode() {
30-
return Arrays.hashCode(colors);
32+
return Objects.hash(super.hashCode(), Arrays.hashCode(colors));
3133
}
3234

3335
@Override
3436
public String toString() {
3537
return "BackgroundFillFreeformGradient{" +
36-
"type='" + type() + '\'' +
37-
", colors=" + Arrays.asList(colors) +
38-
'}';
38+
"colors=" + Arrays.toString(colors) +
39+
'}';
3940
}
4041
}

library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillGradient.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,23 @@ public Integer rotationAngle() {
3333
public boolean equals(Object o) {
3434
if (this == o) return true;
3535
if (o == null || getClass() != o.getClass()) return false;
36+
if (!super.equals(o)) return false;
3637
BackgroundFillGradient that = (BackgroundFillGradient) o;
3738
return Objects.equals(top_color, that.top_color) && Objects.equals(bottom_color, that.bottom_color) && Objects.equals(rotation_angle, that.rotation_angle);
3839
}
3940

4041
@Override
4142
public int hashCode() {
42-
return Objects.hash(top_color, bottom_color, rotation_angle);
43+
return Objects.hash(super.hashCode(), top_color, bottom_color, rotation_angle);
4344
}
4445

4546
@Override
4647
public String toString() {
4748
return "BackgroundFillGradient{" +
48-
"type='" + type() + '\'' +
49-
", top_color=" + top_color +
50-
", bottom_color=" + bottom_color +
51-
", rotation_angle=" + rotation_angle +
52-
'}';
49+
"type='" + type() + '\'' +
50+
", top_color=" + top_color +
51+
", bottom_color=" + bottom_color +
52+
", rotation_angle=" + rotation_angle +
53+
'}';
5354
}
5455
}

library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundFillSolid.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@ public Integer color() {
2121
public boolean equals(Object o) {
2222
if (this == o) return true;
2323
if (o == null || getClass() != o.getClass()) return false;
24+
if (!super.equals(o)) return false;
2425
BackgroundFillSolid that = (BackgroundFillSolid) o;
2526
return Objects.equals(color, that.color);
2627
}
2728

2829
@Override
2930
public int hashCode() {
30-
return Objects.hash(color);
31+
return Objects.hash(super.hashCode(), color);
3132
}
3233

3334
@Override
3435
public String toString() {
3536
return "BackgroundFillSolid{" +
36-
"type='" + type() + '\'' +
37-
", color=" + color +
38-
'}';
37+
"type='" + type() + '\'' +
38+
", color=" + color +
39+
'}';
3940
}
4041
}

library/src/main/java/com/pengrad/telegrambot/model/chatbackground/BackgroundTypeChatTheme.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@ public String themeName() {
2121
public boolean equals(Object o) {
2222
if (this == o) return true;
2323
if (o == null || getClass() != o.getClass()) return false;
24+
if (!super.equals(o)) return false;
2425
BackgroundTypeChatTheme that = (BackgroundTypeChatTheme) o;
2526
return Objects.equals(theme_name, that.theme_name);
2627
}
2728

2829
@Override
2930
public int hashCode() {
30-
return Objects.hash(theme_name);
31+
return Objects.hash(super.hashCode(), theme_name);
3132
}
3233

3334
@Override
3435
public String toString() {
3536
return "BackgroundTypeChatTheme{" +
36-
"type='" + type() + '\'' +
37-
", theme_name=" + theme_name +
38-
'}';
37+
"type='" + type() + '\'' +
38+
", theme_name=" + theme_name +
39+
'}';
3940
}
4041
}

0 commit comments

Comments
 (0)