Added test and facilities

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@124263 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-02-17 15:36:37 +00:00
parent 365f19d8f2
commit 594c09aa96
3 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,53 @@
/**
*
*/
package org.gcube.accounting.analytics.persistence.couchdb;
import org.codehaus.jackson.JsonNode;
import org.ektorp.DocumentNotFoundException;
import org.ektorp.ViewQuery;
import org.ektorp.ViewResult;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration;
import org.gcube.testutility.ScopedTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class DeleteTestDocument extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(DeleteTestDocument.class);
//@Test
public void removeTestRecords() throws Exception {
AccountingPersistenceBackendQueryConfiguration persitenceConfiguration = new AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class);
AccountingPersistenceQueryCouchDB accountingPersistenceQueryCouchDB = new AccountingPersistenceQueryCouchDB();
accountingPersistenceQueryCouchDB.prepareConnection(persitenceConfiguration);
ViewQuery query = new ViewQuery().designDocId("_design/TestRecords");
query = query.viewName("testRecords");
query = query.includeDocs(true);
ViewResult viewResult;
try {
viewResult = accountingPersistenceQueryCouchDB.query(query);
} catch (DocumentNotFoundException e) {
// Install VIEW if valid and does not exist
throw e;
}
for (ViewResult.Row row : viewResult) {
String key = row.getKey();
JsonNode node = row.getValueAsNode();
logger.debug("Going to delete {}", node);
String rev = node.get("_rev").asText();
//accountingPersistenceQueryCouchDB.couchDbConnector.delete(key, rev);
}
}
}

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.accounting.couchdb.query;
package org.gcube.accounting.datamodel.usagerecords;
import java.util.concurrent.TimeUnit;

View File

@ -18,6 +18,7 @@ public class ScopedTest {
public void before() throws Exception{
//SecurityTokenProvider.instance.set(TestUtility.TOKEN);
ScopeProvider.instance.set("/gcube/devsec");
ScopeProvider.instance.set("/gcube/devNext");
}
@After