Skip to content

Commit b65ed48

Browse files
committed
Fix equals ModelTest
1 parent 9fa6b32 commit b65ed48

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

library/src/main/java/com/pengrad/telegrambot/model/VoiceChatStarted.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@
88
*/
99
public class VoiceChatStarted implements Serializable {
1010
private final static long serialVersionUID = 0L;
11+
12+
@Override
13+
public boolean equals(Object o) {
14+
if (this == o) return true;
15+
return o != null && getClass() == o.getClass();
16+
}
17+
18+
@Override
19+
public int hashCode() {
20+
return 1;
21+
}
1122
}

library/src/test/java/com/pengrad/telegrambot/ModelTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup;
66
import com.pengrad.telegrambot.passport.Credentials;
77
import nl.jqno.equalsverifier.EqualsVerifier;
8+
import nl.jqno.equalsverifier.EqualsVerifierApi;
89
import nl.jqno.equalsverifier.Warning;
910
import org.junit.Before;
1011
import org.junit.Test;
@@ -70,14 +71,19 @@ public void testEquals() throws ReflectiveOperationException {
7071
f.set(update, 1);
7172

7273
for (Class<?> c : classes) {
73-
EqualsVerifier.forClass(c)
74+
EqualsVerifierApi<?> verifierApi = EqualsVerifier.forClass(c)
7475
.usingGetClass()
7576
.withPrefabValues(Update.class, Update.class.getDeclaredConstructor().newInstance(), update)
7677
.withPrefabValues(Message.class, Message.class.getDeclaredConstructor().newInstance(), message)
7778
.withPrefabValues(CallbackQuery.class, CallbackQuery.class.getDeclaredConstructor().newInstance(), callbackQuery)
7879
.suppress(Warning.STRICT_HASHCODE)
79-
.suppress(Warning.NONFINAL_FIELDS)
80-
.verify();
80+
.suppress(Warning.NONFINAL_FIELDS);
81+
82+
if (c == Message.class) {
83+
verifierApi.withIgnoredFields("voice_chat_started");
84+
}
85+
86+
verifierApi.verify();
8187
}
8288
}
8389

0 commit comments

Comments
 (0)