diff --git a/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java b/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java index 3c167d9..1a6c32b 100644 --- a/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java +++ b/src/test/java/org/gcube/accounting/analytics/persistence/postgresql/AccountingPersistenceQueryPostgreSQLTest.java @@ -6,15 +6,19 @@ package org.gcube.accounting.analytics.persistence.postgresql; import java.util.ArrayList; import java.util.Calendar; import java.util.List; +import java.util.SortedMap; import org.gcube.accounting.analytics.Filter; +import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode; import org.gcube.accounting.analytics.exception.DuplicatedKeyFilterException; import org.gcube.accounting.analytics.exception.KeyException; import org.gcube.accounting.analytics.exception.ValueException; +import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration; import org.gcube.accounting.datamodel.UsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; +import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,6 +30,17 @@ public class AccountingPersistenceQueryPostgreSQLTest extends ContextTest { private static final Logger logger = LoggerFactory.getLogger(AccountingPersistenceQueryPostgreSQLTest.class); + protected AccountingPersistenceQueryPostgreSQL accountingPersistenceQueryPostgreSQL; + + @Before + public void before() throws Exception { + AccountingPersistenceBackendQueryConfiguration configuration = new AccountingPersistenceBackendQueryConfiguration( + AccountingPersistenceQueryPostgreSQL.class); + + accountingPersistenceQueryPostgreSQL = new AccountingPersistenceQueryPostgreSQL(); + accountingPersistenceQueryPostgreSQL.prepareConnection(configuration); + } + @Test public void testGetNoContextTimeSeriesQuery() throws DuplicatedKeyFilterException, KeyException, ValueException, Exception { logger.debug("test"); @@ -46,12 +61,8 @@ public class AccountingPersistenceQueryPostgreSQLTest extends ContextTest { filters.add(filter); TemporalConstraint temporalConstraint = new TemporalConstraint(startTimeCalendar.getTimeInMillis(), entTimeCalendar.getTimeInMillis(), AggregationMode.MINUTELY); - Query query = new Query(AggregatedServiceUsageRecord.class); - query.setTemporalConstraint(temporalConstraint); - query.setFilters(filters); - String ret = query.getNoContextTimeSeriesQuery(); - logger.debug(ret); - + SortedMap timeseries = accountingPersistenceQueryPostgreSQL.getNoContextTimeSeries(AggregatedServiceUsageRecord.class, temporalConstraint, filters); + logger.debug("{}", timeseries); } }