From b9e8d5ed3125cefd113cce1733810b09882c9604 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 21 Oct 2014 10:09:50 +0000
Subject: [PATCH] AutoRefactored Strings.

---
 opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java                     |   17 ++++++-----------
 opendj-config/src/test/java/org/forgerock/opendj/config/ValidateConfigDefinitionsTest.java |    9 ++++-----
 opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java        |    7 +++----
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java      |   18 ++++++------------
 opendj-cli/src/main/java/com/forgerock/opendj/cli/PromptingTrustManager.java               |    6 ++----
 5 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/PromptingTrustManager.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/PromptingTrustManager.java
index 504b11d..6c9f208 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/PromptingTrustManager.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/PromptingTrustManager.java
@@ -285,8 +285,7 @@
                     onDiskTrustStore.setCertificateEntry(alias, aChain);
                 }
             } catch (final Exception e) {
-                LOG.warn(LocalizableMessage.raw("Error setting certificate to store: " + e + "\nCert: "
-                        + aChain.toString()));
+                LOG.warn(LocalizableMessage.raw("Error setting certificate to store: " + e + "\nCert: " + aChain));
             }
         }
 
@@ -374,9 +373,8 @@
             case UNTRUSTED:
                 if (exception instanceof CertificateException) {
                     throw (CertificateException) exception;
-                } else {
-                    throw new CertificateException(exception);
                 }
+                throw new CertificateException(exception);
             case CERTIFICATE_DETAILS:
                 for (final X509Certificate aChain : chain) {
                     app.println();
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java
index 92faca9..94a8fe6 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java
@@ -147,11 +147,10 @@
 
         String nvalue = value.trim().toLowerCase();
         E eValue = decodeMap.get(nvalue);
-        if (eValue == null) {
-            throw PropertyException.illegalPropertyValueException(this, value);
-        } else {
+        if (eValue != null) {
             return eValue;
         }
+        throw PropertyException.illegalPropertyValueException(this, value);
     }
 
     /**
@@ -189,7 +188,7 @@
      */
     public final LocalizableMessage getValueSynopsis(Locale locale, E value) {
         ManagedObjectDefinitionI18NResource resource = ManagedObjectDefinitionI18NResource.getInstance();
-        String property = "property." + getName() + ".syntax.enumeration.value." + value.toString() + ".synopsis";
+        String property = "property." + getName() + ".syntax.enumeration.value." + value + ".synopsis";
         try {
             return resource.getMessage(getManagedObjectDefinition(), property, locale);
         } catch (MissingResourceException e) {
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/ValidateConfigDefinitionsTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/ValidateConfigDefinitionsTest.java
index 30e52b2..e6c2d40 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/ValidateConfigDefinitionsTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/ValidateConfigDefinitionsTest.java
@@ -36,12 +36,13 @@
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.forgerock.opendj.ldap.schema.Schema;
-import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.*;
+
 @SuppressWarnings("javadoc")
 @Test(singleThreaded = true)
 public class ValidateConfigDefinitionsTest extends ConfigTestCase {
@@ -103,10 +104,8 @@
             validatePropertyDefinition(objectDef, configObjectClass, propDef, errors);
         }
 
-        if (errors.length() > 0) {
-            Assert.fail("The configuration definition for " + objectDef.getName() + " has the following problems: "
-                + EOL + errors.toString());
-        }
+        assertTrue(errors.length() != 0,
+                "The configuration definition for " + objectDef.getName() + " has the following problems: " + EOL + errors);
     }
 
     /** Exceptions to properties ending in -class being exactly 'java-class'. */
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
index da6cc2a..df8e2d3 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
@@ -238,8 +238,7 @@
                 final DN dn = request.getName();
                 final DN parent = dn.parent();
                 if (entries.containsKey(dn)) {
-                    throw newLdapException(ResultCode.ENTRY_ALREADY_EXISTS, "The entry '"
-                            + dn.toString() + "' already exists");
+                    throw newLdapException(ResultCode.ENTRY_ALREADY_EXISTS, "The entry '" + dn + "' already exists");
                 } else if (!entries.containsKey(parent)) {
                     noSuchObject(parent);
                 } else {
@@ -269,8 +268,7 @@
                     password = ((GenericBindRequest) request).getAuthenticationValue();
                 } else {
                     throw newLdapException(ResultCode.PROTOCOL_ERROR,
-                            "non-SIMPLE authentication not supported: "
-                                    + request.getAuthenticationType());
+                            "non-SIMPLE authentication not supported: " + request.getAuthenticationType());
                 }
                 entry = getRequiredEntry(null, username);
                 if (!entry.containsAttribute("userPassword", password)) {
@@ -286,8 +284,7 @@
              * one here because the memory back-end is not intended for
              * production use.
              */
-            resultHandler.handleError(newLdapException(ResultCode.INVALID_CREDENTIALS,
-                    "Unknown user"));
+            resultHandler.handleError(newLdapException(ResultCode.INVALID_CREDENTIALS, "Unknown user"));
         } catch (final LdapException e) {
             resultHandler.handleError(e);
         }
@@ -606,9 +603,8 @@
                 final Filter filter = control.getFilter();
                 final Matcher matcher = filter.matcher(schema);
                 if (!matcher.matches(entry).toBoolean()) {
-                    throw newLdapException(ResultCode.ASSERTION_FAILED, "The filter '"
-                            + filter.toString() + "' did not match the entry '"
-                            + entry.getName().toString() + "'");
+                    throw newLdapException(ResultCode.ASSERTION_FAILED,
+                            "The filter '" + filter + "' did not match the entry '" + entry.getName() + "'");
                 }
             }
         }
