Skip to content
Snippets Groups Projects
Commit fb95f711 authored by Felix Reichenbach's avatar Felix Reichenbach
Browse files

OZG-7837 rename repository method, add ITCases

parent aee61777
Branches
Tags
1 merge request!14Ozg 7837 mapping name as collection
...@@ -4,5 +4,5 @@ interface CustomWarehouseRepository { ...@@ -4,5 +4,5 @@ interface CustomWarehouseRepository {
DocumentEntry saveInCollection(DocumentEntry documentEntry, String collectionName); DocumentEntry saveInCollection(DocumentEntry documentEntry, String collectionName);
void deleteCollection(String collectionName); void clearCollection(String collectionName);
} }
...@@ -15,7 +15,7 @@ class CustomWarehouseRepositoryImpl implements CustomWarehouseRepository { ...@@ -15,7 +15,7 @@ class CustomWarehouseRepositoryImpl implements CustomWarehouseRepository {
} }
@Override @Override
public void deleteCollection(String collectionName) { public void clearCollection(String collectionName) {
mongoTemplate.dropCollection(collectionName); mongoTemplate.dropCollection(collectionName);
} }
......
...@@ -50,7 +50,7 @@ class CustomWarehouseRepositoryImplTest { ...@@ -50,7 +50,7 @@ class CustomWarehouseRepositoryImplTest {
@Test @Test
void shouldDropCollection() { void shouldDropCollection() {
repository.deleteCollection(collectionName); repository.clearCollection(collectionName);
verify(mongoTemplate).dropCollection(collectionName); verify(mongoTemplate).dropCollection(collectionName);
} }
......
...@@ -32,6 +32,8 @@ import org.junit.jupiter.api.Test; ...@@ -32,6 +32,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.MongoOperations;
import com.thedeanda.lorem.LoremIpsum;
import de.ozgcloud.common.test.DataITCase; import de.ozgcloud.common.test.DataITCase;
@DataITCase @DataITCase
...@@ -57,7 +59,33 @@ class WarehouseRepositoryITCase { ...@@ -57,7 +59,33 @@ class WarehouseRepositoryITCase {
var foundDocument = mongoOperations.findById(savedDocument.getId(), Document.class, DocumentEntry.COLLECTION); var foundDocument = mongoOperations.findById(savedDocument.getId(), Document.class, DocumentEntry.COLLECTION);
assertThat(foundDocument.getString("_class")).isEqualTo("Vorgang"); 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();
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment