diff --git a/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepository.java b/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepository.java index da72066a636fd55fa9db24336b81ad6aec241a7f..b191dca31c37a63afb0bcda2f2dc13ecd4a58125 100644 --- a/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepository.java +++ b/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepository.java @@ -4,5 +4,5 @@ interface CustomWarehouseRepository { DocumentEntry saveInCollection(DocumentEntry documentEntry, String collectionName); - void deleteCollection(String collectionName); + void clearCollection(String collectionName); } diff --git a/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImpl.java b/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImpl.java index 6e331b6781dfcd5183f85d5b2d8f255c01d8dddc..7b6a1c09ad7c5d5cc15d30f531a6b4e031a59b19 100644 --- a/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImpl.java +++ b/src/main/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImpl.java @@ -15,7 +15,7 @@ class CustomWarehouseRepositoryImpl implements CustomWarehouseRepository { } @Override - public void deleteCollection(String collectionName) { + public void clearCollection(String collectionName) { mongoTemplate.dropCollection(collectionName); } diff --git a/src/test/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImplTest.java b/src/test/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImplTest.java index c7973307c588cc0cb9a0236ddb048c23e9558346..d3ea33cdd1f5ee322284fac11efb5377c9e459b0 100644 --- a/src/test/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImplTest.java +++ b/src/test/java/de/ozgcloud/aggregation/warehouse/CustomWarehouseRepositoryImplTest.java @@ -50,7 +50,7 @@ class CustomWarehouseRepositoryImplTest { @Test void shouldDropCollection() { - repository.deleteCollection(collectionName); + repository.clearCollection(collectionName); verify(mongoTemplate).dropCollection(collectionName); } diff --git a/src/test/java/de/ozgcloud/aggregation/warehouse/WarehouseRepositoryITCase.java b/src/test/java/de/ozgcloud/aggregation/warehouse/WarehouseRepositoryITCase.java index 18a3ab40118388b784fee2bfe17873ae5ec811d7..ad1c860d0f6006f1c13a5ca3cf5c349863bf136d 100644 --- a/src/test/java/de/ozgcloud/aggregation/warehouse/WarehouseRepositoryITCase.java +++ b/src/test/java/de/ozgcloud/aggregation/warehouse/WarehouseRepositoryITCase.java @@ -32,6 +32,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoOperations; +import com.thedeanda.lorem.LoremIpsum; + import de.ozgcloud.common.test.DataITCase; @DataITCase @@ -57,7 +59,33 @@ class WarehouseRepositoryITCase { var foundDocument = mongoOperations.findById(savedDocument.getId(), Document.class, DocumentEntry.COLLECTION); assertThat(foundDocument.getString("_class")).isEqualTo("Vorgang"); } + } + + @Nested + class TestSaveInCollection { + private final String collectionName = LoremIpsum.getInstance().getWords(1); + + @Test + void shouldSaveInCollection() { + repository.saveInCollection(DocumentEntryTestFactory.create(), collectionName); + + assertThat(mongoOperations.getCollection(collectionName).countDocuments()).isOne(); + } } + @Nested + class TestClearCollection { + + private final String collectionName = LoremIpsum.getInstance().getWords(1); + + @Test + void shouldClearCollection() { + mongoOperations.save(DocumentEntryTestFactory.create(), collectionName); + + repository.clearCollection(collectionName); + + assertThat(mongoOperations.getCollection(collectionName).countDocuments()).isZero(); + } + } }