mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
28.47.2010 f2160f4bd1c8ac67e5a86a6710d431e8932877f9
sdk/tests/unit-tests-testng/src/org/opends/sdk/schema/ApproximateMatchingRuleTest.java
@@ -31,12 +31,11 @@
import static org.opends.sdk.schema.SchemaConstants.AMR_DOUBLE_METAPHONE_NAME;
import static org.testng.Assert.assertEquals;
import org.opends.sdk.ByteString;
import org.opends.sdk.ConditionResult;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.sdk.ByteString;
/**
@@ -50,6 +49,26 @@
  /**
   * Test the normalization and the approximate comparison.
   */
  @Test(dataProvider = "approximatematchingrules")
  public void approximateMatchingRules(final MatchingRule rule,
      final String value1, final String value2, final ConditionResult result)
      throws Exception
  {
    // normalize the 2 provided values
    final ByteString normalizedValue1 = rule.normalizeAttributeValue(ByteString
        .valueOf(value1));
    // check that the approximatelyMatch return the expected result.
    final ConditionResult liveResult = rule.getAssertion(
        ByteString.valueOf(value2)).matches(normalizedValue1);
    assertEquals(result, liveResult);
  }
  /**
   * Build the data for the approximateMatchingRules test.
   */
  @DataProvider(name = "approximatematchingrules")
@@ -132,8 +151,7 @@
        { metaphone, "algorithme", "algorizm", ConditionResult.TRUE },
        { metaphone, "testing", "testng", ConditionResult.TRUE },
        { metaphone, "announce", "annonce", ConditionResult.TRUE },
        { metaphone, "automaticly", "automatically",
            ConditionResult.TRUE },
        { metaphone, "automaticly", "automatically", ConditionResult.TRUE },
        { metaphone, "modifyd", "modified", ConditionResult.TRUE },
        { metaphone, "bouteille", "butaille", ConditionResult.TRUE },
        { metaphone, "xeon", "zeon", ConditionResult.TRUE },
@@ -142,24 +160,4 @@
        { metaphone, "thimble", "thimblle", ConditionResult.TRUE },
        { metaphone, "", "", ConditionResult.TRUE }, };
  }
  /**
   * Test the normalization and the approximate comparison.
   */
  @Test(dataProvider = "approximatematchingrules")
  public void approximateMatchingRules(MatchingRule rule,
      String value1, String value2, ConditionResult result)
      throws Exception
  {
    // normalize the 2 provided values
    ByteString normalizedValue1 = rule
        .normalizeAttributeValue(ByteString.valueOf(value1));
    // check that the approximatelyMatch return the expected result.
    ConditionResult liveResult = rule.getAssertion(
        ByteString.valueOf(value2)).matches(normalizedValue1);
    assertEquals(result, liveResult);
  }
}