Fixing tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@126316 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-03-25 18:18:56 +00:00
parent d037d92c42
commit 3cf5d338ec
2 changed files with 23 additions and 13 deletions

View File

@ -82,14 +82,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics-persistence-couchbase</artifactId> <artifactId>accounting-analytics-persistence-couchbase</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version> <version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
-->
<dependency> <dependency>
<groupId>org.gcube.vremanagement</groupId> <groupId>org.gcube.vremanagement</groupId>

View File

@ -7,11 +7,15 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedSet;
import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode; import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.testutility.ScopedTest; import org.gcube.testutility.ScopedTest;
import org.json.JSONObject; import org.json.JSONObject;
import org.junit.Before; import org.junit.Before;
@ -27,7 +31,7 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(AccountingPersistenceQueryCouchBaseTest.class); private static Logger logger = LoggerFactory.getLogger(AccountingPersistenceQueryCouchBaseTest.class);
//protected AccountingPersistenceQueryCouchBase accountingPersistenceQueryCouchBase; protected AccountingPersistenceQueryCouchBase accountingPersistenceQueryCouchBase;
public class ExtendedInfo extends Info { public class ExtendedInfo extends Info {
@ -63,12 +67,10 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
@Before @Before
public void before() throws Exception{ public void before() throws Exception{
super.before(); super.before();
/*
AccountingPersistenceBackendQueryConfiguration configuration = new AccountingPersistenceBackendQueryConfiguration configuration = new
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class); AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class);
accountingPersistenceQueryCouchBase = new AccountingPersistenceQueryCouchBase(); accountingPersistenceQueryCouchBase = new AccountingPersistenceQueryCouchBase();
accountingPersistenceQueryCouchBase.prepareConnection(configuration); accountingPersistenceQueryCouchBase.prepareConnection(configuration);
*/
} }
@ -81,18 +83,27 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
Calendar startTime = Calendar.getInstance(); Calendar startTime = Calendar.getInstance();
startTime.set(2015, Calendar.SEPTEMBER, 9); startTime.set(2016, Calendar.JANUARY, 1);
Calendar endTime = Calendar.getInstance(); Calendar endTime = Calendar.getInstance();
endTime.set(2016, Calendar.OCTOBER, 16);
List<Filter> filters = new ArrayList<Filter>(); List<Filter> filters = new ArrayList<Filter>();
Filter filter = new Filter("consumerId", "gianpaolo.coro");
Filter filter =
new Filter(AggregatedStorageUsageRecord.CONSUMER_ID, "gianpaolo.coro");
filters.add(filter); filters.add(filter);
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(), endTime.getTimeInMillis(), AggregationMode.DAILY);
/* TemporalConstraint temporalConstraint =
Map<Calendar, Info> infos = accountingPersistenceQueryCouchBase.query(AggregatedStorageUsageRecord.class, temporalConstraint, filters); new TemporalConstraint(startTime.getTimeInMillis(),
endTime.getTimeInMillis(), AggregationMode.DAILY);
printMap(infos); Class<AggregatedStorageUsageRecord> clz =
*/ AggregatedStorageUsageRecord.class;
SortedSet<NumberedFilter> set =
accountingPersistenceQueryCouchBase.getNextPossibleValues(
clz, temporalConstraint, filters,
AggregatedStorageUsageRecord.OPERATION_TYPE, null);
logger.debug("{}", set);
} }
} }