Skip to content

Commit 44e285c

Browse files
author
Mark
committed
added ArangoCollection.drop(isSystem)
1 parent 6bfa812 commit 44e285c

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

src/main/java/com/arangodb/ArangoCollectionAsync.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,21 @@ public CompletableFuture<CollectionPropertiesEntity> count() {
651651
* @return void
652652
*/
653653
public CompletableFuture<Void> drop() {
654-
return executor.execute(dropRequest(), Void.class);
654+
return executor.execute(dropRequest(null), Void.class);
655+
}
656+
657+
/**
658+
* Drops the collection
659+
*
660+
* @see <a href="https://docs.arangodb.com/current/HTTP/Collection/Creating.html#drops-collection">API
661+
* Documentation</a>
662+
* @param isSystem
663+
* Whether or not the collection to drop is a system collection. This parameter must be set to true in
664+
* order to drop a system collection.
665+
* @return void
666+
*/
667+
public CompletableFuture<Void> drop(final boolean isSystem) {
668+
return executor.execute(dropRequest(isSystem), Void.class);
655669
}
656670

657671
/**

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,35 @@ public void deleteCollection() throws InterruptedException, ExecutionException {
107107
}
108108
}
109109

110+
@Test
111+
public void deleteSystemCollection() throws InterruptedException, ExecutionException {
112+
final String name = "_system_test";
113+
db.createCollection(name, new CollectionCreateOptions().isSystem(true)).get();
114+
db.collection(name).drop(true).get();
115+
try {
116+
db.collection(name).getInfo().get();
117+
fail();
118+
} catch (final ArangoDBException e) {
119+
}
120+
}
121+
122+
@Test
123+
public void deleteSystemCollectionFail() throws InterruptedException, ExecutionException {
124+
final String name = "_system_test";
125+
db.createCollection(name, new CollectionCreateOptions().isSystem(true)).get();
126+
try {
127+
db.collection(name).drop().get();
128+
fail();
129+
} catch (final ArangoDBException e) {
130+
}
131+
db.collection(name).drop(true).get();
132+
try {
133+
db.collection(name).getInfo().get();
134+
fail();
135+
} catch (final ArangoDBException e) {
136+
}
137+
}
138+
110139
@Test
111140
public void getIndex() throws InterruptedException, ExecutionException {
112141
try {

0 commit comments

Comments
 (0)