From bfad628d93ca42994aae3d0a4ecd3c9d2aef81a3 Mon Sep 17 00:00:00 2001 From: Thomas Rausch Date: Sun, 1 Apr 2018 17:41:35 +0200 Subject: [PATCH] Make Ass1_4_3_01Test tolerant towards existing collections --- .../src/test/java/dst/ass1/doc/tests/Ass1_4_3_01Test.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ass1-doc/src/test/java/dst/ass1/doc/tests/Ass1_4_3_01Test.java b/ass1-doc/src/test/java/dst/ass1/doc/tests/Ass1_4_3_01Test.java index dab7867..43cc167 100644 --- a/ass1-doc/src/test/java/dst/ass1/doc/tests/Ass1_4_3_01Test.java +++ b/ass1-doc/src/test/java/dst/ass1/doc/tests/Ass1_4_3_01Test.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.List; +import java.util.stream.StreamSupport; import org.bson.Document; import org.junit.ClassRule; @@ -21,7 +22,12 @@ public class Ass1_4_3_01Test { @Rule public MongoService mongo = new MongoService(db -> { - db.createCollection(Constants.COLL_MATERIAL_DATA); // make sure the empty collection exists + boolean exists = StreamSupport.stream(db.listCollectionNames().spliterator(), false) + .anyMatch(Constants.COLL_MATERIAL_DATA::equalsIgnoreCase); + + if (!exists) { + db.createCollection(Constants.COLL_MATERIAL_DATA); // make sure the empty collection exists + } }); @Test -- 2.43.0