Revision 34032
Added by Sandro La Bruzzo over 9 years ago
modules/cnr-mongo-mdstore/trunk/src/test/java/eu/dnetlib/data/mdstore/modular/mongodb/FeedSpeedTest.java | ||
---|---|---|
7 | 7 |
import java.util.UUID; |
8 | 8 |
|
9 | 9 |
import org.apache.commons.io.IOUtils; |
10 |
import org.apache.commons.lang.StringUtils; |
|
11 | 10 |
import org.junit.Ignore; |
12 | 11 |
import org.junit.Test; |
13 | 12 |
import org.junit.runner.RunWith; |
... | ... | |
16 | 15 |
import org.springframework.test.context.ContextConfiguration; |
17 | 16 |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
18 | 17 |
|
19 |
import com.mongodb.BasicDBList; |
|
20 | 18 |
import com.mongodb.DB; |
21 |
import com.mongodb.DBObject; |
|
22 |
import com.mongodb.QueryBuilder; |
|
23 | 19 |
|
24 | 20 |
import eu.dnetlib.data.mdstore.MDStoreServiceException; |
25 | 21 |
import eu.dnetlib.data.mdstore.modular.RecordParser; |
... | ... | |
103 | 99 |
|
104 | 100 |
@Ignore |
105 | 101 |
@Test |
106 |
public void testCollectionsNames() throws MDStoreServiceException { |
|
107 |
this.manager.garbage(); |
|
108 |
} |
|
109 |
|
|
110 |
private DBObject getMetadataObjectForCollections(final String collectionName) { |
|
111 |
if (collectionName == null) { return null; } |
|
112 |
final String postfix = "_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ=="; |
|
113 |
final String tmp = collectionName.contains("discarded-") == true ? StringUtils.substringAfter(collectionName, "discarded-") : collectionName; |
|
114 |
final String collectionNameCleaned = StringUtils.substringBefore(tmp, "::") + postfix; |
|
115 |
|
|
116 |
DBObject query = QueryBuilder.start("mdId").is(collectionNameCleaned).get(); |
|
117 |
return this.db.getCollection("metadataManager").findOne(query); |
|
118 |
} |
|
119 |
|
|
120 |
private boolean shouldDelete(final String collectionName, final DBObject metadataManagerInstance) { |
|
121 |
String currentId = (String) metadataManagerInstance.get("currentId"); |
|
122 |
if (collectionName.equals(currentId)) { return false; } |
|
123 |
BasicDBList expiringList = (BasicDBList) metadataManagerInstance.get("expiring"); |
|
124 |
if (findInList(expiringList, collectionName, "id") == true) { return false; } |
|
125 |
BasicDBList transactionsList = (BasicDBList) metadataManagerInstance.get("transactions"); |
|
126 |
if (findInList(transactionsList, collectionName, "id") == true) { return false; } |
|
127 |
return true; |
|
128 |
} |
|
129 |
|
|
130 |
private boolean findInList(final BasicDBList list, final String object, final String tagname) { |
|
131 |
if (list == null) { return false; } |
|
132 |
for (int i = 0; i < list.size(); i++) { |
|
133 |
DBObject currentObject = (DBObject) list.get(i); |
|
134 |
final String id = (String) currentObject.get(tagname); |
|
135 |
if (id.equals(object)) { return true; } |
|
136 |
} |
|
137 |
return false; |
|
138 |
} |
|
139 |
|
|
140 |
@Ignore |
|
141 |
@Test |
|
142 | 102 |
public void testFeedSpeedFromTemplate() throws MDStoreServiceException, IOException { |
143 | 103 |
MongoMDStore mdStore = new MongoMDStore(UUID.randomUUID().toString(), db.getCollection("speed_test"), recordParser, false); |
144 | 104 |
mdStore.feed(new Iterable<String>() { |
Also available in: Unified diff
fixed test