1   package example;
2   
3   import junit.framework.TestCase;
4   
5   import spoon.contrib.testkit.CtFile4ClassBody;
6   import spoon.contrib.testkit.ProcessorTestHelper;
7   import spoon.contrib.testkit.ReportEntry;
8   import spoon.processing.Severity;
9   
10  public class FieldNameCheckerTest extends TestCase{
11  
12      public void testFinalStaticOK() throws Exception {
13          FieldNameChecker checker = new FieldNameChecker();
14  
15          ProcessorTestHelper.assertNoReport(checker,
16                  new CtFile4ClassBody("public final static int FOO = 0;")
17          );
18          ProcessorTestHelper.assertNoReport(checker,
19                  new CtFile4ClassBody("public final static int FOO_BAR = 0;")
20          );
21      }
22  
23      public void testFinalStaticFailed() throws Exception {
24          FieldNameChecker checker = new FieldNameChecker();
25  
26          ProcessorTestHelper.assertReporting(checker,
27                  new CtFile4ClassBody("public final static int foo = 0;"),
28                  new ReportEntry(checker, Severity.WARNING, null, null)
29          );
30          ProcessorTestHelper.assertReporting(checker,
31                  new CtFile4ClassBody("public final static int _FOO = 0;"),
32                  new ReportEntry(checker, Severity.WARNING, null, null)
33          );
34      }
35  
36      public void testChangeSeverity() throws Exception {
37          FieldNameChecker checker = new FieldNameChecker();
38          checker.severity = Severity.MESSAGE;
39  
40          ProcessorTestHelper.assertReporting(checker,
41                  new CtFile4ClassBody("public final static int foo = 0;"),
42                  new ReportEntry(checker, Severity.MESSAGE, null, null)
43          );
44      }
45  
46  }