@@ -620,8 +616,7 @@
     }
 
     private void noSuchObject(final DN dn) throws LdapException {
-        throw newLdapException(ResultCode.NO_SUCH_OBJECT, "The entry '" + dn.toString()
-                + "' does not exist");
+        throw newLdapException(ResultCode.NO_SUCH_OBJECT, "The entry '" + dn + "' does not exist");
     }
 
     private boolean sendEntry(final AttributeFilter filter,
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java
index b0b3b72..510b2f1 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java
@@ -33,7 +33,7 @@
 import org.testng.annotations.Test;
 
 import static org.forgerock.opendj.ldap.schema.SchemaConstants.SYNTAX_CERTIFICATE_OID;
-import static org.testng.Assert.fail;
+import static org.testng.Assert.*;
 
 /**
  * Certificate syntax tests.
@@ -104,18 +104,15 @@
      *            The expected result of the test
      */
     @Test(dataProvider = "acceptableValues")
-    public void testAcceptableValues(ByteString value, Boolean result) {
+    public void testAcceptableValues(ByteString value, boolean result) {
         // Make sure that the specified class can be instantiated as a task.
         final Syntax syntax = getRule();
 
         final LocalizableMessageBuilder reason = new LocalizableMessageBuilder();
 
         // test the valueIsAcceptable method
-        final Boolean liveResult = syntax.valueIsAcceptable(value, reason);
-
-        if (liveResult != result) {
-            fail(syntax + ".valueIsAcceptable gave bad result for " + value.toString() + "reason : " + reason);
-        }
+        final boolean liveResult = syntax.valueIsAcceptable(value, reason);
+        assertEquals(liveResult, result, syntax + ".valueIsAcceptable gave bad result for " + value + "reason : " + reason);
 
         // call the getters
         syntax.getApproximateMatchingRule();
@@ -146,11 +143,8 @@
         final LocalizableMessageBuilder reason = new LocalizableMessageBuilder();
 
         // test the valueIsAcceptable method
-        final Boolean liveResult = syntax.valueIsAcceptable(value, reason);
-
-        if (!liveResult) {
-            fail(syntax + ".valueIsAcceptable gave bad result for " + value.toString() + "reason : " + reason);
-        }
+        final boolean liveResult = syntax.valueIsAcceptable(value, reason);
+        assertTrue(liveResult, syntax + ".valueIsAcceptable gave bad result for " + value + "reason : " + reason);
     }
 
 

--
Gitblit v1.10.0