Syncgroup { public void create(SyncgroupSpec spec, SyncgroupMemberInfo info) throws VError { io.v.syncbase.internal.Database.CreateSyncgroup(dbFullName, id, spec, info); } Syncgroup(Database database, Id id); Id getId(); void create(SyncgroupSpec spec, SyncgroupMemberInfo info); SyncgroupSpec join(String remoteSyncbaseName, List<String> expectedSyncbaseBlessings,
                              SyncgroupMemberInfo info); void leave(); void destroy(); void eject(String member); VersionedSyncgroupSpec getSpec(); void setSpec(VersionedSyncgroupSpec spec); Map<String, SyncgroupMemberInfo> getMembers();  }
@Test public void create() { Id dbId = new Id("idp:a:angrybirds", "core_create_syncgroups"); Id sgId = new Id("...", "syncgroup"); Id collectionId = new Id("...", "collection"); try { Database db = Service.database(dbId); db.create(anyDbPermissions()); db.collection(collectionId).create(anyCollectionPermissions()); SyncgroupSpec spec = new SyncgroupSpec(); spec.collections = singletonList(collectionId); spec.permissions = anySyncgroupPermissions(); SyncgroupMemberInfo info = new SyncgroupMemberInfo(); info.syncPriority = 1; info.blobDevType = 2; Syncgroup syncgroup = db.syncgroup(sgId); syncgroup.create(spec, info); List<Id> syncgroups = db.listSyncgroups(); assertEquals(1, syncgroups.size()); Id actual = syncgroups.get(0); assertEquals(sgId.blessing, actual.blessing); assertEquals(sgId.name, actual.name); VersionedSyncgroupSpec verSpec = syncgroup.getSpec(); assertNotNull(verSpec.version); assertTrue(verSpec.version.length() > 0); assertNotNull(verSpec.syncgroupSpec); assertEquals(1, verSpec.syncgroupSpec.collections.size()); assertEquals( new String(spec.permissions.json), new String(verSpec.syncgroupSpec.permissions.json).trim()); actual = syncgroups.get(0); assertEquals(sgId.blessing, actual.blessing); assertEquals(sgId.name, actual.name); verSpec.syncgroupSpec.description = "Dummy description"; syncgroup.setSpec(verSpec); assertEquals( verSpec.syncgroupSpec.description, syncgroup.getSpec().syncgroupSpec.description); Map<String, SyncgroupMemberInfo> members = syncgroup.getMembers(); assertNotNull(members); assertEquals(1, members.size()); assertTrue(members.keySet().iterator().next().length() > 0); assertEquals(info.syncPriority, members.values().iterator().next().syncPriority); assertEquals(info.blobDevType, members.values().iterator().next().blobDevType); } catch (VError vError) { vError.printStackTrace(); fail(vError.toString()); } }