Search in sources :

Example 1 with ContainmentPermissionsConstraintImpl

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()));
    }
}
Also used : ContainmentPermissionsConstraintImpl(com.emc.storageos.db.client.constraint.impl.ContainmentPermissionsConstraintImpl) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) HashSet(java.util.HashSet)

Aggregations

NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 ContainmentPermissionsConstraintImpl (com.emc.storageos.db.client.constraint.impl.ContainmentPermissionsConstraintImpl)1 HashSet (java.util.HashSet)1