package com.puppycrawl.tools.checkstyle.checks.naming;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import java.io.File;
import org.junit.Test;

public class AbstractClassNameCheckTest extends BaseCheckTestSupport
{
    @Test
    // abstract --> ^Abstract.*$|^.*Factory$
    public void testIllegalAbstractClassName() throws Exception
    {
        final DefaultConfiguration checkConfig =
            createCheckConfig(AbstractClassNameCheck.class);
        final String[] expected = {
            "3:1: Name 'InputAbstractClassName' must match pattern '^Abstract.*$|^.*Factory$'.",
            "6:1: Name 'NonAbstractClassName' must match pattern '^Abstract.*$|^.*Factory$'.",
            "9:1: Name 'FactoryWithBadName' must match pattern '^Abstract.*$|^.*Factory$'.",
            "13:5: Name 'NonAbstractInnerClass' must match pattern '^Abstract.*$|^.*Factory$'.",
        };
        checkConfig.addAttribute("checkName", "true");
        checkConfig.addAttribute("checkModifier", "false");
        verify(checkConfig, getPath("naming" + File.separator + "InputAbstractClassName.java"), expected);
    }

    @Test
    // ^Abstract.*$|^.*Factory$ --> abstract
	public void testIllegalClassType() throws Exception {
		final DefaultConfiguration checkConfig = createCheckConfig(AbstractClassNameCheck.class);
        final String[] expected = {
                "26:1: Class 'AbstractClass' must has abstract modifier.",
                "29:1: Class 'Class1Factory' must has abstract modifier.",
                "33:5: Class 'AbstractInnerClass' must has abstract modifier.",
                "38:5: Class 'WellNamedFactory' must has abstract modifier.",
                };
        checkConfig.addAttribute("checkName", "false");
        checkConfig.addAttribute("checkModifier", "true");
		verify(checkConfig, getPath("naming" + File.separator + "InputAbstractClassName.java"), expected);
    }

    @Test
    //all variants
    public void testAllVariants() throws Exception {
        final DefaultConfiguration checkConfig = createCheckConfig(AbstractClassNameCheck.class);
        final String[] expected = {
                "3:1: Name 'InputAbstractClassName' must match pattern '^Abstract.*$|^.*Factory$'.",
                "6:1: Name 'NonAbstractClassName' must match pattern '^Abstract.*$|^.*Factory$'.",
                "9:1: Name 'FactoryWithBadName' must match pattern '^Abstract.*$|^.*Factory$'.",
                "13:5: Name 'NonAbstractInnerClass' must match pattern '^Abstract.*$|^.*Factory$'.",
                "26:1: Class 'AbstractClass' must has abstract modifier.",
                "29:1: Class 'Class1Factory' must has abstract modifier.",
                "33:5: Class 'AbstractInnerClass' must has abstract modifier.",
                "38:5: Class 'WellNamedFactory' must has abstract modifier.",
        };
        checkConfig.addAttribute("checkName", "true");
        checkConfig.addAttribute("checkModifier", "true");
        verify(checkConfig, getPath("naming" + File.separator + "InputAbstractClassName.java"), expected);
    }
}

@@ -301,53 +301,8 @@
 est%0A
-    // abstract --%3E %5EAbstract.*$%7C%5E.*Factory$%0A
     
@@ -469,32 +469,148 @@
 meCheck.class);%0A
+        checkConfig.addAttribute(%22checkName%22, %22true%22);%0A        checkConfig.addAttribute(%22checkModifier%22, %22false%22);%0A%0A
         final St
@@ -1026,122 +1026,8 @@
  %7D;%0A
-        checkConfig.addAttribute(%22checkName%22, %22true%22);%0A        checkConfig.addAttribute(%22checkModifier%22, %22false%22);
 %0A   
@@ -1155,50 +1155,8 @@
     
-// %5EAbstract.*$%7C%5E.*Factory$ --%3E abstract%0A%09
 publ
@@ -1206,13 +1206,23 @@
 tion
- %7B%0A%09%09
+%0A    %7B%0A        
 fina
@@ -1299,32 +1299,148 @@
 meCheck.class);%0A
+        checkConfig.addAttribute(%22checkName%22, %22false%22);%0A        checkConfig.addAttribute(%22checkModifier%22, %22true%22);%0A%0A
         final St
@@ -1451,36 +1451,32 @@
 %5B%5D expected = %7B%0A
-    
             %2226:
@@ -1534,36 +1534,32 @@
 .%22,%0A            
-  
-  
 %2229:1: Class 'Cl
@@ -1593,36 +1593,32 @@
 act modifier.%22,%0A
-    
             %2233:
@@ -1681,36 +1681,32 @@
 .%22,%0A            
-   
- 
 %2238:5: Class 'We
@@ -1759,24 +1759,28 @@
         
+%7D;%0A%0A
         
 %7D;%0A     
@@ -1775,128 +1775,8 @@
     
-%7D;%0A        checkConfig.addAttribute(%22checkName%22, %22false%22);%0A        checkConfig.addAttribute(%22checkModifier%22, %22true%22);%0A%09%09
 veri
@@ -1891,27 +1891,8 @@
 est%0A
-    //all variants%0A
     
@@ -1937,16 +1937,20 @@
 xception
+%0A   
  %7B%0A     
@@ -2034,32 +2034,147 @@
 meCheck.class);%0A
+        checkConfig.addAttribute(%22checkName%22, %22true%22);%0A        checkConfig.addAttribute(%22checkModifier%22, %22true%22);%0A%0A
         final St
@@ -2185,36 +2185,32 @@
 %5B%5D expected = %7B%0A
-    
             %223:1
@@ -2294,36 +2294,32 @@
 .%22,%0A            
- 
-   
 %226:1: Name 'NonA
@@ -2389,36 +2389,32 @@
 .%22,%0A            
-    
 %229:1: Name 'Fact
@@ -2482,36 +2482,32 @@
 .%22,%0A            
-   
- 
 %2213:5: Name 'Non
@@ -2579,36 +2579,32 @@
 .%22,%0A            
-    
 %2226:1: Class 'Ab
@@ -2638,36 +2638,32 @@
 act modifier.%22,%0A
-    
             %2229:
@@ -2721,36 +2721,32 @@
 .%22,%0A            
-    
 %2233:5: Class 'Ab
@@ -2797,36 +2797,32 @@
 .%22,%0A            
-    
 %2238:5: Class 'We
@@ -2870,133 +2870,11 @@
 r.%22,
-%0A        %7D;%0A        checkConfig.addAttribute(%22checkName%22, %22true%22);%0A        checkConfig.addAttribute(%22checkModifier%22, %22true%22);
+%7D;%0A
 %0A   

fix up layout