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