Collection { public static native void Create(String name, String batchHandle, Permissions permissions) throws VError;  static native Permissions GetPermissions(String name, String batchHandle); static native void SetPermissions(String name, String batchHandle, Permissions permissions); static native void Create(String name, String batchHandle, Permissions permissions); static native void Destroy(String name, String batchHandle); static native boolean Exists(String name, String batchHandle); static native void DeleteRange(String name, String batchHandle, byte[] start, byte[] limit); static native void Scan(String name, String batchHandle, byte[] start, byte[] limit, ScanCallbacks callbacks);  }
@Test public void createCollection() { Id dbId = new Id("idp:a:angrybirds", "create_collection"); Id collectionId1 = new Id("...", "collection1"); Id collectionId2 = new Id("...", "collection2"); try { Database.Create(dbId.encode(), anyDbPermissions()); String batchHandle = Database.BeginBatch(dbId.encode(), null); String name1 = Util.NamingJoin(Arrays.asList(dbId.encode(), collectionId1.encode())); Collection.Create(name1, batchHandle, anyCollectionPermissions()); String name2 = Util.NamingJoin(Arrays.asList(dbId.encode(), collectionId2.encode())); Collection.Create(name2, batchHandle, anyCollectionPermissions()); List<Id> collections = Database.ListCollections(dbId.encode(), batchHandle); assertNotNull(collections); assertEquals(2, collections.size()); assertEquals(collectionId1.encode(), collections.get(0).encode()); assertEquals(collectionId2.encode(), collections.get(1).encode()); } catch (VError vError) { vError.printStackTrace(); fail(vError.toString()); } }