DeleteAllOperation implements MongoDbOperation { @Override public void execute(final MongoDatabase connection, final Document data) { for (final String collectionName : data.keySet()) { final MongoCollection<Document> collection = connection.getCollection(collectionName); collection.deleteMany(new Document()); } }  @Override void execute(final MongoDatabase connection, final Document data);  }
@Test public void testOperationExecution() { final Document data = new Document().append(USER_DEFINED_COLLECTION_NAME_1, Arrays.asList(new Document())) .append(USER_DEFINED_COLLECTION_NAME_2, Arrays.asList(new Document())); operation.execute(connection, data); final ArgumentCaptor<String> collectionNameCaptor = ArgumentCaptor.forClass(String.class); verify(connection, times(2)).getCollection(collectionNameCaptor.capture()); final List<String> capturedCollectionNames = collectionNameCaptor.getAllValues(); assertThat(capturedCollectionNames.size(), equalTo(2)); assertThat(capturedCollectionNames, hasItems(USER_DEFINED_COLLECTION_NAME_1, USER_DEFINED_COLLECTION_NAME_2)); verify(collection, times(2)).deleteMany(eq(new Document())); }