/*
 * 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.commons.text.similarity;

import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Arrays;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

/**
 * Unit tests for {@link org.apache.commons.text.similarity.EditDistanceFrom}.
 *
 * @param <R> The {@link EditDistance} return type.
 */
@RunWith(Parameterized.class)
public class ParameterizedEditDistanceFromTest<R> {

    private final EditDistance<R> editDistance;
    private final CharSequence left;
    private final CharSequence right;
    private final R distance;

    public ParameterizedEditDistanceFromTest(
        final EditDistance<R> editDistance,
        final CharSequence left, final CharSequence right,
        final R distance) {

        this.editDistance = editDistance;
        this.left = left;
        this.right = right;
        this.distance = distance;
    }

    @Parameters
    public static Iterable<Object[]> parameters() {
        return Arrays.asList( new Object[][] {

            /* TODO: When SANDBOX-491 is ready, add a few FuzzyScore tests. */

            { new HammingDistance(), "Sam I am.", "Ham I am.", 1 },
            { new HammingDistance(), "Japtheth, Ham, Shem", "Japtheth, HAM, Shem", 2 },
            { new HammingDistance(), "Hamming", "Hamming", 0 },

            { new JaroWrinklerDistance(), "elephant", "hippo", 0.44 },
            { new JaroWrinklerDistance(), "hippo", "elephant",  0.44 },
            { new JaroWrinklerDistance(), "hippo", "zzzzzzzz", 0.0 },

            /* TODO: When SANDBOX-491 is ready, add a few limited/threshold tests. */
            { new LevenshteinDistance(), "Apache", "a patchy", 4 },
            { new LevenshteinDistance(), "go", "no go", 3 },
            { new LevenshteinDistance(), "go", "go", 0 },

            {
                new EditDistance<Boolean>() {
                    public Boolean apply(CharSequence left, CharSequence right) {
                        return left == right || (left != null && left.equals(right));
                    }
                },
                "Bob's your uncle.",
                "Every good boy does fine.",
                false
            }

        } );
    }

    @Test
    public void test() {
        EditDistanceFrom<R> editDistanceFrom = new EditDistanceFrom<R>(editDistance, left);
        assertThat(editDistanceFrom.apply(right), equalTo(distance));
    }

}

@@ -960,16 +960,41 @@
 .Arrays;
+%0Aimport java.util.Locale;
 %0A%0Aimport
@@ -1949,88 +1949,8 @@
  %7B%0A%0A
-            /* TODO: When SANDBOX-491 is ready, add a few FuzzyScore tests. */%0A%0A
     
@@ -2384,94 +2384,8 @@
 %7D,%0A%0A
-            /* TODO: When SANDBOX-491 is ready, add a few limited/threshold tests. */%0A
     
@@ -2560,32 +2560,223 @@
 o%22, %22go%22, 0 %7D,%0A%0A
+            %7B new LevenshteinDistance(4), %22Apache%22, %22a patchy%22, 4 %7D,%0A            %7B new LevenshteinDistance(4), %22go%22, %22no go%22, 3 %7D,%0A            %7B new LevenshteinDistance(0), %22go%22, %22go%22, 0 %7D,%0A%0A
             %7B%0A  

Fix TODO tags in test