use of com.emc.storageos.db.client.impl.DecommissionedDbIndex 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());
}
}
Aggregations