File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
main/java/com/pengrad/telegrambot/response
test/java/com/pengrad/telegrambot Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,7 @@ package com.pengrad.telegrambot.response
22
33import com.pengrad.telegrambot.model.chatboost.ChatBoost
44
5- data class UserChatBoostsResponse @JvmOverloads constructor(
6- private val result : ChatBoosts = ChatBoosts (emptyList())
7- ) : BaseResponse() {
5+ data class UserChatBoostsResponse (private val result : ChatBoosts = ChatBoosts (emptyList())) : BaseResponse() {
86 data class ChatBoosts (val boosts : List <ChatBoost >)
97
108 fun boosts (): Array <ChatBoost > {
Original file line number Diff line number Diff line change 99import java .lang .reflect .Field ;
1010import java .lang .reflect .InvocationTargetException ;
1111import java .lang .reflect .Modifier ;
12+ import java .util .Arrays ;
13+ import java .util .Optional ;
1214import java .util .Set ;
1315
1416import static org .junit .Assert .assertTrue ;
@@ -31,9 +33,10 @@ public void setClasses() {
3133 @ Test
3234 public void testToString () throws IllegalAccessException , InstantiationException , InvocationTargetException {
3335 for (Class <? extends BaseResponse > c : classes ) {
34- Constructor <?> constructor = c .getDeclaredConstructors ()[0 ];
35- constructor .setAccessible (true );
36- String toString = constructor .newInstance ().toString ();
36+ Optional <Constructor <?>> constructor = Arrays .stream (c .getDeclaredConstructors ()).filter (dc -> dc .getParameterCount () == 0 ).findFirst ();
37+ assertTrue ("No default constructor in " + c .getSimpleName (), constructor .isPresent ());
38+ constructor .get ().setAccessible (true );
39+ String toString = constructor .get ().newInstance ().toString ();
3740 for (Field f : c .getDeclaredFields ()) {
3841 if (Modifier .isStatic (f .getModifiers ())) {
3942 continue ;
You can’t perform that action at this time.
0 commit comments