@@ -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,9 +51,7 @@ void supportAdd() {
5151 @ ParameterizedTest (name = "{index} {1}" )
5252 @ MethodSource
5353 void supportAddFailsFor (Consumer <Jvm .Support <String >> configuration , String nameNotUsed ) {
54- assertThrows (IllegalArgumentException .class , () -> {
55- configuration .accept (testSupport );
56- });
54+ assertThrows (IllegalArgumentException .class , () -> configuration .accept (testSupport ));
5755 }
5856
5957 private static Stream <Arguments > supportAddFailsFor () {
@@ -76,11 +74,9 @@ void supportEmptyConfiguration() {
7674 testSupport .assertFormatterSupported ("0.1" );
7775
7876 Exception expected = new Exception ("Some test exception" );
79- Exception actual = assertThrows (Exception .class , () -> {
80- testSupport .suggestLaterVersionOnError ("0.0" , unused -> {
81- throw expected ;
82- }).apply ("" );
83- });
77+ Exception actual = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError ("0.0" , unused -> {
78+ throw expected ;
79+ }).apply ("" ));
8480 assertEquals (expected , actual );
8581 }
8682
@@ -94,34 +90,26 @@ void supportListsMinimumJvmIfOnlyHigherJvmSupported() {
9490 assertNull (testSupport .getRecommendedFormatterVersion (), "No formatter version is supported" );
9591
9692 for (String fmtVersion : Arrays .asList ("1.2" , "1.2.3" , "1.2-SNAPSHOT" , "1.2.3-SNAPSHOT" )) {
97- String proposal = assertThrows (Lint .ShortcutException .class , () -> {
98- testSupport .assertFormatterSupported (fmtVersion );
99- }).getLints ().get (0 ).getDetail ();
93+ String proposal = assertThrows (Lint .ShortcutException .class , () -> testSupport .assertFormatterSupported (fmtVersion )).getLints ().get (0 ).getDetail ();
10094 assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
10195 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion ));
10296 assertThat (proposal ).contains ("try %s alternatives" .formatted (TEST_NAME ));
10397
104- proposal = assertThrows (Exception .class , () -> {
105- testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
106- throw testException ;
107- }).apply ("" );
108- }).getMessage ();
98+ proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
99+ throw testException ;
100+ }).apply ("" )).getMessage ();
109101 assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
110102 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion ));
111103 assertThat (proposal ).contains ("try %s alternatives" .formatted (TEST_NAME ));
112104 }
113105
114106 for (String fmtVersion : Arrays .asList ("1.2.4" , "2" , "1.2.5-SNAPSHOT" )) {
115- String proposal = assertThrows (Lint .ShortcutException .class , () -> {
116- testSupport .assertFormatterSupported (fmtVersion );
117- }).getLints ().get (0 ).getDetail ();
107+ String proposal = assertThrows (Lint .ShortcutException .class , () -> testSupport .assertFormatterSupported (fmtVersion )).getLints ().get (0 ).getDetail ();
118108 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion + 1 ));
119109
120- proposal = assertThrows (Exception .class , () -> {
121- testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
122- throw testException ;
123- }).apply ("" );
124- }).getMessage ();
110+ proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
111+ throw testException ;
112+ }).apply ("" )).getMessage ();
125113 assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion + 1 ));
126114 }
127115 }
@@ -135,11 +123,9 @@ void supportProposesFormatterUpgrade() {
135123 for (String fmtVersion : Arrays .asList ("0" , "1" , "1.9" , "1.9-SNAPSHOT" )) {
136124 testSupport .assertFormatterSupported (fmtVersion );
137125
138- String proposal = assertThrows (Exception .class , () -> {
139- testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
140- throw new Exception ("Some test exception" );
141- }).apply ("" );
142- }).getMessage ();
126+ String proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
127+ throw new Exception ("Some test exception" );
128+ }).apply ("" )).getMessage ();
143129 assertThat (proposal .replace ("\r " , "" )).isEqualTo ("My Test Formatter " + fmtVersion + " is currently being used, but outdated.\n " +
144130 "My Test Formatter 2 is the recommended version, which may have fixed this problem.\n " +
145131 "My Test Formatter 2 requires JVM " + requiredJvm + "+." );
@@ -153,11 +139,9 @@ void supportProposesJvmUpgrade() {
153139 testSupport .add (higherJvm , "2" );
154140 testSupport .add (higherJvm + 1 , "3" );
155141 for (String fmtVersion : Arrays .asList ("1" , "1.0" )) {
156- String proposal = assertThrows (Exception .class , () -> {
157- testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
158- throw new Exception ("Some test exception" );
159- }).apply ("" );
160- }).getMessage ();
142+ String proposal = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
143+ throw new Exception ("Some test exception" );
144+ }).apply ("" )).getMessage ();
161145 assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
162146 assertThat (proposal ).contains ("limits you to %s %s" .formatted (TEST_NAME , "1" ));
163147 assertThat (proposal ).contains ("upgrade your JVM to %d+" .formatted (higherJvm ));
@@ -172,11 +156,9 @@ void supportAllowsExperimentalVersions() {
172156 testSupport .assertFormatterSupported (fmtVersion );
173157
174158 Exception testException = new Exception ("Some test exception" );
175- Exception exception = assertThrows (Exception .class , () -> {
176- testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
177- throw testException ;
178- }).apply ("" );
179- });
159+ Exception exception = assertThrows (Exception .class , () -> testSupport .suggestLaterVersionOnError (fmtVersion , unused -> {
160+ throw testException ;
161+ }).apply ("" ));
180162 assertEquals (testException , exception );
181163 }
182164 }
0 commit comments