/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache license, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the license for the specific language governing permissions and
 * limitations under the license.
 */
package org.apache.logging.log4j.core.pattern;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 *
 */
public class NameAbbreviatorTest {

    @Test
    public void testZero() {
        final String str = this.getClass().getName();
        final NameAbbreviator a = NameAbbreviator.getAbbreviator("0");
        final String result = a.abbreviate(str);
        assertEquals("NameAbbreviatorTest", result);
    }

    @Test
    public void testNameAbbreviation() {
        final String str = this.getClass().getName();
        final NameAbbreviator a = NameAbbreviator.getAbbreviator("1");
        final String result = a.abbreviate(str);
        assertEquals("NameAbbreviatorTest", result);
    }

     @Test
    public void testTwo() {
        final String str = this.getClass().getName();
        final NameAbbreviator a = NameAbbreviator.getAbbreviator("2");
        final String result = a.abbreviate(str);
        assertEquals("pattern.NameAbbreviatorTest", result);

    }

    @Test
    public void testThree() throws Exception {
        final String str = this.getClass().getName();
        final NameAbbreviator a = NameAbbreviator.getAbbreviator("3");
        final String result = a.abbreviate(str);
        assertEquals("core.pattern.NameAbbreviatorTest", result);
    }

    @Test
    public void testShortName() {
        final String str = this.getClass().getName();
        final NameAbbreviator a = NameAbbreviator.getAbbreviator("1.");
        final String result = a.abbreviate(str);
        assertEquals("o.a.l.l.c.p.NameAbbreviatorTest", result);

    }

    @Test
    public void testSkipNames() {
        final String str = this.getClass().getName();
        final NameAbbreviator a = NameAbbreviator.getAbbreviator("1.1.~");
        final String result = a.abbreviate(str);
        assertEquals("o.a.~.~.~.~.NameAbbreviatorTest", result);

    }

     @Test
    public void testZeroDot() {
        final String str = this.getClass().getName();
        final NameAbbreviator a = NameAbbreviator.getAbbreviator(".");
        final String result = a.abbreviate(str);
        assertEquals("......NameAbbreviatorTest", result);

    }
}

@@ -853,22 +853,150 @@
 ort 
-org.junit.Test
+java.util.Arrays;%0Aimport java.util.Collection;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized
 ;%0A%0Ai
@@ -1040,16 +1040,46 @@
 %0A *%0A */%0A
+@RunWith(Parameterized.class)%0A
 public c
@@ -1114,1102 +1114,522 @@
     
-@Test%0A    public void testZero() %7B%0A        final String str = this.getClass().getName();%0A        final NameAbbreviator a = NameAbbreviator.getAbbreviator(%220%22);%0A        final String result = a.abbreviate(str);%0A        assertEquals(%22NameAbbreviatorTest%22, result);%0A    %7D%0A%0A    @Test%0A    public void testNameAbbreviation() %7B%0A        final String str = this.getClass().getName();%0A        final NameAbbreviator a = NameAbbreviator.getAbbreviator(%221%22);%0A        final String result = a.abbreviate(str)
+private final String pattern;%0A    private final String expected;%0A%0A    public NameAbbreviatorTest(final String pattern, final String expected) %7B%0A        this.pattern = pattern;%0A        this.expected = expected
 ;%0A    
+%7D%0A%0A
     
-assertEquals(%22NameAbbreviatorTest%22, result);%0A    %7D%0A%0A     @Test%0A    public void testTwo() %7B%0A        final String str = this.getClass().getName();%0A        final NameAbbreviator a = NameAbbreviator.getAbbreviator(%222%22);%0A        final String result = a.abbreviate(str);%0A        assertEquals(%22pattern.NameAbbreviatorTest%22, result);%0A%0A
+@Parameterized.Parameters%0A    public static Collection%3CObject%5B%5D%3E data() %7B%0A        return Arrays.asList(%0A            new Object%5B%5D%5B%5D%7B%0A                // %7B pattern, expected %7D%0A   
     
-%7D%0A%0A
     
-@Test%0A    public void testThree() throws Exception %7B%0A        final String str = this.getClass().getName();%0A        final NameAbbreviator a = NameAbbreviator.getAbbreviator(%223%22);%0A        final String result = a.abbreviate(str);%0A        assertEquals(%22core.
+     %7B %220%22, %22NameAbbreviatorTest%22 %7D,%0A                %7B %221%22, %22NameAbbreviatorTest%22 %7D,%0A                %7B %222%22, %22
 patt
@@ -1656,266 +1656,97 @@
 est%22
-, result);%0A   
  %7D
-%0A
+,
 %0A    
-@Test%0A    public void testShortName() %7B%0A        final String str = this.getClass().getName();%0A        final NameAbbreviator a = NameAbbreviator.getAbbreviator(%221.%22);%0A        final String result = a.abbreviate(str);%0A        assertEquals(
+            %7B %223%22, %22core.pattern.NameAbbreviatorTest%22 %7D,%0A                %7B %221.%22, 
 %22o.a
@@ -1778,323 +1778,161 @@
 est%22
-, result);%0A%0A   
  %7D
-%0A
+,
 %0A    
-@Test%0A    public void testSkipNames() %7B%0A        final String str = this.getClass().getName();%0A        final NameAbbreviator a = NameAbbreviator.getAbbreviator(%221.1.~%22);%0A        final String result = a.abbreviate(str);%0A        assertEquals(%22o.a.~.~.~.~.NameAbbreviatorTest%22, result
+            %7B %221.1.~%22, %22o.a.~.~.~.~.NameAbbreviatorTest%22 %7D,%0A                %7B %22.%22, %22......NameAbbreviatorTest%22 %7D%0A            %7D%0A        
 );%0A
-%0A
     %7D%0A%0A
- 
     
@@ -1961,73 +1961,48 @@
 test
-ZeroDot() %7B%0A        final String str = this.getClass().getName();
+AbbreviatorPatterns() throws Exception %7B
 %0A   
@@ -2029,16 +2029,26 @@
 viator a
+bbreviator
  = NameA
@@ -2073,19 +2073,28 @@
 eviator(
-%22.%22
+this.pattern
 );%0A     
@@ -2113,100 +2113,113 @@
 ing 
-result = a.abbreviate(str);%0A        assertEquals(%22......NameAbbreviatorTest%22, result
+actual = abbreviator.abbreviate(this.getClass().getName());%0A        assertEquals(expected, actual
 );%0A
-%0A
     %7D%0A
+%0A
 %7D%0A

Convert test to parameterized version.