@Test
public void exists() {

    Id dbId = new Id("idp:a:angrybirds", "core_exists_collection");
    Id collectionId1 = new Id("...", "collection1");
    Id collectionId2 = new Id("...", "collection2");
    try {
        Database db = Service.database(dbId);
        db.create(anyDbPermissions());
        BatchDatabase batchDb = db.beginBatch(null);
        Collection collection1 = batchDb.collection(collectionId1);
        collection1.create(anyCollectionPermissions());
        // We have not committed the batch yet so exists() should fail.
        assertFalse(db.collection(collectionId1).exists());
        // But from the point of view of the batch, collection1 does exist.
        assertTrue(collection1.exists());
        batchDb.commit();
        assertTrue(db.collection(collectionId1).exists());
        assertFalse(db.collection(collectionId2).exists());
    } catch (VError vError) {
        vError.printStackTrace();
        fail(vError.toString());
    }
}