@@ -1181,32 +1181,37 @@ class FirstTwoChars extends NestedObfuscatorTest {
11811181 @ Test
11821182 @ DisplayName ("negative keepAtStart" )
11831183 void testNegativeKeepAtStart () {
1184- assertThrows (IllegalArgumentException .class , () -> portion ().keepAtStart (-1 ));
1184+ PortionBuilder builder = portion ();
1185+ assertThrows (IllegalArgumentException .class , () -> builder .keepAtStart (-1 ));
11851186 }
11861187
11871188 @ Test
11881189 @ DisplayName ("negative keepAtEnd" )
11891190 void testNegativeKeepAtEnd () {
1190- assertThrows (IllegalArgumentException .class , () -> portion ().keepAtEnd (-1 ));
1191+ PortionBuilder builder = portion ();
1192+ assertThrows (IllegalArgumentException .class , () -> builder .keepAtEnd (-1 ));
11911193 }
11921194
11931195 @ Test
11941196 @ DisplayName ("negative atLeastFomStart" )
11951197 void testNegativeAtLeastFromStart () {
1196- assertThrows (IllegalArgumentException .class , () -> portion ().atLeastFromStart (-1 ));
1198+ PortionBuilder builder = portion ();
1199+ assertThrows (IllegalArgumentException .class , () -> builder .atLeastFromStart (-1 ));
11971200 }
11981201
11991202 @ Test
12001203 @ DisplayName ("negative AtLeastFromEnd" )
12011204 void testNegativeAtLeastFromEnd () {
1202- assertThrows (IllegalArgumentException .class , () -> portion ().atLeastFromEnd (-1 ));
1205+ PortionBuilder builder = portion ();
1206+ assertThrows (IllegalArgumentException .class , () -> builder .atLeastFromEnd (-1 ));
12031207 }
12041208
12051209 @ Test
12061210 @ DisplayName ("fixedTotalLength < keepAtStart + keepAtEnd" )
12071211 void testFixedTotalLengthSmallerThanKeepAtStartPlusKeepAtEnd () {
12081212 assertDoesNotThrow (() -> portion ().keepAtStart (1 ).keepAtEnd (1 ).withFixedTotalLength (2 ).build ());
1209- assertThrows (IllegalStateException .class , () -> portion ().keepAtStart (1 ).keepAtEnd (1 ).withFixedTotalLength (1 ).build ());
1213+ PortionBuilder builder = portion ().keepAtStart (1 ).keepAtEnd (1 ).withFixedTotalLength (1 );
1214+ assertThrows (IllegalStateException .class , () -> builder .build ());
12101215 }
12111216
12121217 @ Test
@@ -1456,23 +1461,24 @@ class WithFixedLength extends NestedObfuscatorTest {
14561461 @ Test
14571462 @ DisplayName ("invalid first prefix length" )
14581463 void testInvalidFirstPrefixLength () {
1459- IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> none ().untilLength (0 ));
1464+ Obfuscator obfuscator = none ();
1465+ IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> obfuscator .untilLength (0 ));
14601466 assertEquals ("0 <= 0" , exception .getMessage ());
14611467 }
14621468
14631469 @ Test
14641470 @ DisplayName ("invalid second prefix length" )
14651471 void testInvalidSecondPrefixLength () {
1466- IllegalArgumentException exception = assertThrows ( IllegalArgumentException . class ,
1467- () -> none (). untilLength ( 1 ). then ( all ()) .untilLength (1 ));
1472+ Obfuscator obfuscator = none (). untilLength ( 1 ). then ( all ());
1473+ IllegalArgumentException exception = assertThrows ( IllegalArgumentException . class , () -> obfuscator .untilLength (1 ));
14681474 assertEquals ("1 <= 1" , exception .getMessage ());
14691475 }
14701476
14711477 @ Test
14721478 @ DisplayName ("invalid third prefix length" )
14731479 void testInvalidThirdPrefixLength () {
1474- IllegalArgumentException exception = assertThrows ( IllegalArgumentException . class ,
1475- () -> none (). untilLength ( 1 ). then ( all ()). untilLength ( 2 ). then ( none ()) .untilLength (2 ));
1480+ Obfuscator obfuscator = none (). untilLength ( 1 ). then ( all ()). untilLength ( 2 ). then ( none ());
1481+ IllegalArgumentException exception = assertThrows ( IllegalArgumentException . class , () -> obfuscator .untilLength (2 ));
14761482 assertEquals ("2 <= 2" , exception .getMessage ());
14771483 }
14781484
@@ -1757,7 +1763,7 @@ void testWriteInt(@SuppressWarnings("unused") String appendableType, Supplier<Ap
17571763 IOException exception = assertThrows (IOException .class , () -> {
17581764 @ SuppressWarnings ("resource" )
17591765 Writer w = obfuscator .streamTo (destination );
1760- w . close ( );
1766+ assertDoesNotThrow ( w :: close );
17611767 w .write ('x' );
17621768 });
17631769 assertClosedException (exception );
@@ -1780,7 +1786,7 @@ void testWriteCharArray(@SuppressWarnings("unused") String appendableType, Suppl
17801786 IOException exception = assertThrows (IOException .class , () -> {
17811787 @ SuppressWarnings ("resource" )
17821788 Writer w = obfuscator .streamTo (destination );
1783- w . close ( );
1789+ assertDoesNotThrow ( w :: close );
17841790 w .write (input .toCharArray ());
17851791 });
17861792 assertClosedException (exception );
@@ -1814,7 +1820,7 @@ void testWriteCharArrayRange(@SuppressWarnings("unused") String appendableType,
18141820 IOException exception = assertThrows (IOException .class , () -> {
18151821 @ SuppressWarnings ("resource" )
18161822 Writer w = obfuscator .streamTo (destination );
1817- w . close ( );
1823+ assertDoesNotThrow ( w :: close );
18181824 w .write (input .toCharArray (), 0 , 1 );
18191825 });
18201826 assertClosedException (exception );
@@ -1837,7 +1843,7 @@ void testWriteString(@SuppressWarnings("unused") String appendableType, Supplier
18371843 IOException exception = assertThrows (IOException .class , () -> {
18381844 @ SuppressWarnings ("resource" )
18391845 Writer w = obfuscator .streamTo (destination );
1840- w . close ( );
1846+ assertDoesNotThrow ( w :: close );
18411847 w .write (input );
18421848 });
18431849 assertClosedException (exception );
@@ -1865,7 +1871,7 @@ void testWriteStringRange(@SuppressWarnings("unused") String appendableType, Sup
18651871 IOException exception = assertThrows (IOException .class , () -> {
18661872 @ SuppressWarnings ("resource" )
18671873 Writer w = obfuscator .streamTo (destination );
1868- w . close ( );
1874+ assertDoesNotThrow ( w :: close );
18691875 w .write (input , 0 , 1 );
18701876 });
18711877 assertClosedException (exception );
@@ -1888,7 +1894,7 @@ void testAppendCharSequence(@SuppressWarnings("unused") String appendableType, S
18881894 IOException exception = assertThrows (IOException .class , () -> {
18891895 @ SuppressWarnings ("resource" )
18901896 Writer w = obfuscator .streamTo (destination );
1891- w . close ( );
1897+ assertDoesNotThrow ( w :: close );
18921898 w .append (input );
18931899 });
18941900 assertClosedException (exception );
@@ -1921,7 +1927,7 @@ void testAppendCharSequenceRange(@SuppressWarnings("unused") String appendableTy
19211927 IOException exception = assertThrows (IOException .class , () -> {
19221928 @ SuppressWarnings ("resource" )
19231929 Writer w = obfuscator .streamTo (destination );
1924- w . close ( );
1930+ assertDoesNotThrow ( w :: close );
19251931 w .append (input , 0 , 1 );
19261932 });
19271933 assertClosedException (exception );
@@ -1946,7 +1952,7 @@ void testAppendChar(@SuppressWarnings("unused") String appendableType, Supplier<
19461952 IOException exception = assertThrows (IOException .class , () -> {
19471953 @ SuppressWarnings ("resource" )
19481954 Writer w = obfuscator .streamTo (destination );
1949- w . close ( );
1955+ assertDoesNotThrow ( w :: close );
19501956 w .append ('x' );
19511957 });
19521958 assertClosedException (exception );
@@ -1966,7 +1972,7 @@ void testFlush(@SuppressWarnings("unused") String appendableType, Supplier<Appen
19661972 IOException exception = assertThrows (IOException .class , () -> {
19671973 @ SuppressWarnings ("resource" )
19681974 Writer w = obfuscator .streamTo (destination );
1969- w . close ( );
1975+ assertDoesNotThrow ( w :: close );
19701976 w .flush ();
19711977 });
19721978 assertClosedException (exception );
0 commit comments