77import com .pengrad .telegrambot .model .request .InlineKeyboardButton ;
88import com .pengrad .telegrambot .model .request .InlineKeyboardMarkup ;
99import com .pengrad .telegrambot .passport .Credentials ;
10- import nl .jqno .equalsverifier .EqualsVerifier ;
11- import nl .jqno .equalsverifier .Warning ;
10+
1211import org .junit .Before ;
1312import org .junit .Test ;
1413import org .reflections .Reflections ;
1514import org .reflections .scanners .SubTypesScanner ;
1615
16+ import java .lang .reflect .Constructor ;
1717import java .lang .reflect .Field ;
1818import java .lang .reflect .Modifier ;
1919import java .util .Arrays ;
2323import java .util .function .Supplier ;
2424import java .util .stream .Collectors ;
2525
26+ import nl .jqno .equalsverifier .EqualsVerifier ;
27+ import nl .jqno .equalsverifier .Warning ;
28+
2629import static org .junit .Assert .assertTrue ;
2730
2831/**
@@ -85,9 +88,9 @@ public void testEquals() throws IllegalAccessException, InstantiationException,
8588 }
8689
8790 @ Test
88- public void testToString () throws IllegalAccessException , InstantiationException {
91+ public void testToString () throws Exception {
8992 for (Class c : classes ) {
90- Object instance = customInstance .containsKey (c ) ? customInstance .get (c ).get () : c . newInstance ( );
93+ Object instance = customInstance .containsKey (c ) ? customInstance .get (c ).get () : defaultInstance ( c );
9194 String toString = instance .toString ();
9295 for (Field f : c .getDeclaredFields ()) {
9396 if (Modifier .isStatic (f .getModifiers ())) {
@@ -97,4 +100,10 @@ public void testToString() throws IllegalAccessException, InstantiationException
97100 }
98101 }
99102 }
103+
104+ private Object defaultInstance (Class c ) throws Exception {
105+ Constructor constructor = c .getDeclaredConstructor ();
106+ constructor .setAccessible (true );
107+ return constructor .newInstance ();
108+ }
100109}
0 commit comments