1
|
package eu.dnetlib.data.mdstore;
|
2
|
|
3
|
import java.util.UUID;
|
4
|
|
5
|
import com.mongodb.client.MongoCollection;
|
6
|
import com.mongodb.client.MongoDatabase;
|
7
|
import org.apache.commons.logging.Log;
|
8
|
import org.apache.commons.logging.LogFactory;
|
9
|
import org.bson.Document;
|
10
|
import org.junit.runner.RunWith;
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.boot.test.context.SpringBootTest;
|
13
|
import org.springframework.test.context.ActiveProfiles;
|
14
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
15
|
|
16
|
/**
|
17
|
* Created by claudio on 22/03/2017.
|
18
|
*/
|
19
|
@ActiveProfiles("mdstoreTest")
|
20
|
@RunWith(SpringJUnit4ClassRunner.class)
|
21
|
@SpringBootTest(classes = { EmbeddedMongodbConfiguration.class, TestMocks.class })
|
22
|
public abstract class AbstractMDStoreTest {
|
23
|
|
24
|
protected static final Log log = LogFactory.getLog(AbstractMDStoreTest.class);
|
25
|
|
26
|
@Autowired
|
27
|
protected MongoDatabase mongoDatabase;
|
28
|
|
29
|
protected <T> MongoCollection<T> getCollection(final String name, final Class<T> clazz) {
|
30
|
return mongoDatabase.getCollection(name, clazz);
|
31
|
}
|
32
|
|
33
|
protected MongoCollection<Document> getCollection(final String name) {
|
34
|
return mongoDatabase.getCollection(name);
|
35
|
}
|
36
|
|
37
|
protected String mockMDID() {
|
38
|
return UUID.randomUUID().toString();
|
39
|
}
|
40
|
|
41
|
}
|