refs #2437: Some records accounted on fallback are not recovered in the proper way in a special case

https://support.d4science.org/issues/2437
Added Tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@124684 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Luca Frosini 8 years ago
parent cb9aea9e6c
commit 7204f2574a

@ -28,7 +28,6 @@
<groupId>org.gcube.data.publishing</groupId>
<artifactId>document-store-lib</artifactId>
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.data.publishing</groupId>
@ -40,7 +39,6 @@
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.data.publishing</groupId>

@ -0,0 +1,77 @@
/**
*
*/
package org.gcube.documentstore.records;
import java.net.URI;
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OperationType;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class RecordUtilityTest {
private static Logger logger = LoggerFactory.getLogger(RecordUtilityTest.class);
@Test
public void testImportOldRecord() throws Exception {
String line = "{"
+ "resourceScope=/gcube/devsec, "
+ "scope=/gcube/devsec, "
+ "operationCount=1, "
+ "usageRecordType=StorageUsageRecord, "
+ "endTime=1448447153009, "
+ "consumerId=CSV, "
+ "startTime=1448447153009, "
+ "id=c7bab219-4024-4019-a8ad-ff5f342b439b, "
+ "dataVolume=68, "
+ "dataType=STORAGE, "
+ "resourceOwner=CSV, "
+ "operationResult=SUCCESS, "
+ "resourceURI=testprotocol://objectURI, "
+ "operationType=CREATE, "
+ "aggregated=true, "
+ "creationTime=1448447153096, "
+ "providerURI=data.d4science.org}";
logger.debug(line);
Record record = RecordUtility.getRecord(line);
Assert.assertTrue(record instanceof AggregatedStorageUsageRecord);
AggregatedStorageUsageRecord aggregatedStorageUsageRecord = (AggregatedStorageUsageRecord) record;
Assert.assertTrue(aggregatedStorageUsageRecord.getResourceScope().compareTo("/gcube/devsec")==0);
Assert.assertTrue(aggregatedStorageUsageRecord.getScope().compareTo("/gcube/devsec")==0);
Assert.assertTrue(aggregatedStorageUsageRecord.getOperationCount()==1);
//
Assert.assertTrue(aggregatedStorageUsageRecord.getRecordType().compareTo("StorageUsageRecord")==0);
Assert.assertTrue(aggregatedStorageUsageRecord.getEndTime().getTimeInMillis()==(new Long("1448447153009")));
Assert.assertTrue(aggregatedStorageUsageRecord.getConsumerId().compareTo("CSV")==0);
Assert.assertTrue(aggregatedStorageUsageRecord.getStartTime().getTimeInMillis()==(new Long("1448447153009")));
Assert.assertTrue(aggregatedStorageUsageRecord.getId().compareTo("c7bab219-4024-4019-a8ad-ff5f342b439b")==0);
Assert.assertTrue(aggregatedStorageUsageRecord.getDataVolume()==68);
Assert.assertTrue(aggregatedStorageUsageRecord.getDataType()==DataType.STORAGE);
Assert.assertTrue(aggregatedStorageUsageRecord.getResourceOwner().compareTo("CSV")==0);
Assert.assertTrue(aggregatedStorageUsageRecord.getOperationResult()==OperationResult.SUCCESS);
Assert.assertTrue(aggregatedStorageUsageRecord.getResourceURI().compareTo(new URI("testprotocol://objectURI"))==0);
Assert.assertTrue(aggregatedStorageUsageRecord.getOperationType()==OperationType.CREATE);
Assert.assertTrue((Boolean) aggregatedStorageUsageRecord.getResourceProperty(AggregatedStorageUsageRecord.AGGREGATED));
Assert.assertTrue(aggregatedStorageUsageRecord.getCreationTime().getTimeInMillis()==(new Long("1448447153096")));
Assert.assertTrue(aggregatedStorageUsageRecord.getProviderURI().compareTo(new URI("data.d4science.org"))==0);
logger.debug("{}", aggregatedStorageUsageRecord);
}
}

@ -5,6 +5,8 @@ package org.gcube.test;
import org.gcube.accounting.persistence.AccountingPersistence;
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
import org.gcube.documentstore.records.Record;
import org.gcube.documentstore.records.RecordUtility;
import org.gcube.testutility.ScopedTest;
import org.junit.Before;
import org.junit.Test;
@ -21,13 +23,13 @@ public class AccountingTest extends ScopedTest {
protected AccountingPersistence accountingPersistence;
@Before
//@Before
public void before() throws Exception {
super.before();
AccountingPersistenceFactory.setFallbackLocation("src/test/resources");
accountingPersistence = AccountingPersistenceFactory.getPersistence();
}
//@Test
public void testAccounting() throws Exception {
logger.trace("Let See");

Loading…
Cancel
Save