View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2026 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  ///////////////////////////////////////////////////////////////////////////////////////////////
19  
20  package com.puppycrawl.tools.checkstyle.checks.blocks;
21  
22  import static com.google.common.truth.Truth.assertWithMessage;
23  import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_ALONE;
24  import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_BREAK_BEFORE;
25  import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_SAME;
26  import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.getExpectedThrowable;
27  
28  import org.junit.jupiter.api.Test;
29  
30  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
31  import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
32  import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
33  
34  public class RightCurlyCheckTest extends AbstractModuleTestSupport {
35  
36      @Override
37      public String getPackageLocation() {
38          return "com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly";
39      }
40  
41      /* Additional test for jacoco, since valueOf()
42       * is generated by javac and jacoco reports that
43       * valueOf() is uncovered.
44       */
45      @Test
46      public void testRightCurlyOptionValueOf() {
47          final RightCurlyOption option = RightCurlyOption.valueOf("ALONE");
48          assertWithMessage("Invalid valueOf result")
49              .that(option)
50              .isEqualTo(RightCurlyOption.ALONE);
51      }
52  
53      @Test
54      public void testDefault() throws Exception {
55          final String[] expected = {
56              "25:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
57              "28:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
58              "40:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
59              "44:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
60              "93:27: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 27),
61          };
62          verifyWithInlineConfigParser(
63                  getPath("InputRightCurlyLeftTestDefault.java"), expected);
64      }
65  
66      @Test
67      public void testSame() throws Exception {
68          final String[] expected = {
69              "26:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
70              "29:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
71              "41:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
72              "45:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
73              "87:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
74              "94:27: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 27),
75              "189:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
76              "190:41: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 41),
77          };
78          verifyWithInlineConfigParser(
79                  getPath("InputRightCurlyLeftTestSame.java"), expected);
80      }
81  
82      @Test
83      public void testSameOmitOneLiners() throws Exception {
84          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
85          verifyWithInlineConfigParser(
86                  getPath("InputRightCurlyTestSameOmitOneLiners.java"), expected);
87      }
88  
89      @Test
90      public void testSameDoesNotComplainForNonMultilineConstructs() throws Exception {
91          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
92          verifyWithInlineConfigParser(
93                  getPath("InputRightCurlyTestSame.java"), expected);
94      }
95  
96      @Test
97      public void testAlone() throws Exception {
98          final String[] expected = {
99              "57:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
100             "94:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
101             "98:41: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 41),
102             "174:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
103             "176:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
104             "178:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
105             "179:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
106             "184:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
107             "189:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
108             "190:53: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 53),
109         };
110         verifyWithInlineConfigParser(
111                 getPath("InputRightCurlyLeftTestAlone.java"), expected);
112     }
113 
114     @Test
115     public void testNewLine() throws Exception {
116         final String[] expected = {
117             "86:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
118             "111:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
119             "111:6: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 6),
120             "125:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
121             "125:6: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 6),
122             "142:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
123             "142:6: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 6),
124             "153:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
125             "158:41: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 41),
126             "161:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
127             "163:39: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 39),
128             "206:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
129             "211:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
130             "214:39: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 39),
131             "220:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
132             "220:10: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 10),
133         };
134         verifyWithInlineConfigParser(
135                 getPath("InputRightCurlyLeftTestNewLine.java"), expected);
136     }
137 
138     @Test
139     public void testShouldStartLine2() throws Exception {
140         final String[] expected = {
141             "86:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
142             "111:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
143             "111:6: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 6),
144             "125:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
145             "125:6: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 6),
146             "142:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
147             "142:6: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 6),
148             "206:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
149             "211:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
150             "220:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
151             "220:10: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 10),
152         };
153         verifyWithInlineConfigParser(
154                 getPath("InputRightCurlyLeftTestShouldStartLine2.java"), expected);
155     }
156 
157     @Test
158     public void testForceLineBreakBefore() throws Exception {
159         final String[] expected = {
160             "38:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 43),
161             "41:17: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 17),
162             "44:71: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 71),
163             "46:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
164             "50:25: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 25),
165         };
166         verifyWithInlineConfigParser(
167                 getPath("InputRightCurlyTestForceLineBreakBefore.java"), expected);
168     }
169 
170     @Test
171     public void testForceLineBreakBefore2() throws Exception {
172         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
173         verifyWithInlineConfigParser(
174                 getPath("InputRightCurlyTestForceLineBreakBefore2.java"), expected);
175     }
176 
177     @Test
178     public void testNullPointerException() throws Exception {
179         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
180         verifyWithInlineConfigParser(
181                 getPath("InputRightCurlyTestNullPointerException.java"), expected);
182     }
183 
184     @Test
185     public void testWithAnnotations() throws Exception {
186         final String[] expected = {
187             "18:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
188             "21:65: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 65),
189             "32:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
190             "36:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
191             "39:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
192             "42:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
193             "48:73: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 73),
194             "50:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
195             "55:66: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 66),
196             "58:96: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 96),
197             "61:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
198             "64:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
199             "67:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
200             "71:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
201             "72:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
202             "78:62: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 62),
203             "87:28: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 28),
204             "89:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21),
205             "91:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
206             "93:14: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 14),
207             "104:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
208             "105:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
209             "114:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
210             "114:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
211             "121:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
212             "121:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
213             "128:40: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 40),
214             "128:88: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 88),
215             "133:18: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 18),
216             "137:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
217             "140:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
218             "142:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
219             "146:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
220             "155:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
221             "157:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
222             "157:33: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 33),
223             "172:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
224             "173:58: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 58),
225             "173:74: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 74),
226             "177:58: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 58),
227             "179:58: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 58),
228             "179:73: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 73),
229             "187:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
230             "193:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
231 
232             "207:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
233             "214:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
234             "214:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
235             "225:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
236             "225:10: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 10),
237             "232:54: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 54),
238             "232:55: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 55),
239             "238:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
240             "238:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
241             "238:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
242             "246:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
243 
244             "254:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
245             "258:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
246             "261:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
247             "263:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
248             "266:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
249             "269:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
250             "272:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
251             "275:39: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 39),
252             "277:56: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 56),
253             "280:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
254             "290:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
255             "292:40: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 40),
256             "296:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
257             "299:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
258             "301:61: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 61),
259         };
260         verifyWithInlineConfigParser(
261                 getPath("InputRightCurlyTestWithAnnotations.java"), expected);
262     }
263 
264     @Test
265     public void testAloneOrSingleLine() throws Exception {
266         final String[] expected = {
267             "70:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
268             "84:42: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 42),
269             "87:18: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 18),
270             "95:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
271             "99:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
272             "107:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
273             "109:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
274             "120:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
275             "124:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
276             "124:93: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 93),
277             "126:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
278             "130:64: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 64),
279             "130:80: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 80),
280             "136:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
281             "142:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
282             "155:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
283             "161:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
284             "161:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
285             "173:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
286             "173:10: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 10),
287             "180:54: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 54),
288             "180:55: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 55),
289             "186:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
290             "186:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
291             "186:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
292             "202:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
293             "208:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
294             "211:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
295             "214:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
296             "220:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
297             "222:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
298             "224:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
299             "225:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
300             "230:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
301             "235:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
302             "236:39: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 39),
303             "244:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
304             "256:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
305             "262:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
306             "262:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
307         };
308         verifyWithInlineConfigParser(
309                 getPath("InputRightCurlyTestAloneOrSingleline.java"), expected);
310     }
311 
312     @Test
313     public void testAloneOrSingleLineTryCatchBlock() throws Exception {
314         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
315         verifyWithInlineConfigParser(
316                 getPath("InputRightCurlyTestAloneOrSinglelineTryCatchBlock.java"), expected);
317     }
318 
319     @Test
320     public void testCatchWithoutFinally() throws Exception {
321         final String[] expected = {
322             "19:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
323         };
324         verifyWithInlineConfigParser(
325                 getPath("InputRightCurlyTestWithoutFinally.java"), expected);
326     }
327 
328     @Test
329     public void testSingleLineClass() throws Exception {
330         final String[] expected = {
331             "29:56: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 56),
332         };
333         verifyWithInlineConfigParser(
334                 getPath("InputRightCurlyTestSingleLineClass.java"), expected);
335     }
336 
337     @Test
338     public void testInvalidOption() {
339 
340         final CheckstyleException exc = getExpectedThrowable(CheckstyleException.class,
341                 () -> {
342                     final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
343                     verifyWithInlineConfigParser(
344                             getPath("InputRightCurlyTestInvalidOption.java"), expected);
345                 });
346         assertWithMessage("Invalid exception message")
347             .that(exc.getMessage())
348             .isEqualTo("cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
349                 + "cannot initialize module com.puppycrawl.tools.checkstyle.checks."
350                 + "blocks.RightCurlyCheck");
351     }
352 
353     @Test
354     public void testRightCurlySameAndLiteralDo() throws Exception {
355         final String[] expected = {
356             "70:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
357             "75:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
358             "91:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
359         };
360         verifyWithInlineConfigParser(
361                 getPath("InputRightCurlyTestSameAndLiteralDo.java"), expected);
362     }
363 
364     @Test
365     public void testTryWithResourceSame() throws Exception {
366         final String[] expected = {
367             "19:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
368             "33:67: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 67),
369             "44:15: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 15),
370             "46:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
371         };
372         verifyWithInlineConfigParser(
373                 getPath("InputRightCurlyTestTryWithResourceSame.java"), expected);
374     }
375 
376     @Test
377     public void testTryWithResourceAlone() throws Exception {
378         final String[] expected = {
379             "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
380             "33:67: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 67),
381             "34:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
382             "37:64: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 64),
383             "37:92: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 92),
384             "47:67: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 67),
385             "49:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
386             "51:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
387         };
388         verifyWithInlineConfigParser(
389                 getPath("InputRightCurlyTestTryWithResourceAlone.java"), expected);
390     }
391 
392     @Test
393     public void testTryWithResourceAloneSingle() throws Exception {
394         final String[] expected = {
395             "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
396             "43:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
397             "45:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
398         };
399         verifyWithInlineConfigParser(
400                 getPath("InputRightCurlyTryWithResourceAloneSingle.java"), expected);
401     }
402 
403     @Test
404     public void testBracePolicyAloneAndSinglelineIfBlocks() throws Exception {
405         final String[] expected = {
406             "13:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32),
407             "15:45: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 45),
408             "15:47: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 47),
409         };
410         verifyWithInlineConfigParser(
411                 getPath("InputRightCurlyTestSinglelineIfBlocks.java"), expected);
412     }
413 
414     @Test
415     public void testRightCurlyIsAloneLambda() throws Exception {
416         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
417         verifyWithInlineConfigParser(
418                 getPath("InputRightCurlyTestIsAloneLambda.java"), expected);
419     }
420 
421     @Test
422     public void testRightCurlyIsAloneOrSinglelineLambda() throws Exception {
423         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
424         verifyWithInlineConfigParser(
425                 getPath("InputRightCurlyTestIsAloneOrSinglelineLambda.java"), expected);
426     }
427 
428     @Test
429     public void testRightCurlyIsSameLambda() throws Exception {
430         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
431         verifyWithInlineConfigParser(
432                 getPath("InputRightCurlyTestIsSameLambda.java"), expected);
433     }
434 
435     @Test
436     public void testOptionAlone() throws Exception {
437         final String[] expected = {
438             "16:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
439             "17:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21),
440             "21:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
441             "30:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
442             "47:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
443             "51:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
444             "54:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
445             "56:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
446             "58:17: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 17),
447             "60:53: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 53),
448             "62:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
449             "62:52: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 52),
450             "78:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
451             "78:11: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 11),
452             "85:39: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 39),
453             "87:56: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 56),
454             "90:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
455             "102:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
456             "105:39: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 39),
457             "111:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
458             "111:10: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 10),
459         };
460         verifyWithInlineConfigParser(
461                 getPath("InputRightCurlyTestOptionAlone.java"),
462                 expected);
463     }
464 
465     @Test
466     public void testOptionAloneOrSingleLine() throws Exception {
467         final String[] expected = {
468             "21:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
469             "30:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
470             "38:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
471             "47:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
472             "51:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
473             "72:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
474             "77:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
475             "86:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
476             "86:10: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 10),
477         };
478         verifyWithInlineConfigParser(
479                 getPath(
480                 "InputRightCurlyTestOptionAloneOrSingleLine.java"), expected);
481     }
482 
483     @Test
484     public void testBlocksEndingWithSemiOptionSame() throws Exception {
485         final String[] expected = {
486             "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
487             "21:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
488             "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
489             "35:29: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 29),
490             "41:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
491             "44:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
492             "51:20: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 20),
493             "57:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
494             "60:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
495             "65:30: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 30),
496             "74:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
497             "74:11: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 11),
498             "81:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
499         };
500         verifyWithInlineConfigParser(
501                 getPath("InputRightCurlyTestOptSameBlocksWithSemi.java"), expected);
502     }
503 
504     @Test
505     public void testBlocksEndingWithSemiOptionAlone() throws Exception {
506         final String[] expected = {
507             "13:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
508             "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
509             "18:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
510             "21:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
511             "24:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
512             "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
513             "35:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
514             "37:40: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 40),
515             "41:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
516             "44:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
517             "46:61: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 61),
518             "48:19: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 19),
519             "51:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
520             "53:34: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 34),
521             "57:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
522             "60:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
523             "65:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
524             "71:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
525             "71:11: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 11),
526             "78:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
527         };
528         verifyWithInlineConfigParser(
529                 getPath("InputRightCurlyTestOptAloneBlocksWithSemi.java"), expected);
530     }
531 
532     @Test
533     public void testBlocksEndingWithSemiOptionAloneOrSingleLine() throws Exception {
534         final String[] expected = {
535             "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
536             "21:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
537             "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
538             "35:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
539             "41:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
540             "44:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
541             "51:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
542             "57:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
543             "60:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
544             "65:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
545             "74:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
546             "74:11: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 11),
547             "81:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
548         };
549         verifyWithInlineConfigParser(
550                 getPath("InputRightCurlyTestOptAloneOrSingleLineBlocksWithSemi.java"), expected);
551     }
552 
553     @Test
554     public void testNewTokensAlone() throws Exception {
555         final String[] expected = {
556             "13:19: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 19),
557             "16:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
558             "18:34: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 34),
559         };
560         verifyWithInlineConfigParser(
561                 getPath("InputRightCurlyTestNewTokensAlone.java"), expected);
562     }
563 
564     @Test
565     public void testNewTokensAloneOrSingleLine() throws Exception {
566         final String[] expected = {
567             "16:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
568         };
569         verifyWithInlineConfigParser(
570                 getPath("InputRightCurlyNewTokensAloneOrSingleLine.java"), expected);
571     }
572 
573     @Test
574     public void testNewTokensSame() throws Exception {
575         final String[] expected = {
576             "16:20: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 20),
577         };
578         verifyWithInlineConfigParser(
579                 getPath("InputRightCurlyTestSameNewTokens.java"), expected);
580     }
581 
582     @Test
583     public void testRightCurlyDoubleBrace() throws Exception {
584         final String[] expected = {
585             "14:1: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 1),
586             "14:2: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 2),
587         };
588         verifyWithInlineConfigParser(
589                 getPath("InputRightCurlyTestDoubleBrace.java"), expected);
590     }
591 
592     @Test
593     public void testRightCurlyEmptyOnSingleLine() throws Exception {
594         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
595         verifyWithInlineConfigParser(
596                 getPath("InputRightCurlyTestEmptyOnSingleLine.java"), expected);
597     }
598 
599     @Test
600     public void testRightCurlyEndOfFile() throws Exception {
601         final String[] expected = {
602             "16:2: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 2),
603             "16:3: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 3),
604         };
605         verifyWithInlineConfigParser(
606                 getPath("InputRightCurlyTestEndOfFile.java"), expected);
607     }
608 
609     @Test
610     public void testRightCurlyRecordsAndCompactCtors() throws Exception {
611         final String[] expected = {
612             "23:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
613             "23:11: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 11),
614             "30:21: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 21),
615             "35:23: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 23),
616             "37:37: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 37),
617             "44:68: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 68),
618         };
619         verifyWithInlineConfigParser(
620                 getPath("InputRightCurlyTestRecordsAndCompactCtors.java"), expected);
621     }
622 
623     @Test
624     public void testRightCurlyWithEmoji() throws Exception {
625         final String[] expected = {
626             "24:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
627             "28:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
628             "49:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
629             "69:50: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 50),
630             "78:44: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 44),
631             "84:41: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 41),
632 
633         };
634         verifyWithInlineConfigParser(getPath("InputRightCurlyWithEmoji.java"), expected);
635     }
636 
637     @Test
638     public void testRightCurlyWithEmojiAloneOrSingleLine() throws Exception {
639         final String[] expected = {
640             "24:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
641             "30:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 43),
642             "40:45: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 45),
643             "51:41: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 41),
644             "54:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
645         };
646         verifyWithInlineConfigParser(
647                 getPath("InputRightCurlyWithEmojiAloneOrSingleLine.java"), expected);
648     }
649 
650     @Test
651     public void testUppercaseOptionProperty() throws Exception {
652         final String[] expected = {
653             "16:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
654             "21:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
655         };
656         verifyWithInlineConfigParser(
657                 getPath("InputRightCurlyWithUppercaseOptionProperty.java"), expected);
658     }
659 
660     @Test
661     public void testRightCurlyWithIfElseAlone() throws Exception {
662         final String[] expected = {
663             "19:12: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 12),
664             "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
665         };
666         verifyWithInlineConfigParser(
667                 getPath("InputRightCurlyTestIfElseAlone.java"), expected);
668     }
669 
670     @Test
671     public void testSwitchCase() throws Exception {
672         final String[] expected = {
673             "20:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
674             "27:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
675             "51:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
676             "69:68: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 68),
677             "75:74: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 74),
678             "112:17: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 17),
679             "116:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21),
680         };
681         verifyWithInlineConfigParser(
682                 getPath("InputRightCurlyTestSwitchCase.java"), expected);
683     }
684 
685     @Test
686     public void testSwitchCase2() throws Exception {
687         final String[] expected = {
688             "20:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
689             "27:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
690             "114:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
691         };
692         verifyWithInlineConfigParser(
693                 getPath("InputRightCurlyTestSwitchCase2.java"), expected);
694     }
695 
696     @Test
697     public void testSwitchCase3() throws Exception {
698         final String[] expected = {
699             "15:22: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 22),
700             "17:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
701             "19:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
702             "25:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
703             "26:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
704             "28:22: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 22),
705             "29:22: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 22),
706             "37:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
707             "37:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
708             "46:40: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 40),
709             "46:41: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 41),
710             "54:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
711             "56:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32),
712             "56:33: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 33),
713             "61:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
714             "61:14: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 14),
715         };
716         verifyWithInlineConfigParser(
717                 getPath("InputRightCurlyTestSwitchCase3.java"), expected);
718     }
719 
720     @Test
721     public void testSwitchCase4() throws Exception {
722         final String[] expected = {
723             "17:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
724             "19:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
725             "25:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
726             "26:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
727             "28:22: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 22),
728             "35:41: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 41),
729             "35:42: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 42),
730             "43:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
731             "45:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32),
732         };
733         verifyWithInlineConfigParser(
734                 getPath("InputRightCurlyTestSwitchCase4.java"), expected);
735     }
736 
737     @Test
738     public void testSwitchCase5() throws Exception {
739         final String[] expected = {
740             "17:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
741             "19:36: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 36),
742             "25:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
743             "26:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
744             "28:22: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 22),
745             "35:41: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 41),
746             "35:42: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 42),
747             "43:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
748             "45:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32),
749             "68:49: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 49),
750         };
751         verifyWithInlineConfigParser(
752                 getPath("InputRightCurlyTestSwitchCase5.java"), expected);
753     }
754 
755     @Test
756     public void testSwitchExpression() throws Exception {
757         final String[] expected = {
758             "48:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
759             "56:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
760             "92:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
761         };
762         verifyWithInlineConfigParser(
763                 getPath("InputRightCurlyTestSwitchExpression.java"), expected);
764     }
765 
766     @Test
767     public void testSwitchExpression2() throws Exception {
768         final String[] expected = {
769             "46:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
770             "54:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
771             "77:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
772             "90:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
773         };
774         verifyWithInlineConfigParser(
775                 getPath("InputRightCurlyTestSwitchExpression2.java"), expected);
776     }
777 
778     @Test
779     public void testSwitchExpression3() throws Exception {
780         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
781         verifyWithInlineConfigParser(
782                 getPath("InputRightCurlyTestSwitchExpression3.java"), expected);
783     }
784 
785     @Test
786     public void testSwitchExpression4() throws Exception {
787         final String[] expected = {
788             "117:28: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 28),
789         };
790         verifyWithInlineConfigParser(
791                 getPath("InputRightCurlyTestSwitchExpression4.java"), expected);
792     }
793 
794     @Test
795     public void testSwitchExpression5() throws Exception {
796         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
797         verifyWithInlineConfigParser(
798                 getPath("InputRightCurlyTestSwitchExpression5.java"), expected);
799     }
800 
801     @Test
802     public void testSwitchWithComment() throws Exception {
803         final String[] expected = {
804             "16:66: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 66),
805             "23:61: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 61),
806             "24:57: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 57),
807             "31:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
808             "32:19: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 19),
809             "37:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
810             "38:33: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 33),
811         };
812         verifyWithInlineConfigParser(
813                 getPath("InputRightCurlyTestWithComment.java"), expected);
814     }
815 
816     @Test
817     public void testSwitchExpression6() throws Exception {
818         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
819         verifyWithInlineConfigParser(
820                 getPath("InputRightCurlyTestSwitchExpression6.java"), expected);
821     }
822 
823     @Test
824     public void testSwitchExpression7() throws Exception {
825         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
826         verifyWithInlineConfigParser(
827                 getPath("InputRightCurlyTestSwitchExpression7.java"), expected);
828     }
829 
830     @Test
831     public void testCaseBlocksInSwitchStatementAlone() throws Exception {
832         final String[] expected = {
833             "33:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
834             "44:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
835             "73:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
836             "78:44: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 44),
837             "90:39: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 39),
838             "97:42: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 42),
839             "107:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
840         };
841         verifyWithInlineConfigParser(
842                 getPath("InputRightCurlyCaseBlocksInSwitchStatementAlone.java"), expected);
843     }
844 
845     @Test
846     public void testCaseBlocksInSwitchStatementAlone2() throws Exception {
847         final String[] expected = {
848             "17:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
849             "25:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
850             "37:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
851             "40:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
852             "48:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
853             "48:45: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 45),
854             "59:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
855             "70:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
856             "70:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
857             "79:34: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 34),
858             "79:47: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 47),
859             "88:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
860             "105:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
861         };
862         verifyWithInlineConfigParser(
863                 getPath("InputRightCurlyCaseBlocksInSwitchStatementAlone2.java"), expected);
864     }
865 
866     @Test
867     public void testCaseBlocksInSwitchStatementAloneOrSingleLine() throws Exception {
868         final String[] expected = {
869             "33:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
870             "44:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
871             "73:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
872             "78:51: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 51),
873         };
874         verifyWithInlineConfigParser(
875                 getPath("InputRightCurlyCaseBlocksInSwitchStatementAloneOrSingleline.java"),
876                 expected);
877     }
878 
879     @Test
880     public void testCaseBlocksInSwitchStatementAloneOrSingle2() throws Exception {
881         final String[] expected = {
882             "18:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
883             "27:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
884             "39:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
885             "42:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
886             "50:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
887             "71:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
888             "80:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
889             "100:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
890         };
891         verifyWithInlineConfigParser(
892                 getPath("InputRightCurlyCaseBlocksInSwitchStatementAloneOrSingleline2.java"),
893                 expected);
894     }
895 
896     @Test
897     public void testCaseBlocksInSwitchStatementSame() throws Exception {
898         final String[] expected = {
899             "33:16: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 16),
900             "44:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
901             "73:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
902             "78:51: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 51),
903             "106:23: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 23),
904         };
905         verifyWithInlineConfigParser(
906                 getPath("InputRightCurlyCaseBlocksInSwitchStatementSame.java"), expected);
907     }
908 
909     @Test
910     public void testCaseBlocksInSwitchStatementSame2() throws Exception {
911         final String[] expected = {
912             "17:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
913             "26:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
914             "38:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
915             "41:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
916             "49:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
917             "69:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
918             "75:34: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 34),
919             "75:47: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 47),
920             "86:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
921             "104:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
922         };
923         verifyWithInlineConfigParser(
924                 getPath("InputRightCurlyCaseBlocksInSwitchStatementSame2.java"), expected);
925     }
926 
927     @Test
928     public void testCaseBlocksWithSwitchRuleAlone() throws Exception {
929         final String[] expected = {
930             "32:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
931             "44:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
932             "45:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
933             "56:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
934             "69:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
935             "74:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
936             "83:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
937             "83:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
938             "96:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
939             "97:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
940         };
941         verifyWithInlineConfigParser(
942                 getPath("InputRightCurlyCaseBlocksWithSwitchRuleAlone.java"),
943                 expected);
944     }
945 
946     @Test
947     public void testCaseBlocksWithSwitchRuleAloneOrSingleLine() throws Exception {
948 
949         final String[] expected = {
950             "27:19: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 19),
951             "41:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
952             "53:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
953             "54:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
954             "64:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
955             "77:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
956             "82:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
957             "91:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
958             "102:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
959         };
960         final String fileName = "InputRightCurlyCaseBlocksWithSwitchRuleAloneOrSingleline.java";
961         verifyWithInlineConfigParser(getPath(fileName), expected);
962     }
963 
964     @Test
965     public void testCaseBlocksWithSwitchExpressionAlone() throws Exception {
966         final String[] expected = {
967             "63:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
968             "86:42: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 42),
969         };
970         final String fileName = "InputRightCurlyCaseBlocksWithSwitchExpressionAlone.java";
971         verifyWithInlineConfigParser(getPath(fileName), expected);
972     }
973 
974     @Test
975     public void testCaseBlocksWithSwitchExpressionAloneOrSingleLine() throws Exception {
976         final String[] expected = {
977             "63:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
978         };
979         final String fileName =
980                 "InputRightCurlyCaseBlocksWithSwitchExpressionAloneOrSingleline.java";
981         verifyWithInlineConfigParser(getPath(fileName), expected);
982     }
983 
984     @Test
985     public void testSwitchWhenGuards() throws Exception {
986         final String[] expected = {
987             "25:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
988             "36:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
989             "51:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
990             "64:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
991             "73:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
992         };
993         final String fileName = "InputRightCurlySwitchWhen.java";
994         verifyWithInlineConfigParser(getNonCompilablePath(fileName), expected);
995     }
996 
997     @Test
998     public void testDefaultBlocksInSwitchStatementAlone() throws Exception {
999         final String[] expected = {
1000             "33:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1001             "44:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1002             "73:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1003             "78:68: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 68),
1004             "90:40: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 40),
1005             "97:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 43),
1006             "107:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
1007         };
1008         verifyWithInlineConfigParser(
1009                 getPath("InputRightCurlyDefaultBlocksInSwitchStatementAlone.java"), expected);
1010     }
1011 
1012     @Test
1013     public void testDefaultBlocksInSwitchStatementAlone2() throws Exception {
1014         final String[] expected = {
1015             "17:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
1016             "29:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1017             "41:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24),
1018             "53:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1019             "64:25: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 25),
1020             "71:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
1021         };
1022         verifyWithInlineConfigParser(
1023                 getPath("InputRightCurlyDefaultBlocksInSwitchStatementAlone2.java"), expected);
1024     }
1025 
1026     @Test
1027     public void testDefaultBlocksInSwitchStatementAloneOrSingleline() throws Exception {
1028         final String[] expected = {
1029             "33:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1030             "44:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1031             "73:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1032             "78:74: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 74),
1033         };
1034         verifyWithInlineConfigParser(
1035                 getPath("InputRightCurlyDefaultBlocksInSwitchStatementAloneOrSingleline.java"),
1036                 expected);
1037     }
1038 
1039     @Test
1040     public void testDefaultBlocksInSwitchStatementAloneOrSingleline2() throws Exception {
1041         final String[] expected = {
1042             "18:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
1043             "30:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1044             "43:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15),
1045             "117:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1046         };
1047         verifyWithInlineConfigParser(
1048                 getPath("InputRightCurlyDefaultBlocksInSwitchStatementAloneOrSingleline2.java"),
1049                 expected);
1050     }
1051 
1052     @Test
1053     public void testDefaultBlocksInSwitchStatementSame() throws Exception {
1054         final String[] expected = {
1055             "35:16: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 16),
1056             "46:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1057             "75:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1058             "80:74: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 74),
1059             "110:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1060         };
1061         verifyWithInlineConfigParser(
1062                 getPath("InputRightCurlyDefaultBlocksInSwitchStatementSame.java"), expected);
1063     }
1064 
1065     @Test
1066     public void testDefaultBlocksInSwitchStatementSame2() throws Exception {
1067         final String[] expected = {
1068             "18:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1069             "30:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1070             "42:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1071             "54:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1072             "84:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
1073         };
1074         verifyWithInlineConfigParser(
1075                 getPath("InputRightCurlyDefaultBlocksInSwitchStatementSame2.java"), expected);
1076     }
1077 
1078     @Test
1079     public void testDefaultBlocksWithSwitchRuleAlone() throws Exception {
1080         final String[] expected = {
1081             "63:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1082             "68:82: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 82),
1083             "78:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
1084             "88:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32),
1085         };
1086         verifyWithInlineConfigParser(
1087                 getPath("InputRightCurlyDefaultBlocksWithSwitchRuleAlone.java"),
1088                 expected);
1089     }
1090 
1091     @Test
1092     public void testDefaultBlocksWithSwitchRuleAloneOrSingleline() throws Exception {
1093         final String[] expected = {
1094             "55:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
1095             "68:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1096             "79:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
1097             "84:70: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 70),
1098         };
1099         final String fileName =
1100                 "InputRightCurlyDefaultBlocksWithSwitchRuleAloneOrSingleline.java";
1101         verifyWithInlineConfigParser(getPath(fileName), expected);
1102     }
1103 
1104     @Test
1105     public void testDefaultBlocksWithSwitchExpressionAlone() throws Exception {
1106         final String[] expected = {
1107             "62:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
1108             "86:42: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 42),
1109             "112:34: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 34),
1110         };
1111         final String fileName =
1112                 "InputRightCurlyDefaultBlocksWithSwitchExpressionAlone.java";
1113         verifyWithInlineConfigParser(getPath(fileName), expected);
1114     }
1115 
1116     @Test
1117     public void testDefaultBlocksWithSwitchExpressionAloneOrSingleline() throws Exception {
1118         final String[] expected = {
1119             "62:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
1120             "113:34: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 34),
1121         };
1122         final String fileName =
1123                 "InputRightCurlyDefaultBlocksWithSwitchExpressionAloneOrSingleline.java";
1124         verifyWithInlineConfigParser(getPath(fileName), expected);
1125     }
1126 
1127 }