From 0093f3526b3e3427a6a8a0e4a97a6b27f7906bb8 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 06 Oct 2014 08:41:39 +0000
Subject: [PATCH] SubstringMatchingRuleTest.java: Added strings() + used it in all subclasses.

---
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java     |   52 +++++-------
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java  |   56 ++++++-------
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java |   64 +++++++--------
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java              |    4 +
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java    |   60 ++++++--------
 5 files changed, 109 insertions(+), 127 deletions(-)

diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java
index fb63054..fccd3e0 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java
@@ -33,14 +33,16 @@
 /**
  * Test the CaseExactIA5SubstringMatchingRule.
  */
+@SuppressWarnings("javadoc")
 public class CaseExactIA5SubstringMatchingRuleTest extends SubstringMatchingRuleTest {
 
     @Override
     @DataProvider(name = "substringInvalidAssertionValues")
     public Object[][] createMatchingRuleInvalidAssertionValues() {
-        return new Object[][] { { "12345678\uFFFD", new String[0], null },
-            { null, new String[] { "12345678\uFFFD" }, null },
-            { null, new String[0], "12345678\uFFFD" }, };
+        return new Object[][] {
+            { "12345678\uFFFD", new String[0], null },
+            { null, strings("12345678\uFFFD"), null },
+            { null, strings(), "12345678\uFFFD" }, };
     }
 
     @Override
@@ -49,13 +51,12 @@
         return new Object[][] { { "12345678\uFFFD" }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringFinalMatchData")
     public Object[][] createSubstringFinalMatchData() {
-        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "value", ConditionResult.TRUE },
             { "this is a value", "alue", ConditionResult.TRUE },
             { "this is a value", "ue", ConditionResult.TRUE },
             { "this is a value", "e", ConditionResult.TRUE },
@@ -68,13 +69,12 @@
             { "end with space    ", "space", ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringInitialMatchData")
     public Object[][] createSubstringInitialMatchData() {
-        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "this", ConditionResult.TRUE },
             { "this is a value", "th", ConditionResult.TRUE },
             { "this is a value", "t", ConditionResult.TRUE },
             { "this is a value", "is", ConditionResult.FALSE },
@@ -85,33 +85,29 @@
             { "this is a value", "THIS", ConditionResult.FALSE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringMiddleMatchData")
     public Object[][] createSubstringMiddleMatchData() {
         return new Object[][] {
-            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
+            { "this is a value", strings("this"), ConditionResult.TRUE },
+            { "this is a value", strings("is"), ConditionResult.TRUE },
+            { "this is a value", strings("a"), ConditionResult.TRUE },
+            { "this is a value", strings("value"), ConditionResult.TRUE },
+            { "this is a value", strings(" "), ConditionResult.TRUE },
+            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
             // The matching rule requires ordered non overlapping substrings
             // Issue #730 was not valid.
-            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "his is", "a val", }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "THIS", }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
+            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
+            { "this is a value", strings("his is", "a val"), ConditionResult.TRUE },
+            { "this is a value", strings("not"), ConditionResult.FALSE },
+            { "this is a value", strings("THIS"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
+            { "this is a value", strings("    "), ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     protected MatchingRule getRule() {
         return Schema.getCoreSchema().getMatchingRule(SMR_CASE_EXACT_IA5_OID);
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java
index 76f9658..bbbaf38 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java
@@ -33,6 +33,7 @@
 /**
  * Test the CaseExactSubstringMatchingRule class.
  */
+@SuppressWarnings("javadoc")
 public class CaseExactSubstringMatchingRuleTest extends SubstringMatchingRuleTest {
 
     @Override
@@ -47,13 +48,12 @@
         return new Object[][] {};
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringFinalMatchData")
     public Object[][] createSubstringFinalMatchData() {
-        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "value", ConditionResult.TRUE },
             { "this is a value", "alue", ConditionResult.TRUE },
             { "this is a value", "ue", ConditionResult.TRUE },
             { "this is a value", "e", ConditionResult.TRUE },
@@ -66,13 +66,12 @@
             { "end with space    ", "space", ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringInitialMatchData")
     public Object[][] createSubstringInitialMatchData() {
-        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "this", ConditionResult.TRUE },
             { "this is a value", "th", ConditionResult.TRUE },
             { "this is a value", "t", ConditionResult.TRUE },
             { "this is a value", "is", ConditionResult.FALSE },
@@ -83,34 +82,29 @@
             { "this is a value", "THIS", ConditionResult.FALSE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringMiddleMatchData")
     public Object[][] createSubstringMiddleMatchData() {
         return new Object[][] {
-            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
-            // The matching rule requires ordered non overlapping
-            // substrings.
+            { "this is a value", strings("this"), ConditionResult.TRUE },
+            { "this is a value", strings("is"), ConditionResult.TRUE },
+            { "this is a value", strings("a"), ConditionResult.TRUE },
+            { "this is a value", strings("value"), ConditionResult.TRUE },
+            { "this is a value", strings(" "), ConditionResult.TRUE },
+            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
+            // The matching rule requires ordered non overlapping substrings.
             // Issue #730 was not valid.
-            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "his is", "a val", }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "THIS", }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
+            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
+            { "this is a value", strings("his is", "a val"), ConditionResult.TRUE },
+            { "this is a value", strings("not"), ConditionResult.FALSE },
+            { "this is a value", strings("THIS"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
+            { "this is a value", strings("    "), ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     protected MatchingRule getRule() {
         return Schema.getCoreSchema().getMatchingRule(SMR_CASE_EXACT_OID);
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java
index 6399797..444b46a 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java
@@ -33,13 +33,14 @@
 /**
  * Test the CaseIgnoreIA5SubstringMatchingRule.
  */
+@SuppressWarnings("javadoc")
 public class CaseIgnoreIA5SubstringMatchingRuleTest extends SubstringMatchingRuleTest {
 
     @DataProvider(name = "substringInvalidAssertionValues")
     public Object[][] createMatchingRuleInvalidAssertionValues() {
         return new Object[][] { { "12345678\uFFFD", new String[0], null },
-            { null, new String[] { "12345678\uFFFD" }, null },
-            { null, new String[0], "12345678\uFFFD" }, };
+            { null, strings("12345678\uFFFD"), null },
+            { null, strings(), "12345678\uFFFD" }, };
     }
 
     @DataProvider(name = "substringInvalidAttributeValues")
@@ -47,13 +48,12 @@
         return new Object[][] { { "12345678\uFFFD" }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringFinalMatchData")
     public Object[][] createSubstringFinalMatchData() {
-        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "value", ConditionResult.TRUE },
             { "this is a value", "alue", ConditionResult.TRUE },
             { "this is a value", "ue", ConditionResult.TRUE },
             { "this is a value", "e", ConditionResult.TRUE },
@@ -72,13 +72,12 @@
             { "end with space    ", "SPACE", ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringInitialMatchData")
     public Object[][] createSubstringInitialMatchData() {
-        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "this", ConditionResult.TRUE },
             { "this is a value", "th", ConditionResult.TRUE },
             { "this is a value", "t", ConditionResult.TRUE },
             { "this is a value", "is", ConditionResult.FALSE },
@@ -93,38 +92,33 @@
             { "this is a value", "THIS", ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringMiddleMatchData")
     public Object[][] createSubstringMiddleMatchData() {
         return new Object[][] {
-            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "THIS" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "IS" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "A" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "VALUE" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
-            // The matching rule requires ordered non overlapping
-            // substrings.
+            { "this is a value", strings("this"), ConditionResult.TRUE },
+            { "this is a value", strings("is"), ConditionResult.TRUE },
+            { "this is a value", strings("a"), ConditionResult.TRUE },
+            { "this is a value", strings("value"), ConditionResult.TRUE },
+            { "this is a value", strings("THIS"), ConditionResult.TRUE },
+            { "this is a value", strings("IS"), ConditionResult.TRUE },
+            { "this is a value", strings("A"), ConditionResult.TRUE },
+            { "this is a value", strings("VALUE"), ConditionResult.TRUE },
+            { "this is a value", strings(" "), ConditionResult.TRUE },
+            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
+            // The matching rule requires ordered non overlapping substrings.
             // Issue #730 was not valid.
-            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "IS", "a", "VALue" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "his IS", "A val", }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
+            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "IS", "a", "VALue"), ConditionResult.TRUE },
+            { "this is a value", strings("his IS", "A val"), ConditionResult.TRUE },
+            { "this is a value", strings("not"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
+            { "this is a value", strings("    "), ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     protected MatchingRule getRule() {
         return Schema.getCoreSchema().getMatchingRule(SMR_CASE_IGNORE_IA5_OID);
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java
index 8d24d25..bf0431f 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java
@@ -33,6 +33,7 @@
 /**
  * Test the CaseIgnoreSubstringMatchingRule.
  */
+@SuppressWarnings("javadoc")
 public class CaseIgnoreSubstringMatchingRuleTest extends SubstringMatchingRuleTest {
 
     @DataProvider(name = "substringInvalidAssertionValues")
@@ -45,13 +46,12 @@
         return new Object[][] {};
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringFinalMatchData")
     public Object[][] createSubstringFinalMatchData() {
-        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "value", ConditionResult.TRUE },
             { "this is a value", "alue", ConditionResult.TRUE },
             { "this is a value", "ue", ConditionResult.TRUE },
             { "this is a value", "e", ConditionResult.TRUE },
@@ -70,13 +70,12 @@
             { "end with space    ", "SPACE", ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringInitialMatchData")
     public Object[][] createSubstringInitialMatchData() {
-        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
+        return new Object[][] {
+            { "this is a value", "this", ConditionResult.TRUE },
             { "this is a value", "th", ConditionResult.TRUE },
             { "this is a value", "t", ConditionResult.TRUE },
             { "this is a value", "is", ConditionResult.FALSE },
@@ -91,38 +90,33 @@
             { "this is a value", "THIS", ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     @DataProvider(name = "substringMiddleMatchData")
     public Object[][] createSubstringMiddleMatchData() {
         return new Object[][] {
-            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "THIS" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "IS" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "A" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "VALUE" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
-            // The matching rule requires ordered non overlapping
-            // substrings.
+            { "this is a value", strings("this"), ConditionResult.TRUE },
+            { "this is a value", strings("is"), ConditionResult.TRUE },
+            { "this is a value", strings("a"), ConditionResult.TRUE },
+            { "this is a value", strings("value"), ConditionResult.TRUE },
+            { "this is a value", strings("THIS"), ConditionResult.TRUE },
+            { "this is a value", strings("IS"), ConditionResult.TRUE },
+            { "this is a value", strings("A"), ConditionResult.TRUE },
+            { "this is a value", strings("VALUE"), ConditionResult.TRUE },
+            { "this is a value", strings(" "), ConditionResult.TRUE },
+            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
+            // The matching rule requires ordered non overlapping substrings.
             // Issue #730 was not valid.
-            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "IS", "a", "VALue" }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "his IS", "A val", }, ConditionResult.TRUE },
-            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
-            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
+            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "IS", "a", "VALue"), ConditionResult.TRUE },
+            { "this is a value", strings("his IS", "A val"), ConditionResult.TRUE },
+            { "this is a value", strings("not"), ConditionResult.FALSE },
+            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
+            { "this is a value", strings("    "), ConditionResult.TRUE }, };
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     protected MatchingRule getRule() {
         return Schema.getCoreSchema().getMatchingRule(SMR_CASE_IGNORE_OID);
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java
index 85f08f9..cdec418 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java
@@ -219,4 +219,8 @@
      * @return An instance of the matching rule to test.
      */
     protected abstract MatchingRule getRule();
+
+    protected String[] strings(String... strings) {
+        return strings;
+    }
 }

--
Gitblit v1.10.0