use of org.opends.server.types.Attribute in project midpoint by Evolveum.
the class OpenDJController method assertNoAttribute.
public static void assertNoAttribute(Entry response, String name) {
List<Attribute> attrs = response.getAttribute(name.toLowerCase());
if (attrs == null || attrs.size() == 0) {
return;
}
assertEquals("Too many \"attributes\" for " + name + ": ", 1, attrs.size());
Attribute attribute = response.getAttribute(name.toLowerCase()).get(0);
if (attribute.size() == 0) {
return;
}
if (attribute.isEmpty()) {
return;
}
AssertJUnit.fail("Attribute " + name + " exists while not expecting it: " + attribute);
}
use of org.opends.server.types.Attribute in project midpoint by Evolveum.
the class OpenDJController method assertAttribute.
public static void assertAttribute(Entry response, String name, String... values) {
List<Attribute> attrs = response.getAttribute(name.toLowerCase());
if (attrs == null || attrs.size() == 0) {
if (values.length == 0) {
return;
} else {
AssertJUnit.fail("Attribute " + name + " does not have any value");
}
}
assertEquals("Too many \"attributes\" for " + name + ": ", 1, attrs.size());
Attribute attribute = response.getAttribute(name.toLowerCase()).get(0);
if (values.length != attribute.size()) {
AssertJUnit.fail("Wrong number of values for attribute " + name + ", expected " + values.length + " values but got " + attribute.size() + " values: " + attribute);
}
for (String value : values) {
boolean found = false;
Iterator<AttributeValue> iterator = attribute.iterator();
List<String> attrVals = new ArrayList<String>();
while (iterator.hasNext()) {
AttributeValue attributeValue = iterator.next();
String attrVal = attributeValue.toString();
attrVals.add(attrVal);
if (attrVal.equals(value)) {
found = true;
}
}
if (!found) {
AssertJUnit.fail("Attribute " + name + " does not contain value " + value + ", it has values: " + attrVals);
}
}
}
use of org.opends.server.types.Attribute in project midpoint by Evolveum.
the class OpenDJController method getAttributeValue.
public static String getAttributeValue(Entry response, String name) {
List<Attribute> attrs = response.getAttribute(name.toLowerCase());
if (attrs == null || attrs.size() == 0) {
return null;
}
assertEquals("Too many attributes for name " + name + ": ", 1, attrs.size());
Attribute attribute = attrs.get(0);
return getAttributeValue(attribute);
}
use of org.opends.server.types.Attribute in project OpenAM by OpenRock.
the class EmbeddedSearchResultIterator method convertLDAPAttributeSetToMap.
static Map<String, Set<String>> convertLDAPAttributeSetToMap(List<Attribute> attributes) {
Map<String, Set<String>> answer = null;
if (CollectionUtils.isNotEmpty(attributes)) {
for (Attribute attr : attributes) {
if (attr != null) {
Set<String> strValues = new HashSet<>();
for (ByteString anAttr : attr) {
strValues.add(anAttr.toString());
}
if (answer == null) {
answer = new CaseInsensitiveHashMap<>(10);
}
answer.put(attr.getName(), strValues);
}
}
}
return (answer);
}
use of org.opends.server.types.Attribute in project midpoint by Evolveum.
the class TestQuartzTaskManagerContract method assertAttribute.
protected void assertAttribute(SearchResultEntry response, String name, String value) {
AssertJUnit.assertNotNull(response.getAttribute(name.toLowerCase()));
AssertJUnit.assertEquals(1, response.getAttribute(name.toLowerCase()).size());
Attribute attribute = response.getAttribute(name.toLowerCase()).get(0);
AssertJUnit.assertEquals(value, attribute.iterator().next().getValue().toString());
}
Aggregations