use of com.emc.storageos.db.client.constraint.Constraint in project coprhd-controller by CoprHD.
the class DbClientTest method testAlternateIdPaginateConstraint.
@Test
public void testAlternateIdPaginateConstraint() throws Exception {
int objCount = 10;
List<VirtualPool> vpools = createVirtualPools(10, "GOLD", VirtualPool.Type.file);
Constraint constraint = AlternateIdConstraint.Factory.getVpoolTypeVpoolConstraint(VirtualPool.Type.file);
queryInPaginate(constraint, URIQueryResultList.class, objCount, pageSize);
}
use of com.emc.storageos.db.client.constraint.Constraint in project coprhd-controller by CoprHD.
the class DbIndexTest method testPermissionIndex.
@Test
public void testPermissionIndex() {
URI id = URIUtil.createId(TenantOrg.class);
String key0 = "abcd1234";
String key1 = "efgh5678";
Constraint constraint0 = ContainmentPermissionsConstraint.Factory.getTenantsWithPermissionsConstraint(key0);
Constraint constraint1 = ContainmentPermissionsConstraint.Factory.getTenantsWithPermissionsConstraint(key1);
{
TenantOrg obj = new TenantOrg();
obj.setId(id);
// obj.setLabel("test tenant");
obj.setRoleAssignments(new StringSetMap());
obj.addRole(key0, "role1");
obj.addRole(key0, "role2");
_dbClient.createObject(obj);
}
verifyContain(constraint0, id, 2);
verifyContain(constraint1, null, 0);
{
TenantOrg obj = _dbClient.queryObject(TenantOrg.class, id);
obj.addRole(key1, "role3");
_dbClient.persistObject(obj);
}
verifyContain(constraint0, id, 2);
verifyContain(constraint1, id, 1);
{
TenantOrg obj = _dbClient.queryObject(TenantOrg.class, id);
obj.removeRole(key0, "role1");
_dbClient.persistObject(obj);
}
verifyContain(constraint0, id, 1);
verifyContain(constraint1, id, 1);
{
TenantOrg obj = _dbClient.queryObject(TenantOrg.class, id);
obj.removeRole(key0, "role2");
_dbClient.persistObject(obj);
}
verifyContain(constraint1, id, 1);
verifyContain(constraint0, null, 0);
}
use of com.emc.storageos.db.client.constraint.Constraint in project coprhd-controller by CoprHD.
the class DbIndexTest method verifyContain.
private void verifyContain(Constraint c, URI uri, int count, DbClient client) {
URIQueryResultList list = new URIQueryResultList();
client.queryByConstraint(c, list);
int realCount = 0;
boolean found = false;
for (URI elem : list) {
realCount++;
if (uri != null && uri.equals(elem)) {
found = true;
}
}
if (uri != null) {
assertTrue(found);
}
if (count >= 0) {
assertTrue(String.format("Found %d URIs while %d is expected", realCount, count), realCount == count);
}
}
use of com.emc.storageos.db.client.constraint.Constraint in project coprhd-controller by CoprHD.
the class DbIndexTest method verifyContain.
private void verifyContain(Constraint c, URI uri, int count) {
URIQueryResultList list = new URIQueryResultList();
_dbClient.queryByConstraint(c, list);
int realCount = 0;
boolean found = false;
for (URI elem : list) {
realCount++;
if (uri != null && uri.equals(elem)) {
found = true;
}
}
if (uri != null) {
assertTrue(found);
}
if (count >= 0) {
assertTrue(String.format("Found %d URIs while %d is expected", realCount, count), realCount == count);
}
}
use of com.emc.storageos.db.client.constraint.Constraint in project coprhd-controller by CoprHD.
the class DbIndexTest method testInactive.
@Test
public void testInactive() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
// We're going to need synchronize between threads calling into DbClient
this._dbClient.threadStepLock = new ThreadLocal<DbClientTest.StepLock>();
URI vol1Uri = URIUtil.createId(Volume.class);
URI varr1Uri = URIUtil.createId(VirtualArray.class);
IndexTestData[] tests = new IndexTestData[] { new IndexTestData("Test inactive with other index", Volume.class, // Initial state
new Object[] { "personality=", "abc" }, new Object[][] { new Object[] { "inactive=", true }, new Object[] { "personality=", "ghi" } }, new IndexVerifier() {
@Override
public void verify(Class<? extends DataObject> clazz, URI id, DbClient client) {
Volume vol = (Volume) client.queryObject(clazz, id);
String per = vol.getPersonality();
DataObjectType doType = TypeMap.getDoType(clazz);
AlternateIdConstraint constraint = new AlternateIdConstraintImpl(doType.getColumnField("personality"), per);
URIQueryResultList list = new URIQueryResultList();
client.queryByConstraint(constraint, list);
for (URI elem : list) {
assertTrue("The index of .personality should be removed", !elem.equals(id));
}
}
}) };
for (int i = 0; i < tests.length; i++) {
testRaceCondition(tests[i]);
}
}
Aggregations