@@ -42,7 +42,7 @@ void initialize() {
42
42
43
43
@ Test
44
44
void supportAdd () {
45
- Integer differentVersions [] = {0 , 1 , 2 };
45
+ Integer [] differentVersions = {0 , 1 , 2 };
46
46
Arrays .asList (differentVersions ).forEach (v -> testSupport .add (v + Jvm .version (), v .toString ()));
47
47
Arrays .asList (differentVersions ).forEach (v -> assertThat (testSupport .toString ()).contains ("Version %d" .formatted (v )));
48
48
assertThat (testSupport .toString ()).contains ("%s alternatives" .formatted (TEST_NAME ));
@@ -51,9 +51,7 @@ void supportAdd() {
51
51
@ ParameterizedTest (name = "{index} {1}" )
52
52
@ MethodSource
53
53
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 ));
57
55
}
58
56
59
57
private static Stream <Arguments > supportAddFailsFor () {
@@ -76,11 +74,9 @@ void supportEmptyConfiguration() {
76
74
testSupport .assertFormatterSupported ("0.1" );
77
75
78
76
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 ("" ));
84
80
assertEquals (expected , actual );
85
81
}
86
82
@@ -94,34 +90,26 @@ void supportListsMinimumJvmIfOnlyHigherJvmSupported() {
94
90
assertNull (testSupport .getRecommendedFormatterVersion (), "No formatter version is supported" );
95
91
96
92
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 ();
100
94
assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
101
95
assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion ));
102
96
assertThat (proposal ).contains ("try %s alternatives" .formatted (TEST_NAME ));
103
97
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 ();
109
101
assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
110
102
assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion ));
111
103
assertThat (proposal ).contains ("try %s alternatives" .formatted (TEST_NAME ));
112
104
}
113
105
114
106
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 ();
118
108
assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion + 1 ));
119
109
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 ();
125
113
assertThat (proposal ).contains ("%s %s requires JVM %d+" .formatted (TEST_NAME , fmtVersion , higherJvmVersion + 1 ));
126
114
}
127
115
}
@@ -135,11 +123,9 @@ void supportProposesFormatterUpgrade() {
135
123
for (String fmtVersion : Arrays .asList ("0" , "1" , "1.9" , "1.9-SNAPSHOT" )) {
136
124
testSupport .assertFormatterSupported (fmtVersion );
137
125
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 ();
143
129
assertThat (proposal .replace ("\r " , "" )).isEqualTo ("My Test Formatter " + fmtVersion + " is currently being used, but outdated.\n " +
144
130
"My Test Formatter 2 is the recommended version, which may have fixed this problem.\n " +
145
131
"My Test Formatter 2 requires JVM " + requiredJvm + "+." );
@@ -153,11 +139,9 @@ void supportProposesJvmUpgrade() {
153
139
testSupport .add (higherJvm , "2" );
154
140
testSupport .add (higherJvm + 1 , "3" );
155
141
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 ();
161
145
assertThat (proposal ).contains (String .format ("on JVM %d" , Jvm .version ()));
162
146
assertThat (proposal ).contains ("limits you to %s %s" .formatted (TEST_NAME , "1" ));
163
147
assertThat (proposal ).contains ("upgrade your JVM to %d+" .formatted (higherJvm ));
@@ -172,11 +156,9 @@ void supportAllowsExperimentalVersions() {
172
156
testSupport .assertFormatterSupported (fmtVersion );
173
157
174
158
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 ("" ));
180
162
assertEquals (testException , exception );
181
163
}
182
164
}
0 commit comments