@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();
        // TODO(razvanm): Pick some meaningful values.
        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());
        // The trim is used to remove a new line.
        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());
    }
}