2222import java .io .Serializable ;
2323import java .lang .reflect .Field ;
2424import org .junit .jupiter .api .Test ;
25- import static org .immutables .check .Checkers .* ;
25+ import static org .immutables .check .Checkers .check ;
2626
2727public class SerialTest {
28- @ Test
29- public void readResolveInterned () throws Exception {
28+ @ Test void hasReadReplace () throws NoSuchMethodException {
29+ // this checks if AllStructural were applied
30+ var writeReplaceMethod = ImmutableStructed .class .getDeclaredMethod ("writeReplace" );
31+ // actually exception will be thrown, this is just to avoid unused variable warning
32+ check (writeReplaceMethod ).notNull ();
33+ }
34+
35+ @ Test void readResolveInterned () throws Exception {
3036 ImmutableSomeSer instance0 = ImmutableSomeSer .builder ().build ();
3137 ImmutableSomeSer instance1 = ImmutableSomeSer .builder ().regular (1 ).build ();
3238 ImmutableSomeSer instance1_2 = ImmutableSomeSer .builder ().regular (1 ).build ();
@@ -40,8 +46,7 @@ public void readResolveInterned() throws Exception {
4046 check (deserialize (serialize (ImmutableOthSer .of ()))).same (ImmutableOthSer .builder ().build ());
4147 }
4248
43- @ Test
44- public void copySerialVersion () throws Exception {
49+ @ Test void copySerialVersion () throws Exception {
4550 for (Field field : ImmutableSomeSer .class .getDeclaredFields ()) {
4651 field .setAccessible (true );
4752 if (field .getName ().equals ("serialVersionUID" ) && field .get (null ).equals (1L )) {
@@ -52,15 +57,13 @@ public void copySerialVersion() throws Exception {
5257 check (false );
5358 }
5459
55- @ Test
56- public void serializeModifiable () throws Exception {
60+ @ Test void serializeModifiable () throws Exception {
5761 ModifiableSomeSer instance = ModifiableSomeSer .create ().setRegular (1 );
5862 // interning
5963 check (deserialize (serialize (instance ))).is (ModifiableSomeSer .create ().setRegular (1 ));
6064 }
6165
62- @ Test
63- public void copySerialVersionModifiable () throws Exception {
66+ @ Test void copySerialVersionModifiable () throws Exception {
6467 for (Field field : ModifiableSomeSer .class .getDeclaredFields ()) {
6568 field .setAccessible (true );
6669 if (field .getName ().equals ("serialVersionUID" ) && field .get (null ).equals (1L )) {
0 commit comments