use of com.emc.storageos.db.client.constraint.impl.ContainmentPermissionsConstraintImpl in project coprhd-controller by CoprHD.
the class DbIndexTest method verifyPermissionsDbIndex.
private void verifyPermissionsDbIndex(DataObject obj, ColumnField field, Object val, boolean indexByKey, DbClient client) {
switch(field.getType()) {
case TrackingSetMap:
for (String key : ((AbstractChangeTrackingSetMap<String>) val).keySet()) {
ContainmentPermissionsConstraintImpl constraint = new ContainmentPermissionsConstraintImpl(key, field, obj.getClass());
NamedElementQueryResultList results = new NamedElementQueryResultList();
client.queryByConstraint(constraint, results);
HashSet<String> setFromIndex = new HashSet<String>();
for (NamedElementQueryResultList.NamedElement elem : results) {
if (elem.getId().equals(obj.getId())) {
setFromIndex.add(elem.getName());
}
}
AbstractChangeTrackingSet<String> values = ((AbstractChangeTrackingSetMap<String>) val).get(key);
assertTrue("The value set from index is not same as what is currently in object", setFromIndex.equals(values));
}
break;
case Id:
case NamedURI:
case NestedObject:
case Primitive:
case TrackingMap:
case TrackingSet:
default:
throw new IllegalArgumentException(String.format("Field type %s is not supported by PermissionsDbIndex", field.getType().toString()));
}
}
Aggregations