View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2018 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.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_ALONE;
23  import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_BREAK_BEFORE;
24  import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_NEW;
25  import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_SAME;
26  import static org.junit.Assert.assertEquals;
27  import static org.junit.Assert.assertTrue;
28  import static org.junit.Assert.fail;
29  
30  import org.junit.Test;
31  
32  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
33  import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
34  import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
35  import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
36  
37  public class RightCurlyCheckTest extends AbstractModuleTestSupport {
38  
39      @Override
40      protected String getPackageLocation() {
41          return "com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly";
42      }
43  
44      /* Additional test for jacoco, since valueOf()
45       * is generated by javac and jacoco reports that
46       * valueOf() is uncovered.
47       */
48      @Test
49      public void testRightCurlyOptionValueOf() {
50          final RightCurlyOption option = RightCurlyOption.valueOf("ALONE");
51          assertEquals("Invalid valueOf result", RightCurlyOption.ALONE, option);
52      }
53  
54      @Test
55      public void testDefault() throws Exception {
56          final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
57          final String[] expected = {
58              "25:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
59              "28:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
60              "40:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
61              "44:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
62              "93:27: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 27),
63          };
64          verify(checkConfig, getPath("InputRightCurlyLeft.java"), expected);
65      }
66  
67      @Test
68      public void testSame() throws Exception {
69          final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
70          checkConfig.addAttribute("option", RightCurlyOption.SAME.toString());
71          final String[] expected = {
72              "25:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
73              "28:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17),
74              "40:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
75              "44:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
76              "93:27: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 27),
77          };
78          verify(checkConfig, getPath("InputRightCurlyLeft.java"), expected);
79      }
80  
81      @Test
82      public void testSameOmitOneLiners() throws Exception {
83          final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
84          checkConfig.addAttribute("option", RightCurlyOption.SAME.toString());
85          final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
86          verify(checkConfig, getPath("InputRightCurlyNameForOneLiners.java"), expected);
87      }
88  
89      @Test
90      public void testAlone() throws Exception {
91          final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
92          checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
93          final String[] expected = {
94              "93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
95              "97:72: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 72),
96          };
97          verify(checkConfig, getPath("InputRightCurlyLeft.java"), expected);
98      }
99  
100     @Test
101     public void testNewLine() throws Exception {
102         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
103         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
104         checkConfig.addAttribute("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF");
105         checkConfig.addAttribute("shouldStartLine", "true");
106         final String[] expected = {
107             "111:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
108             "111:6: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 6),
109             "122:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
110             "122:6: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 6),
111             "136:6: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 6),
112         };
113         verify(checkConfig, getPath("InputRightCurlyLeft.java"), expected);
114     }
115 
116     @Test
117     public void testShouldStartLine() throws Exception {
118         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
119         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
120         checkConfig.addAttribute("shouldStartLine", "false");
121         final String[] expected = {
122             "93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
123             "97:72: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 72),
124         };
125         verify(checkConfig, getPath("InputRightCurlyLeft.java"), expected);
126     }
127 
128     @Test
129     public void testMethodCtorNamedClassClosingBrace() throws Exception {
130         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
131         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
132         checkConfig.addAttribute("shouldStartLine", "false");
133         final String[] expected = {
134             "93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
135             "97:72: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 72),
136         };
137         verify(checkConfig, getPath("InputRightCurlyLeft.java"), expected);
138     }
139 
140     @Test
141     public void testForceLineBreakBefore() throws Exception {
142         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
143         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
144         checkConfig.addAttribute("tokens", "LITERAL_FOR,"
145                 + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT");
146         final String[] expected = {
147             "35:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 43),
148             "41:71: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 71),
149             "47:25: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 25),
150         };
151         verify(checkConfig, getPath("InputRightCurlyLineBreakBefore.java"), expected);
152     }
153 
154     @Test
155     public void testForceLineBreakBefore2() throws Exception {
156         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
157         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
158         verify(checkConfig, getPath("InputRightCurlyLineBreakBefore.java"), expected);
159     }
160 
161     @Test
162     public void testNullPointerException() throws Exception {
163         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
164         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
165         checkConfig.addAttribute("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, "
166             + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT");
167         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
168         verify(checkConfig, getPath("InputRightCurlyEmptyAbstractMethod.java"), expected);
169     }
170 
171     @Test
172     public void testWithAnnotations() throws Exception {
173         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
174         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
175         checkConfig.addAttribute("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, "
176             + "LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, "
177             + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT");
178         final String[] expected = {
179             "8:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
180             "11:65: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 65),
181             "22:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
182             "26:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
183             "29:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
184             "32:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
185             "38:73: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 73),
186             "40:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
187             "45:58: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 58),
188             "47:97: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 97),
189             "50:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
190             "53:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
191             "60:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
192             "67:62: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 62),
193             "76:28: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 28),
194             "78:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21),
195             "80:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
196             "82:14: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 14),
197             "93:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
198             "103:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
199             "107:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
200             "111:52: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 52),
201             "111:112: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 112),
202             "114:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 18),
203             "118:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
204             "121:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
205             "123:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
206             "127:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
207             "136:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
208             "138:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
209             "138:33: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 33),
210             "148:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
211             "150:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
212             "151:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
213             "151:93: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 93),
214             "152:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
215             "153:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
216             "153:93: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 93),
217             "159:37: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 37),
218             "166:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
219             "181:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
220             "188:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
221             "188:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 13),
222             "197:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
223             "197:10: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 10),
224             "201:54: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 54),
225             "201:55: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 55),
226             "204:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
227             "204:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
228             "204:77: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 77),
229             "208:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
230             "216:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
231         };
232         verify(checkConfig, getPath("InputRightCurlyAnnotations.java"), expected);
233     }
234 
235     @Test
236     public void testAloneOrSingleLine() throws Exception {
237         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
238         checkConfig.addAttribute("option", RightCurlyOption.ALONE_OR_SINGLELINE.toString());
239         checkConfig.addAttribute("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, "
240             + "LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, "
241             + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT");
242         final String[] expected = {
243             "60:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
244             "69:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
245             "74:52: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 52),
246             "77:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 18),
247             "85:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
248             "97:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
249             "99:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
250             "119:37: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 37),
251             "126:37: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 37),
252             "148:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 13),
253             "157:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
254             "157:10: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 10),
255             "161:54: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 54),
256             "161:55: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 55),
257             "164:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
258             "164:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
259             "164:77: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 77),
260             "176:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
261             "182:24: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 24),
262             "185:24: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 24),
263             "188:24: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 24),
264         };
265         verify(checkConfig, getPath("InputRightCurlyAloneOrSingleline.java"), expected);
266     }
267 
268     @Test
269     public void testCatchWithoutFinally() throws Exception {
270         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
271         final String[] expected = {
272             "15:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
273         };
274         verify(checkConfig, getPath("InputRightCurly.java"), expected);
275     }
276 
277     @Test
278     public void testSingleLineClass() throws Exception {
279         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
280         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
281         checkConfig.addAttribute("tokens", "CLASS_DEF");
282         final String[] expected = {
283             "24:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
284         };
285         verify(checkConfig, getPath("InputRightCurly.java"), expected);
286     }
287 
288     @Test
289     public void testInvalidOption() throws Exception {
290         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
291         checkConfig.addAttribute("option", "invalid_option");
292 
293         try {
294             final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
295 
296             verify(checkConfig, getPath("InputRightCurly.java"), expected);
297             fail("exception expected");
298         }
299         catch (CheckstyleException ex) {
300             final String messageStart =
301                 "cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - "
302                     + "Cannot set property 'option' to 'invalid_option' in module";
303             assertTrue("Invalid exception message, should start with: " + messageStart,
304                 ex.getMessage().startsWith(messageStart));
305         }
306     }
307 
308     @Test
309     public void testRightCurlySameAndLiteralDo() throws Exception {
310         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
311         checkConfig.addAttribute("option", RightCurlyOption.SAME.toString());
312         checkConfig.addAttribute("tokens", "LITERAL_DO");
313         final String[] expected = {
314             "62:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
315             "67:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
316             "83:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
317         };
318         verify(checkConfig, getPath("InputRightCurlyDoWhile.java"), expected);
319     }
320 
321     @Test
322     public void testTryWithResourceSame() throws Exception {
323         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
324         checkConfig.addAttribute("option", RightCurlyOption.SAME.toString());
325         final String[] expected = {
326             "11:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9),
327             "24:67: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 67),
328             "35:15: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 15),
329             "37:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
330         };
331         verify(checkConfig, getPath("InputRightCurlyTryResource.java"), expected);
332     }
333 
334     @Test
335     public void testTryWithResourceAlone() throws Exception {
336         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
337         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
338         final String[] expected = {
339             "19:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
340             "24:67: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 67),
341             "25:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
342             "27:92: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 92),
343             "33:67: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 67),
344             "35:15: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 15),
345             "37:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
346         };
347         verify(checkConfig, getPath("InputRightCurlyTryResource.java"), expected);
348     }
349 
350     @Test
351     public void testTryWithResourceAloneSingle() throws Exception {
352         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
353         checkConfig.addAttribute("option", RightCurlyOption.ALONE_OR_SINGLELINE.toString());
354         final String[] expected = {
355             "19:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
356             "35:15: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 15),
357             "37:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13),
358         };
359         verify(checkConfig, getPath("InputRightCurlyTryResource.java"), expected);
360     }
361 
362     @Test
363     public void testBracePolicyAloneAndSinglelineIfBlocks() throws Exception {
364         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
365         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
366         final String[] expected = {
367             "5:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32),
368             "7:45: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 45),
369             "7:47: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 47),
370         };
371         verify(checkConfig, getPath("InputRightCurlySinglelineIfBlocks.java"), expected);
372     }
373 
374     @Test
375     public void testRightCurlyIsAloneLambda() throws Exception {
376         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
377         checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
378         checkConfig.addAttribute("tokens", "LAMBDA");
379         final String[] expected = {
380             "14:74: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 74),
381             "17:49: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 49),
382             "35:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
383             "45:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
384         };
385         verify(checkConfig, getPath("InputRightCurlyAloneLambda.java"), expected);
386     }
387 
388     @Test
389     public void testRightCurlyIsAloneOrSinglelineLambda() throws Exception {
390         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
391         checkConfig.addAttribute("option",
392             RightCurlyOption.ALONE_OR_SINGLELINE.toString());
393         checkConfig.addAttribute("tokens", "LAMBDA");
394         final String[] expected = {
395             "17:49: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 49),
396             "35:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
397             "45:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
398             "47:58: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 58),
399         };
400         verify(checkConfig,
401             getPath("InputRightCurlyAloneOrSinglelineLambda.java"), expected);
402     }
403 
404     @Test
405     public void testRightCurlyIsSameLambda() throws Exception {
406         final DefaultConfiguration checkConfig = createModuleConfig(RightCurlyCheck.class);
407         checkConfig.addAttribute("option", RightCurlyOption.SAME.toString());
408         checkConfig.addAttribute("tokens", "LAMBDA");
409         final String[] expected = {
410             "17:49: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 49),
411             "35:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5),
412             "40:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13),
413             "53:30: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 30),
414             "68:20: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 20),
415             "73:20: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 20),
416         };
417         verify(checkConfig,
418             getPath("InputRightCurlySameLambda.java"), expected);
419     }
420 
421 }