diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java index 6798def..ce1cad8 100644 --- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java @@ -22,12 +22,16 @@ public class AccountingPersistenceFactory { protected final static Map persistences; - static { - persistences = new HashMap(); + public static void initAccountingPackages(){ PersistenceBackendFactory.addRecordPackage(ServiceUsageRecord.class.getPackage()); PersistenceBackendFactory.addRecordPackage(AggregatedServiceUsageRecord.class.getPackage()); } + static { + persistences = new HashMap(); + initAccountingPackages(); + } + public static void setFallbackLocation(String path){ PersistenceBackendFactory.setFallbackLocation(path); } diff --git a/src/test/java/org/gcube/testutility/TestUsageRecord.java b/src/test/java/org/gcube/testutility/TestUsageRecord.java index f495ed3..354a260 100644 --- a/src/test/java/org/gcube/testutility/TestUsageRecord.java +++ b/src/test/java/org/gcube/testutility/TestUsageRecord.java @@ -17,6 +17,7 @@ import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord; import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord; import org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord; +import org.gcube.accounting.persistence.AccountingPersistenceFactory; import org.gcube.documentstore.exception.InvalidValueException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,6 +60,10 @@ public class TestUsageRecord { private final static long MIN_DURATION = 60; // millisec private final static long MAX_DURATION = 1000; // millisec + static { + AccountingPersistenceFactory.initAccountingPackages(); + } + /** * Generate A Random long in a range between min and max. * This function is internally used to set random duration.