use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class DbClientTest method testStringSetMap.
@Test
public void testStringSetMap() throws Exception {
_logger.info("Starting StringSetMap test");
DbClient dbClient = _dbClient;
TenantOrg tenant = new TenantOrg();
tenant.setId(URIUtil.createId(TenantOrg.class));
StringSetMap sMap = new StringSetMap();
tenant.setUserMappings(sMap);
StringSet set = new StringSet();
set.add("test1");
sMap.put("key1", set);
sMap.get("key1").add("test2");
sMap.get("key1").remove("test1");
dbClient.persistObject(tenant);
// record pending
tenant = dbClient.queryObject(TenantOrg.class, tenant.getId());
sMap = tenant.getUserMappings();
set = sMap.get("key1");
Assert.assertEquals(set.size(), 1);
Assert.assertEquals(set.contains("test2"), true);
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class DbClientTest method createTenants.
private List<TenantOrg> createTenants(int count, String label, String indexKey) {
List<TenantOrg> tenants = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
TenantOrg t = new TenantOrg();
t.setId(URIUtil.createId(TenantOrg.class));
t.setLabel(label);
t.setRoleAssignments(new StringSetMap());
t.addRole(indexKey, "role1");
t.addRole(indexKey, "role2");
_dbClient.createObject(t);
tenants.add(t);
}
return tenants;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class DbClientTest method testStringSetMapClear.
@Test
public void testStringSetMapClear() throws Exception {
// shows behavior of AbstractChangeTrackingMapSet.clear()
_logger.info("Starting StringSetMap3 test");
DbClient dbClient = _dbClient;
ProtectionSystem ps = new ProtectionSystem();
ps.setId(URIUtil.createId(ProtectionSystem.class));
StringSet set1 = new StringSet();
set1.add("test1");
set1.add("test2");
set1.add("test3");
set1.add("test4");
StringSet set2 = new StringSet();
set2.add("test5");
set2.add("test6");
set2.add("test7");
set2.add("test8");
String key1 = "key1";
String key2 = "key2";
StringSetMap sMap = new StringSetMap();
sMap.put(key1, set1);
sMap.put(key2, set2);
ps.setSiteInitiators(sMap);
dbClient.createObject(ps);
ProtectionSystem ps1 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
StringSet set3 = new StringSet();
set3.add("test9");
set3.add("test10");
set3.add("test11");
set3.add("test12");
StringSet set4 = new StringSet();
set4.add("test13");
set4.add("test14");
set4.add("test15");
set4.add("test16");
String key4 = "key4";
String key3 = "key3";
StringSetMap sMap2 = new StringSetMap();
sMap2.put(key3, set3);
sMap2.put(key4, set4);
ps1.getSiteInitiators().clear();
ps1.getSiteInitiators().putAll(sMap2);
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key1));
Assert.assertTrue(ps1.getSiteInitiators().get(key1).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps1.getSiteInitiators().get(key2).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps1.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps1.getSiteInitiators().get(key4).isEmpty());
dbClient.persistObject(ps1);
ProtectionSystem ps2 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key1));
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps2.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps2.getSiteInitiators().get(key4).isEmpty());
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class RemoteReplicationSet method addSystemRole.
public void addSystemRole(String systemName, String role) {
if (this.systemToRolesMap == null) {
this.systemToRolesMap = new StringSetMap();
}
if (this.systemToRolesMap.get(systemName) == null) {
addSystemRolesEntry(systemName, new StringSet());
}
StringSet roles = this.systemToRolesMap.get(systemName);
roles.add(role);
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupUtils method getLocalSystemsInCG.
/**
* Gets the storage system(s) containing the native CGs corresponding to the
* passed VPLEX CG.
*
* @param cg A reference to a VPLEX CG
* @param dbClient A reference to a database client
*
* @return A list of the the storage system(s) containing the native CGs
* corresponding to the passed VPLEX CG.
*/
public static List<URI> getLocalSystemsInCG(BlockConsistencyGroup cg, DbClient dbClient) {
List<URI> localSystemUris = new ArrayList<URI>();
StringSetMap systemCgMap = cg.getSystemConsistencyGroups();
if (systemCgMap != null) {
Iterator<String> cgSystemIdsIter = cg.getSystemConsistencyGroups().keySet().iterator();
while (cgSystemIdsIter.hasNext()) {
URI cgSystemUri = URI.create(cgSystemIdsIter.next());
if (URIUtil.isType(cgSystemUri, StorageSystem.class)) {
StorageSystem cgSystem = dbClient.queryObject(StorageSystem.class, cgSystemUri);
// isBlockStorageSystem
if (Type.isBlockStorageSystem(cgSystem.getSystemType())) {
localSystemUris.add(cgSystemUri);
}
}
}
}
return localSystemUris;
}
Aggregations