2020import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
2121import java .util .concurrent .CompletableFuture ;
2222import java .util .concurrent .CountDownLatch ;
23- import java .util .concurrent .ExecutionException ;
2423import java .util .concurrent .TimeUnit ;
2524import java .util .function .Consumer ;
2625import org .bson .BsonDocument ;
@@ -125,13 +124,12 @@ public MongoCollection<Document> setupInsert(String dbName, String collectionNam
125124 }
126125
127126 @ Override
128- public long insert (MongoCollection <Document > collection )
129- throws ExecutionException , InterruptedException {
127+ public long insert (MongoCollection <Document > collection ) {
130128 CompletableFuture <Long > count = new CompletableFuture <>();
131129 collection .insertOne (
132130 new Document ("password" , "SECRET" ),
133131 toCallback (result -> collection .count (toCallback (o -> count .complete (((Long ) o ))))));
134- return count .get ();
132+ return count .join ();
135133 }
136134
137135 @ Override
@@ -158,8 +156,7 @@ public MongoCollection<Document> setupUpdate(String dbName, String collectionNam
158156 }
159157
160158 @ Override
161- public long update (MongoCollection <Document > collection )
162- throws ExecutionException , InterruptedException {
159+ public long update (MongoCollection <Document > collection ) {
163160 CompletableFuture <UpdateResult > result = new CompletableFuture <>();
164161 CompletableFuture <Long > count = new CompletableFuture <>();
165162 collection .updateOne (
@@ -170,7 +167,7 @@ public long update(MongoCollection<Document> collection)
170167 result .complete (((UpdateResult ) res ));
171168 collection .count (toCallback (o -> count .complete (((Long ) o ))));
172169 }));
173- return result .get ().getModifiedCount ();
170+ return result .join ().getModifiedCount ();
174171 }
175172
176173 @ Override
@@ -197,8 +194,7 @@ public MongoCollection<Document> setupDelete(String dbName, String collectionNam
197194 }
198195
199196 @ Override
200- public long delete (MongoCollection <Document > collection )
201- throws ExecutionException , InterruptedException {
197+ public long delete (MongoCollection <Document > collection ) {
202198 CompletableFuture <DeleteResult > result = new CompletableFuture <>();
203199 CompletableFuture <Long > count = new CompletableFuture <>();
204200 collection .deleteOne (
@@ -208,7 +204,7 @@ public long delete(MongoCollection<Document> collection)
208204 result .complete ((DeleteResult ) res );
209205 collection .count (toCallback (value -> count .complete (((Long ) value ))));
210206 }));
211- return result .get ().getDeletedCount ();
207+ return result .join ().getDeletedCount ();
212208 }
213209
214210 @ Override
0 commit comments