@@ -42,7 +42,7 @@ void initialize() {
4242
4343 @ Test
4444 void supportAdd () {
45- Integer [] differentVersions = {0 , 1 , 2 };
45+ Integer differentVersions [] = {0 , 1 , 2 };
4646 Arrays .asList (differentVersions ).forEach (v -> testSupport .add (v + Jvm .version (), v .toString ()));
4747 Arrays .asList (differentVersions ).forEach (v -> assertThat (testSupport .toString ()).contains ("Version %d" .formatted (v )));
4848 assertThat (testSupport .toString ()).contains ("%s alternatives" .formatted (TEST_NAME ));
@@ -51,7 +51,9 @@ void supportAdd() {
5151 @ ParameterizedTest (name = "{index} {1}" )
5252 @ MethodSource
5353 void supportAddFailsFor (Consumer <Jvm .Support <String >> configuration , String nameNotUsed ) {
54- assertThrows (IllegalArgumentException .class , () -> configuration .accept (testSupport ));
54+ assertThrows (IllegalArgumentException .class , () -> {
55+ configuration .accept (testSupport );
56+ });
5557 }
5658
5759 private static Stream <Arguments > supportAddFailsFor () {
@@ -74,9 +76,11 @@ void supportEmptyConfiguration() {
7476 testSupport .assertFormatterSupported ("0.1" );
7577
7678 Exception expected = new Exception ("Some test exception" );
77- Exception actual = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError ("0.0" , unused -> {
78- throw expected ;
79- }).apply ("" ));
79+ Exception actual = assertThrows (Exception .class , () -> {
80+ testSupport .suggestLaterVersionOnError ("0.0" , unused -> {
81+ throw expected ;
82+ }).apply ("" );
83+ });
8084 assertEquals (expected , actual );
8185 }
8286
@@ -90,26 +94,34 @@ void supportListsMinimumJvmIfOnlyHigherJvmSupported() {
9094 assertNull (testSupport .getRecommendedFormatterVersion (), "No formatter version is supported" );
9195
9296 for (String fmtVersion : Arrays .asList ("1.2" , "1.2.3" , "1.2-SNAPSHOT" , "1.2.3-SNAPSHOT" )) {
93- String proposal = assertThrows (Lint .ShortcutException .class , () -> testSupport .assertFormatterSupported (fmtVersion )).getLints ().get (0 ).getDetail ();
97+ String proposal = assertThrows (Lint .ShortcutException .class , () -> {
98+ testSupport .assertFormatterSupported (fmtVersion );
99+ }).getLints ().get (0 ).getDetail ();
94100 assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
95101 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion ));
96102 assertThat (proposal ).contains ("try %s alternatives" .formatted (TEST_NAME ));
97103
98- proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
99- throw testException ;
100- }).apply ("" )).getMessage ();
104+ proposal = assertThrows (Exception .class , () -> {
105+ testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
106+ throw testException ;
107+ }).apply ("" );
108+ }).getMessage ();
101109 assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
102110 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion ));
103111 assertThat (proposal ).contains ("try %s alternatives" .formatted (TEST_NAME ));
104112 }
105113
106114 for (String fmtVersion : Arrays .asList ("1.2.4" , "2" , "1.2.5-SNAPSHOT" )) {
107- String proposal = assertThrows (Lint .ShortcutException .class , () -> testSupport .assertFormatterSupported (fmtVersion )).getLints ().get (0 ).getDetail ();
115+ String proposal = assertThrows (Lint .ShortcutException .class , () -> {
116+ testSupport .assertFormatterSupported (fmtVersion );
117+ }).getLints ().get (0 ).getDetail ();
108118 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion + 1 ));
109119
110- proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
111- throw testException ;
112- }).apply ("" )).getMessage ();
120+ proposal = assertThrows (Exception .class , () -> {
121+ testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
122+ throw testException ;
123+ }).apply ("" );
124+ }).getMessage ();
113125 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion + 1 ));
114126 }
115127 }
@@ -123,12 +135,14 @@ void supportProposesFormatterUpgrade() {
123135 for (String fmtVersion : Arrays .asList ("0" , "1" , "1.9" , "1.9-SNAPSHOT" )) {
124136 testSupport .assertFormatterSupported (fmtVersion );
125137
126- String proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
127- throw new Exception ("Some test exception" );
128- }).apply ("" )).getMessage ();
129- assertThat (proposal .replace ("\r " , "" )).isEqualTo ("My Test Formatter " + fmtVersion + " is currently being used, but outdated.\n "
130- + "My Test Formatter 2 is the recommended version, which may have fixed this problem.\n "
131- + "My Test Formatter 2 requires JVM " + requiredJvm + "+." );
138+ String proposal = assertThrows (Exception .class , () -> {
139+ testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
140+ throw new Exception ("Some test exception" );
141+ }).apply ("" );
142+ }).getMessage ();
143+ assertThat (proposal .replace ("\r " , "" )).isEqualTo ("My Test Formatter " + fmtVersion + " is currently being used, but outdated.\n " +
144+ "My Test Formatter 2 is the recommended version, which may have fixed this problem.\n " +
145+ "My Test Formatter 2 requires JVM " + requiredJvm + "+." );
132146 }
133147 }
134148
@@ -139,9 +153,11 @@ void supportProposesJvmUpgrade() {
139153 testSupport .add (higherJvm , "2" );
140154 testSupport .add (higherJvm + 1 , "3" );
141155 for (String fmtVersion : Arrays .asList ("1" , "1.0" )) {
142- String proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
143- throw new Exception ("Some test exception" );
144- }).apply ("" )).getMessage ();
156+ String proposal = assertThrows (Exception .class , () -> {
157+ testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
158+ throw new Exception ("Some test exception" );
159+ }).apply ("" );
160+ }).getMessage ();
145161 assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
146162 assertThat (proposal ).contains ("limits you to %s %s" .formatted (TEST_NAME , "1" ));
147163 assertThat (proposal ).contains ("upgrade your JVM to %d+" .formatted (higherJvm ));
@@ -156,9 +172,11 @@ void supportAllowsExperimentalVersions() {
156172 testSupport .assertFormatterSupported (fmtVersion );
157173
158174 Exception testException = new Exception ("Some test exception" );
159- Exception exception = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
160- throw testException ;
161- }).apply ("" ));
175+ Exception exception = assertThrows (Exception .class , () -> {
176+ testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
177+ throw testException ;
178+ }).apply ("" );
179+ });
162180 assertEquals (testException , exception );
163181 }
164182 }
0 commit comments