Skip to content

Commit b52246e

Browse files
committed
test(discovery-v1): clean collections
1 parent 687c661 commit b52246e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,26 @@ public void cleanup() {
178178
"deleteConfiguration failed. Configuration " + configurationId + " not found");
179179
}
180180
}
181+
182+
ListCollectionsOptions listCollectionsOptions = new ListCollectionsOptions.Builder()
183+
.environmentId(environmentId)
184+
.build();
185+
ListCollectionsResponse response = discovery.listCollections(listCollectionsOptions).execute().getResult();
186+
for(Collection collection: response.getCollections()){
187+
if(collection.getName().matches("java-sdk-.*collection") ||
188+
collection.getName().matches("my_watson_developer_cloud_collection.*") ||
189+
collection.getName().matches("tokenization-dict-testing-collection.*")) {
190+
DeleteCollectionOptions deleteCollectionOptions = new DeleteCollectionOptions.Builder()
191+
.collectionId(collection.getCollectionId())
192+
.environmentId(environmentId)
193+
.build();
194+
try {
195+
DeleteCollectionResponse deleteCollectionResponse = discovery.deleteCollection(deleteCollectionOptions).execute().getResult();
196+
} catch (NotFoundException ex) {
197+
System.out.println("deleteCollection failed. Collection " + collectionId + " not found");
198+
}
199+
}
200+
}
181201
}
182202

183203
/**

0 commit comments

Comments
 (0)