Search in sources :

Example 1 with AltIdDbIndex

use of com.emc.storageos.db.client.impl.AltIdDbIndex in project coprhd-controller by CoprHD.

the class DbIndexTest method verify.

@Override
public void verify(Class<? extends DataObject> clazz, URI id, DbClient client) {
    // Get meta data about the object, field and index we're going to test
    DataObjectType doType = TypeMap.getDoType(clazz);
    ColumnField field = doType.getColumnField(fieldName);
    if (field == null) {
        throw new NullPointerException(String.format("Cannot find field %s from class %s", fieldName, clazz.getSimpleName()));
    }
    DbIndex index = field.getIndex();
    // Load object first
    DataObject obj = (DataObject) client.queryObject(clazz, id);
    // Get current value of indexed field
    Object val = null;
    try {
        val = field.getPropertyDescriptor().getReadMethod().invoke(obj);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Assert.fail("Cannot get field value");
    }
    boolean indexByKey = field.getPropertyDescriptor().getReadMethod().getAnnotation(IndexByKey.class) != null;
    // See which type the index is, and call corresponding verification functions
    if (index instanceof AltIdDbIndex) {
        verifyAltIdDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof RelationDbIndex) {
        verifyRelationDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof NamedRelationDbIndex) {
        verifyNamedRelationDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof PrefixDbIndex) {
        verifyPrefixDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof DecommissionedDbIndex) {
        verifyDecommissionedDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof PermissionsDbIndex) {
        verifyPermissionsDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof ScopedLabelDbIndex) {
        verifyScopedLabelDbIndex(obj, field, val, indexByKey, client);
    } else {
        System.out.printf("Unsupported index type %s%n", index.getClass().getSimpleName());
    }
}
Also used : AltIdDbIndex(com.emc.storageos.db.client.impl.AltIdDbIndex) PrefixDbIndex(com.emc.storageos.db.client.impl.PrefixDbIndex) DecommissionedDbIndex(com.emc.storageos.db.client.impl.DecommissionedDbIndex) ColumnField(com.emc.storageos.db.client.impl.ColumnField) ScopedLabelDbIndex(com.emc.storageos.db.client.impl.ScopedLabelDbIndex) NamedRelationDbIndex(com.emc.storageos.db.client.impl.NamedRelationDbIndex) AltIdDbIndex(com.emc.storageos.db.client.impl.AltIdDbIndex) RelationDbIndex(com.emc.storageos.db.client.impl.RelationDbIndex) PrefixDbIndex(com.emc.storageos.db.client.impl.PrefixDbIndex) DbIndex(com.emc.storageos.db.client.impl.DbIndex) DecommissionedDbIndex(com.emc.storageos.db.client.impl.DecommissionedDbIndex) PermissionsDbIndex(com.emc.storageos.db.client.impl.PermissionsDbIndex) InvocationTargetException(java.lang.reflect.InvocationTargetException) ScopedLabelDbIndex(com.emc.storageos.db.client.impl.ScopedLabelDbIndex) JsonObject(com.google.gson.JsonObject) PermissionsDbIndex(com.emc.storageos.db.client.impl.PermissionsDbIndex) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType) NamedRelationDbIndex(com.emc.storageos.db.client.impl.NamedRelationDbIndex) NamedRelationDbIndex(com.emc.storageos.db.client.impl.NamedRelationDbIndex) RelationDbIndex(com.emc.storageos.db.client.impl.RelationDbIndex)

Aggregations

AltIdDbIndex (com.emc.storageos.db.client.impl.AltIdDbIndex)1 ColumnField (com.emc.storageos.db.client.impl.ColumnField)1 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)1 DbIndex (com.emc.storageos.db.client.impl.DbIndex)1 DecommissionedDbIndex (com.emc.storageos.db.client.impl.DecommissionedDbIndex)1 NamedRelationDbIndex (com.emc.storageos.db.client.impl.NamedRelationDbIndex)1 PermissionsDbIndex (com.emc.storageos.db.client.impl.PermissionsDbIndex)1 PrefixDbIndex (com.emc.storageos.db.client.impl.PrefixDbIndex)1 RelationDbIndex (com.emc.storageos.db.client.impl.RelationDbIndex)1 ScopedLabelDbIndex (com.emc.storageos.db.client.impl.ScopedLabelDbIndex)1 JsonObject (com.google.gson.JsonObject)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1