From 5e0a551935151242e4308053617c2f487a60d5f0 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 08 Aug 2016 07:31:26 +0000
Subject: [PATCH] Partial OPENDJ-3106 Migrate Entry
---
opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java | 10
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java | 10 +
opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java | 37 ++--
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java | 7
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java | 22 +-
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java | 16 +-
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java | 12 +
opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java | 12
opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java | 36 ++--
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java | 3
opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java | 16 +-
opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java | 6
opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java | 13 +
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java | 7
opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java | 30 ++-
opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java | 22 +-
opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java | 24 +-
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java | 7
opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java | 28 ++--
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 6
opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java | 19 +-
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java | 11
opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java | 34 ++--
24 files changed, 208 insertions(+), 182 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
index d08db62..88c4c45 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
@@ -63,6 +63,7 @@
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.CoreSchema;
+import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.server.config.server.TrustStoreBackendCfg;
import org.forgerock.util.Reject;
import org.opends.server.api.Backend;
@@ -86,7 +87,6 @@
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.types.RestoreConfig;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.CertificateManager;
@@ -1077,16 +1077,16 @@
}
else
{
- List<Attribute> certAttrs = entry.getAllAttributes(
- ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
- if (certAttrs.isEmpty())
+ Iterator<Attribute> certAttrs = entry.getAllAttributes(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE).iterator();
+ if (!certAttrs.hasNext())
{
LocalizableMessage message =
ERR_TRUSTSTORE_ENTRY_MISSING_CERT_ATTR.get(entryDN, ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
throw new DirectoryException(
DirectoryServer.getServerErrorResultCode(), message);
}
- if (certAttrs.size() != 1)
+ Attribute certAttr = certAttrs.next();
+ if (certAttrs.hasNext())
{
LocalizableMessage message =
ERR_TRUSTSTORE_ENTRY_HAS_MULTIPLE_CERT_ATTRS.get(entryDN, ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
@@ -1094,7 +1094,6 @@
DirectoryServer.getServerErrorResultCode(), message);
}
- Attribute certAttr = certAttrs.get(0);
Iterator<ByteString> i = certAttr.iterator();
if (!i.hasNext())
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
index 3ca0915..e4ff406 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
@@ -311,8 +311,8 @@
private String getAttributeValue(String attributeName, boolean isRequired)
throws InitializationException
{
- List<Attribute> attrList = taskEntry.getAllAttributes(attributeName);
- if (attrList.isEmpty())
+ Iterator<Attribute> attrList = taskEntry.getAllAttributes(attributeName).iterator();
+ if (!attrList.hasNext())
{
if (isRequired)
{
@@ -321,13 +321,13 @@
return null;
}
- if (attrList.size() > 1)
+ final Iterator<ByteString> values = attrList.next().iterator();
+ if (attrList.hasNext())
{
throw new InitializationException(ERR_TASK_MULTIPLE_ATTRS_FOR_TYPE.get(attributeName, taskEntry.getName()));
}
- Iterator<ByteString> iterator = attrList.get(0).iterator();
- if (! iterator.hasNext())
+ if (!values.hasNext())
{
if (isRequired)
{
@@ -336,8 +336,8 @@
return null;
}
- ByteString value = iterator.next();
- if (iterator.hasNext())
+ ByteString value = values.next();
+ if (values.hasNext())
{
throw new InitializationException(ERR_TASK_MULTIPLE_VALUES_FOR_ATTR.get(attributeName, taskEntry.getName()));
}
@@ -359,21 +359,21 @@
*/
private LinkedList<String> getAttributeValues(String attributeName) throws InitializationException
{
- LinkedList<String> valueStrings = new LinkedList<>();
- List<Attribute> attrList = taskEntry.getAllAttributes(attributeName);
- if (attrList.isEmpty())
+ final LinkedList<String> valueStrings = new LinkedList<>();
+ final Iterator<Attribute> attrList = taskEntry.getAllAttributes(attributeName).iterator();
+ if (!attrList.hasNext())
{
return valueStrings;
}
- if (attrList.size() > 1)
+ final Iterator<ByteString> values = attrList.next().iterator();
+ if (attrList.hasNext())
{
throw new InitializationException(ERR_TASK_MULTIPLE_ATTRS_FOR_TYPE.get(attributeName, taskEntry.getName()));
}
- Iterator<ByteString> iterator = attrList.get(0).iterator();
- while (iterator.hasNext())
+ while (values.hasNext())
{
- valueStrings.add(iterator.next().toString());
+ valueStrings.add(values.next().toString());
}
return valueStrings;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
index 389cdc3..0cb9c59 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -19,6 +19,7 @@
import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.replication.plugin.HistAttrModificationKey.*;
+import static org.opends.server.util.CollectionUtils.*;
import java.util.HashMap;
import java.util.Iterator;
@@ -515,11 +516,11 @@
public static EntryHistorical newInstanceFromEntry(Entry entry)
{
// Read the DB historical attribute from the entry
- List<Attribute> histAttrWithOptionsFromEntry = getHistoricalAttr(entry);
+ Iterable<Attribute> histAttrWithOptionsFromEntry = getHistoricalAttr(entry);
// Now we'll build the Historical object we want to construct
final EntryHistorical newHistorical = new EntryHistorical();
- if (histAttrWithOptionsFromEntry.isEmpty())
+ if (isEmpty(histAttrWithOptionsFromEntry))
{
// No historical attribute in the entry, return empty object
return newHistorical;
@@ -660,7 +661,7 @@
* Several values on the list if several options for this attribute.
* Null if not present.
*/
- public static List<Attribute> getHistoricalAttr(Entry entry)
+ public static Iterable<Attribute> getHistoricalAttr(Entry entry)
{
return entry.getAllAttributes(HISTORICAL_ATTRIBUTE_NAME);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index e59499c..8ef9f28 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3287,10 +3287,10 @@
SearchResultEntry resultEntry = result.get(0);
if (resultEntry != null)
{
- List<Attribute> attrs = resultEntry.getAllAttributes(REPLICATION_GENERATION_ID);
- if (!attrs.isEmpty())
+ Iterator<Attribute> attrs = resultEntry.getAllAttributes(REPLICATION_GENERATION_ID).iterator();
+ if (attrs.hasNext())
{
- Attribute attr = attrs.get(0);
+ Attribute attr = attrs.next();
if (attr.size()>1)
{
String errorMsg = "#Values=" + attr.size() + " Must be exactly 1 in entry " + resultEntry.toLDIFString();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
index 89cbd4b..bde8767 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
@@ -17,6 +17,7 @@
package org.opends.server.tools;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -118,10 +119,10 @@
*/
public static String getStringSingleValuedAttribute(Entry entry, String attrName)
{
- List<Attribute> attributes = entry.getAllAttributes(attrName);
- if (!attributes.isEmpty())
+ Iterator<Attribute> attributes = entry.getAllAttributes(attrName).iterator();
+ if (attributes.hasNext())
{
- Attribute attribute = attributes.get(0);
+ Attribute attribute = attributes.next();
for (ByteString byteString : attribute)
{
return byteString.toString();
@@ -134,10 +135,10 @@
{
try
{
- List<Attribute> attributes = configEntry.getAllAttributes(ATTR_BACKEND_BASE_DN);
- if (!attributes.isEmpty())
+ Iterator<Attribute> attributes = configEntry.getAllAttributes(ATTR_BACKEND_BASE_DN).iterator();
+ if (attributes.hasNext())
{
- Attribute attribute = attributes.get(0);
+ Attribute attribute = attributes.next();
List<DN> dns = new ArrayList<>();
for (ByteString byteString : attribute)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
index a3d4317..5ceb723 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
@@ -418,10 +418,10 @@
Set<DN> baseDNs = new TreeSet<>();
try
{
- List<Attribute> attributes = configEntry.getAllAttributes(ATTR_BACKEND_BASE_DN);
- if (!attributes.isEmpty())
+ Iterator<Attribute> attributes = configEntry.getAllAttributes(ATTR_BACKEND_BASE_DN).iterator();
+ if (attributes.hasNext())
{
- Attribute attribute = attributes.get(0);
+ Attribute attribute = attributes.next();
for (ByteString byteString : attribute)
{
baseDNs.add(DN.valueOf(byteString.toString()));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java
index 47b5cb2..6294aef 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java
@@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -416,9 +417,12 @@
}
private String getSingleStringValue(Entry entry, String attrName) {
- List<Attribute> attrList = entry.getAllAttributes(attrName);
- if (attrList.size() == 1) {
- Attribute attr = attrList.get(0);
+ Iterator<Attribute> attrs = entry.getAllAttributes(attrName).iterator();
+ if (attrs.hasNext()) {
+ Attribute attr = attrs.next();
+ if (attrs.hasNext()) {
+ return "";
+ }
if (!attr.isEmpty()) {
return attr.iterator().next().toString();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
index 099261e..d21d9b0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -734,7 +734,7 @@
* attribute type, or an empty list if the specified
* attribute type is not present in this entry.
*/
- public List<Attribute> getAllAttributes(String nameOrOID)
+ public Iterable<Attribute> getAllAttributes(String nameOrOID)
{
for (AttributeType attr : userAttributes.keySet())
{
@@ -826,8 +826,9 @@
public AttributeParser parseAttribute(String attributeDescription)
throws LocalizedIllegalArgumentException, NullPointerException
{
- final List<Attribute> attribute = getAllAttributes(attributeDescription);
- return AttributeParser.parseAttribute(!attribute.isEmpty() ? attribute.get(0) : null);
+ final Iterable<Attribute> attribute = getAllAttributes(attributeDescription);
+ Iterator<Attribute> it = attribute.iterator();
+ return AttributeParser.parseAttribute(it.hasNext() ? it.next() : null);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
index fdb34ff..52f66d8 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
@@ -16,8 +16,22 @@
*/
package org.opends.server.authorization.dseecompat;
-import java.io.*;
-import java.util.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.ServerConstants.*;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import javax.naming.NamingException;
import javax.naming.NoPermissionException;
@@ -26,6 +40,7 @@
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.ModificationItem;
+import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.DirectoryServerTestCase;
@@ -39,7 +54,6 @@
import org.opends.server.tools.LDAPPasswordModify;
import org.opends.server.tools.LDAPSearch;
import org.opends.server.types.Attribute;
-import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.testng.Assert;
@@ -48,10 +62,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.ServerConstants.*;
-
@SuppressWarnings("javadoc")
@Test(groups = {"precommit", "dseecompat"}, sequential = true)
public abstract class AciTestCase extends DirectoryServerTestCase {
@@ -69,12 +79,12 @@
// Save Global ACI.
Entry e = DirectoryServer.getEntry(DN.valueOf(ACCESS_HANDLER_DN));
- List<Attribute> attrs = e.getAllAttributes(ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI);
- if (!attrs.isEmpty())
+ Iterator<Attribute> attrs = e.getAllAttributes(ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI).iterator();
+ if (attrs.hasNext())
{
Reporter.log("Saved global ACI attribute");
- globalACIAttribute = attrs.iterator().next();
+ globalACIAttribute = attrs.next();
}
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
index 7dc5085..39b369e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
@@ -36,6 +36,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -943,7 +944,8 @@
private String readCookieFromNthEntry(List<SearchResultEntry> entries, int i)
{
SearchResultEntry entry = entries.get(i);
- return entry.getAllAttributes("changelogcookie").get(0).iterator().next().toString();
+ Attribute attr = entry.getAllAttributes("changelogcookie").iterator().next();
+ return attr.iterator().next().toString();
}
private String assertEntriesContainsCSNsAndReadLastCookie(String test, List<SearchResultEntry> entries,
@@ -1479,12 +1481,12 @@
private static String getAttributeValue(Entry entry, String attrName)
{
- List<Attribute> attrs = entry.getAllAttributes(attrName);
- if (attrs.isEmpty())
+ Iterator<Attribute> attrs = entry.getAllAttributes(attrName).iterator();
+ if (!attrs.hasNext())
{
return null;
}
- Attribute attr = attrs.iterator().next();
+ Attribute attr = attrs.next();
ByteString value = attr.iterator().next();
return value.toString();
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
index dba2744..c3cac98 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
@@ -793,7 +793,7 @@
retrieveCompletedOperationElements(addOperation);
Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test"));
- List<Attribute> attrList = e.getAllAttributes("ou");
+ Iterable<Attribute> attrList = e.getAllAttributes("ou");
assertThat(attrList).isNotEmpty();
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
index 579bd66..14419ab 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
@@ -3242,10 +3242,11 @@
// @formatter:on
e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
- List<Attribute> attrList = e.getAllAttributes("userpassword");
- assertThat(attrList).hasSize(1);
- assertFalse(attrList.get(0).getAttributeDescription().hasOptions());
- assertThat(attrList.get(0)).hasSize(1);
+ Iterable<Attribute> attrs = e.getAllAttributes("userpassword");
+ assertThat(attrs).hasSize(1);
+ Attribute attr = attrs.iterator().next();
+ assertFalse(attr.getAttributeDescription().hasOptions());
+ assertThat(attr).hasSize(1);
}
/**
@@ -3282,10 +3283,11 @@
// @formatter:on
e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
- List<Attribute> attrList = e.getAllAttributes("userpassword");
- assertThat(attrList).hasSize(1);
- assertFalse(attrList.get(0).getAttributeDescription().hasOptions());
- assertThat(attrList.get(0)).hasSize(1);
+ Iterable<Attribute> attrs = e.getAllAttributes("userpassword");
+ assertThat(attrs).hasSize(1);
+ Attribute attr = attrs.iterator().next();
+ assertFalse(attr.getAttributeDescription().hasOptions());
+ assertThat(attr).hasSize(1);
}
/**
@@ -3318,10 +3320,11 @@
// @formatter:on
Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
- List<Attribute> attrList = e.getAllAttributes("userpassword");
- assertThat(attrList).hasSize(1);
- assertFalse(attrList.get(0).getAttributeDescription().hasOptions());
- assertThat(attrList.get(0)).hasSize(1);
+ Iterable<Attribute> attrs = e.getAllAttributes("userpassword");
+ assertThat(attrs).hasSize(1);
+ Attribute attr = attrs.iterator().next();
+ assertFalse(attr.getAttributeDescription().hasOptions());
+ assertThat(attr).hasSize(1);
}
/**
@@ -3354,10 +3357,11 @@
// @formatter:on
Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
- List<Attribute> attrList = e.getAllAttributes("userpassword");
- assertThat(attrList).hasSize(1);
- assertFalse(attrList.get(0).getAttributeDescription().hasOptions());
- assertThat(attrList.get(0)).hasSize(1);
+ Iterable<Attribute> attrs = e.getAllAttributes("userpassword");
+ assertThat(attrs).hasSize(1);
+ Attribute attr = attrs.iterator().next();
+ assertFalse(attr.getAttributeDescription().hasOptions());
+ assertThat(attr).hasSize(1);
}
/**
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java
index 2c306dd..de6744e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java
@@ -16,9 +16,17 @@
*/
package org.opends.server.core;
+import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.testng.Assert.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
@@ -63,13 +71,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.*;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.testng.Assert.*;
-
@SuppressWarnings("javadoc")
public class SearchOperationTestCase extends OperationTestCase
{
@@ -980,18 +981,18 @@
{
for (String attrType : virtualAttrTypes)
{
- List<Attribute> attrList = entry.getAllAttributes(attrType);
+ Iterable<Attribute> attrs = entry.getAllAttributes(attrType);
if (stripVirtualAttributes)
{
- if (!attrList.isEmpty())
+ if (!isEmpty(attrs))
{
messages.add("Unexpected virtual attribute: " + attrType);
}
}
else if (filterType == AttributeFilterType.DEFAULT)
{
- if (!attrList.isEmpty())
+ if (!isEmpty(attrs))
{
messages.add("Unexpected operational attribute: " + attrType);
}
@@ -999,20 +1000,21 @@
else if ("ismemberof".equals(attrType))
{
// isMemberOf should never be returned as user is not in any groups.
- if (!attrList.isEmpty())
+ if (!isEmpty(attrs))
{
messages.add("Unexpected isMemberOf attribute");
}
}
else
{
- if (attrList.isEmpty())
+ Iterator<Attribute> attrsIt = attrs.iterator();
+ if (!attrsIt.hasNext())
{
messages.add("Missing virtual attribute: " + attrType);
}
else
{
- Attribute attr = attrList.get(0);
+ Attribute attr = attrsIt.next();
if (typesOnly)
{
if (!attr.isEmpty())
@@ -1037,24 +1039,25 @@
{
for (String attrType : realAttrTypes)
{
- List<Attribute> attrList = entry.getAllAttributes(attrType);
+ Iterable<Attribute> attrs = entry.getAllAttributes(attrType);
if (stripRealAttributes)
{
- if (!attrList.isEmpty())
+ if (!isEmpty(attrs))
{
messages.add("Unexpected real attribute: " + attrType);
}
}
else
{
- if (attrList.isEmpty())
+ Iterator<Attribute> attrsIt = attrs.iterator();
+ if (!attrsIt.hasNext())
{
messages.add("Missing real attribute: " + attrType);
}
else
{
- Attribute attr = attrList.get(0);
+ Attribute attr = attrsIt.next();
if (typesOnly)
{
if (!attr.isEmpty())
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
index 23d5042..2324943 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
@@ -17,6 +17,15 @@
package org.opends.server.core;
+import static org.assertj.core.api.Assertions.*;
+import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.testng.Assert.*;
+
import java.util.ArrayList;
import java.util.List;
@@ -44,15 +53,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.*;
-import static org.forgerock.opendj.ldap.ModificationType.*;
-import static org.opends.server.TestCaseUtils.*;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.testng.Assert.*;
-
@SuppressWarnings("javadoc")
public class SubentryManagerTestCase extends CoreTestCase
{
@@ -225,7 +225,7 @@
Entry e = DirectoryServer.getEntry(DN.valueOf("uid=normal user,ou=people,o=test"));
assertNotNull(e);
- List<Attribute> description = e.getAllAttributes("description");
+ Iterable<Attribute> description = e.getAllAttributes("description");
assertThat(description).isEmpty();
// Collective user will inherit the collective description attribute.
@@ -234,7 +234,7 @@
description = e.getAllAttributes("description");
assertThat(description).hasSize(1);
- Attribute attribute = description.get(0);
+ Attribute attribute = description.iterator().next();
assertEquals(attribute.size(), 1);
assertFalse(attribute.getAttributeDescription().hasOptions());
assertTrue(attribute.contains(ByteString.valueOfUtf8("inherited description")));
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java
index 92521ed..1afe927 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java
@@ -16,9 +16,13 @@
*/
package org.opends.server.extensions;
+import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.testng.Assert.*;
+
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
@@ -37,10 +41,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.testng.Assert.*;
-
@SuppressWarnings("javadoc")
public class PasswordExpirationTimeVirtualAttributeProviderTestCase
extends ExtensionsTestCase
@@ -204,10 +204,10 @@
SearchResultEntry entry = entries.get(0);
assertNotNull(entry);
- List<Attribute> attrs = entry.getAllAttributes(attributeName);
- assertEquals(attrs.size(), 1);
+ Iterable<Attribute> attrs = entry.getAllAttributes(attributeName);
+ assertThat(attrs).hasSize(1);
- Attribute attr = attrs.get(0);
+ Attribute attr = attrs.iterator().next();
assertNotNull(attr);
Iterator<ByteString> it = attr.iterator();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
index 1581544..839377d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
@@ -197,8 +197,7 @@
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
assertNotNull(e);
- List<Attribute> attrs = e.getAllAttributes("usercertificate");
- Attribute a = attrs.get(0);
+ Attribute a = e.getAllAttributes("usercertificate").iterator().next();
assertNotNull(a);
assertThat(a.getAttributeDescription().getOptions()).contains("binary");
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
index 286ac92..8472094 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
@@ -16,6 +16,17 @@
*/
package org.opends.server.replication;
+import static java.util.concurrent.TimeUnit.*;
+
+import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.forgerock.opendj.ldap.ResultCode.*;
+import static org.forgerock.opendj.ldap.SearchScope.*;
+import static org.opends.server.backends.task.TaskState.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.testng.Assert.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -68,17 +79,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static java.util.concurrent.TimeUnit.*;
-
-import static org.forgerock.opendj.ldap.ModificationType.*;
-import static org.forgerock.opendj.ldap.ResultCode.*;
-import static org.forgerock.opendj.ldap.SearchScope.*;
-import static org.opends.server.backends.task.TaskState.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.testng.Assert.*;
-
/** An abstract class that all Replication unit test should extend. */
@SuppressWarnings("javadoc")
@Test(groups = { "precommit", "replication" }, sequential = true)
@@ -524,9 +524,9 @@
{
final Entry newEntry = DirectoryServer.getEntry(dn);
assertNotNull(newEntry);
- List<Attribute> attrList = newEntry.getAllAttributes(attrTypeStr);
- Assertions.assertThat(attrList).isNotEmpty();
- Attribute attr = attrList.get(0);
+ Iterable<Attribute> attrs = newEntry.getAllAttributes(attrTypeStr);
+ Assertions.assertThat(attrs).isNotEmpty();
+ Attribute attr = attrs.iterator().next();
boolean foundAttributeValue = attr.contains(ByteString.valueOfUtf8(valueString));
assertEquals(foundAttributeValue, expectedAttributeValueFound, foundMsg);
return null;
@@ -781,10 +781,10 @@
{
Entry newEntry = DirectoryServer.getEntry(dn);
assertNotNull(newEntry);
- Attribute attribute = newEntry.getAllAttributes("entryuuid").get(0);
- String found = attribute.iterator().next().toString();
+ Attribute attribute = newEntry.getAllAttributes("entryuuid").iterator().next();
+ ByteString found = attribute.iterator().next();
assertNotNull(found, "Entry: " + dn + " Could not be found.");
- return found;
+ return found.toString();
}
});
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
index 7d2e19f..9bd57ea 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
@@ -16,6 +16,17 @@
*/
package org.opends.server.replication;
+import static java.util.concurrent.TimeUnit.*;
+
+import static org.forgerock.opendj.ldap.ModificationType.*;
+import static org.forgerock.opendj.ldap.requests.Requests.*;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.replication.plugin.LDAPReplicationDomain.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.testng.Assert.*;
+
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.List;
@@ -60,17 +71,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static java.util.concurrent.TimeUnit.*;
-
-import static org.forgerock.opendj.ldap.ModificationType.*;
-import static org.forgerock.opendj.ldap.requests.Requests.*;
-import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
-import static org.opends.server.TestCaseUtils.*;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.replication.plugin.LDAPReplicationDomain.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.testng.Assert.*;
-
/**
* Test synchronization of update operations on the directory server and through
* the replication server broker interface.
@@ -1087,7 +1087,7 @@
*/
private boolean assertConflictAttributeExists(Entry entry)
{
- return !entry.getAllAttributes("ds-sync-confict").isEmpty();
+ return !isEmpty(entry.getAllAttributes("ds-sync-confict"));
}
@DataProvider(name="assured")
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
index a4f6589..5684966 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -30,6 +30,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -1480,15 +1481,15 @@
throw new Exception("Unknown assured type");
}
- List<Attribute> attrs = entry.getAllAttributes(assuredAttr);
- if (attrs.isEmpty())
+ Iterator<Attribute> attrs = entry.getAllAttributes(assuredAttr).iterator();
+ if (!attrs.hasNext())
{
return Collections.emptyMap();
}
// Parse and store values
Map<Integer,Integer> resultMap = new HashMap<>();
- for (ByteString val : attrs.get(0))
+ for (ByteString val : attrs.next())
{
StringTokenizer strtok = new StringTokenizer(val.toString(), ":");
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
index d3a1d11..80ddaff 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -139,12 +139,8 @@
replServerPort = TestCaseUtils.findFreePort();
}
- /**
- * Returns a bunch of single values for fractional-exclude configuration
- * attribute
- */
- @SuppressWarnings("unused")
- @DataProvider(name = "testExcludePrecommitProvider")
+ /** Returns a bunch of single values for fractional-exclude configuration attribute. */
+ @DataProvider
private Object[][] testExcludePrecommitProvider()
{
return new Object[][]
@@ -753,9 +749,11 @@
*/
private static void checkEntryAttributeValue(Entry entry, String attributeName, String attributeValue)
{
- List<Attribute> attrs = entry.getAllAttributes(attributeName);
- assertThat(attrs).as("Was expecting attribute " + attributeName + "=" + attributeValue).hasSize(1);
- Attribute attr = attrs.get(0);
+ Iterable<Attribute> attrs = entry.getAllAttributes(attributeName);
+ assertThat(attrs)
+ .as("Was expecting attribute " + attributeName + "=" + attributeValue)
+ .hasSize(1);
+ Attribute attr = attrs.iterator().next();
Iterator<ByteString> attrValues = attr.iterator();
assertTrue(attrValues.hasNext());
ByteString attrValue = attrValues.next();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
index eaa8563..f83379c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
@@ -16,6 +16,15 @@
*/
package org.opends.server.replication.plugin;
+import static java.util.concurrent.TimeUnit.*;
+
+import static org.forgerock.opendj.ldap.ResultCode.*;
+import static org.forgerock.opendj.ldap.SearchScope.*;
+import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.util.CollectionUtils.*;
+import static org.testng.Assert.*;
+
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Callable;
@@ -45,15 +54,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static java.util.concurrent.TimeUnit.*;
-
-import static org.forgerock.opendj.ldap.ResultCode.*;
-import static org.forgerock.opendj.ldap.SearchScope.*;
-import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
-import static org.opends.server.TestCaseUtils.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.testng.Assert.*;
-
/** Tests the Historical class. */
@SuppressWarnings("javadoc")
public class HistoricalTest extends ReplicationTestCase
@@ -172,8 +172,8 @@
DN dn = DN.valueOf("uid=user.1," + TEST_ROOT_DN_STRING);
Entry entry = DirectoryServer.getEntry(dn);
- List<Attribute> attrs = EntryHistorical.getHistoricalAttr(entry);
- Attribute before = attrs.get(0);
+ Iterable<Attribute> attrs = EntryHistorical.getHistoricalAttr(entry);
+ Attribute before = attrs.iterator().next();
// Check that encoding and decoding preserves the history information.
EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
index 1712281..a4a3ba4 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -648,7 +648,9 @@
assertEquals(mod.getAttribute(), values3and4);
// check that the entry now contains value1 and value2 and no other values.
- Attribute resultEntryAttr = entry.getAllAttributes(DESCRIPTION).get(0);
+ Iterable<Attribute> attrs = entry.getAllAttributes(DESCRIPTION);
+ assertThat(attrs).hasSize(1);
+ Attribute resultEntryAttr = attrs.iterator().next();
assertEquals(resultEntryAttr, values1and2);
Attribute attr = buildSyncHist(DESCRIPTION,
@@ -1357,8 +1359,8 @@
assertEquals(hist.encodeAndPurge(), attr);
// The entry should have no value
- List<Attribute> attrs = entry.getAllAttributes(DESCRIPTION);
- assertEquals(attrs.get(0), Attributes.create(DESCRIPTION, "value2", "value3", "value4"));
+ Iterable<Attribute> attrs = entry.getAllAttributes(DESCRIPTION);
+ assertThat(attrs).containsOnly(Attributes.create(DESCRIPTION, "value2", "value3", "value4"));
}
/**
@@ -1404,8 +1406,8 @@
assertEquals(hist.encodeAndPurge(), attr);
// The entry should have no value
- List<Attribute> attrs = entry.getAllAttributes(DESCRIPTION);
- assertEquals(attrs.get(0), Attributes.create(DESCRIPTION, "value3", "value4"));
+ Iterable<Attribute> attrs = entry.getAllAttributes(DESCRIPTION);
+ assertThat(attrs).containsOnly(Attributes.create(DESCRIPTION, "value3", "value4"));
}
/**
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java
index e5179d4..f76fab4 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/LDAPSyntaxTest.java
@@ -16,6 +16,11 @@
*/
package org.opends.server.schema;
+import static org.assertj.core.api.Assertions.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.testng.Assert.*;
+
import java.util.ArrayList;
import java.util.List;
@@ -35,11 +40,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.*;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.testng.Assert.*;
-
/** Test the LDAPSyntaxDescriptionSyntax. */
@RemoveOnceSDKSchemaIsUsed
@SuppressWarnings("javadoc")
@@ -215,7 +215,7 @@
assertThat(entries).isNotEmpty();
SearchResultEntry e = entries.get(0);
assertNotNull(e);
- Attribute attr = e.getAllAttributes("ldapsyntaxes").get(0);
+ Attribute attr = e.getAllAttributes("ldapsyntaxes").iterator().next();
//There are other ways of doing it but we will extract the OID
//from the attribute values and then check to see if our
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java
index fa941cd..7fda1b9 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tools/makeldif/MakeLDIFTestCase.java
@@ -17,6 +17,10 @@
*/
package org.opends.server.tools.makeldif;
+import static org.assertj.core.api.Assertions.*;
+import static org.opends.messages.ToolMessages.*;
+import static org.testng.Assert.*;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,9 +43,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import static org.opends.messages.ToolMessages.*;
-import static org.testng.Assert.*;
-
/** A set of test cases for the MakeLDIF tool. */
@SuppressWarnings("javadoc")
public class MakeLDIFTestCase extends ToolsTestCase
@@ -316,9 +317,9 @@
Entry e = readEntry(outLdifFilePath);
assertNotNull(e);
- List<Attribute> attrs = e.getAllAttributes(attrName);
- assertFalse(attrs.isEmpty());
- Attribute a = attrs.get(0);
+ Iterable<Attribute> attrs = e.getAllAttributes(attrName);
+ assertThat(attrs).isNotEmpty();
+ Attribute a = attrs.iterator().next();
Attribute expectedRes = Attributes.create(attrName, expectedValue);
assertEquals(a, expectedRes);
}
@@ -365,9 +366,9 @@
Entry e = readEntry(outLdifFilePath);
assertNotNull(e);
- List<Attribute> attrs = e.getAllAttributes("cn");
- assertFalse(attrs.isEmpty());
- Attribute a = attrs.get(0);
+ Iterable<Attribute> attrs = e.getAllAttributes("cn");
+ assertThat(attrs).isNotEmpty();
+ Attribute a = attrs.iterator().next();
assertTrue(a.iterator().next().toString().matches("Foo <[A-Z]>\\{1\\}Bar"),
"cn value doesn't match the expected value");
}
--
Gitblit v1.10.0