2015-06-25 14:30:50 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2016-02-17 14:17:13 +01:00
|
|
|
package org.gcube.testutility;
|
2015-06-25 14:30:50 +02:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
import java.net.URI;
|
|
|
|
import java.net.URISyntaxException;
|
2015-10-20 14:40:30 +02:00
|
|
|
import java.util.UUID;
|
2015-06-25 17:41:56 +02:00
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
2017-09-14 14:21:23 +02:00
|
|
|
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
2015-07-01 16:40:49 +02:00
|
|
|
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
2016-02-17 15:09:32 +01:00
|
|
|
import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
|
2015-07-01 12:50:46 +02:00
|
|
|
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord;
|
2017-09-14 14:21:23 +02:00
|
|
|
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
2016-03-01 16:20:48 +01:00
|
|
|
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
2015-12-18 17:09:05 +01:00
|
|
|
import org.gcube.documentstore.exception.InvalidValueException;
|
2015-06-25 14:30:50 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
/**
|
2016-10-12 14:15:28 +02:00
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
2015-06-25 14:30:50 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class TestUsageRecord {
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(TestUsageRecord.class);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
public final static String TEST_CONSUMER_ID = "name.surname";
|
|
|
|
public final static String TEST_SCOPE = "/infrastructure/vo";
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
public final static String TEST_SCOPE_2 = "/infrastructure/vo/vre";
|
2016-02-17 15:09:32 +01:00
|
|
|
public final static OperationResult TEST_OPERATION_RESULT = OperationResult.SUCCESS;
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
public final static String TEST_SERVICE_CLASS = "TestServiceClass";
|
|
|
|
public final static String TEST_SERVICE_NAME = "TestServiceName";
|
2015-07-13 11:26:50 +02:00
|
|
|
public final static String TEST_CALLED_METHOD = "TestCalledMethod";
|
2016-09-19 11:06:46 +02:00
|
|
|
public final static String TEST_CALLER_QUALIFIER = "TestCallerQualifier";
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public final static String TEST_CALLER_HOST = "remotehost";
|
|
|
|
public final static String TEST_HOST = "localhost";
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
public final static String TEST_PROPERTY_NAME = "TestPropertyName";
|
|
|
|
public final static String TEST_PROPERTY_VALUE = "TestPropertyValue";
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-01-28 11:28:38 +01:00
|
|
|
public final static String TEST_JOB_ID = UUID.randomUUID().toString();
|
2015-10-20 14:40:30 +02:00
|
|
|
public final static String TEST_JOB_NAME = "TestJobName";
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-02-17 15:09:32 +01:00
|
|
|
public final static String TEST_PORTLET_ID = "TestPortlet";
|
|
|
|
public final static String TEST_PORTLET_OPERATION_ID = "TestPortletOperationID";
|
|
|
|
public final static String TEST_PORTLET_MESSAGE = "TestPortletMessage";
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
private final static long MIN_DURATION = 60; // millisec
|
|
|
|
private final static long MAX_DURATION = 1000; // millisec
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-03-01 16:20:48 +01:00
|
|
|
static {
|
|
|
|
AccountingPersistenceFactory.initAccountingPackages();
|
|
|
|
}
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
/**
|
|
|
|
* Generate A Random long in a range between min and max.
|
|
|
|
* This function is internally used to set random duration.
|
|
|
|
* @return the generated random long
|
|
|
|
*/
|
|
|
|
public static long generateRandomLong(long min, long max){
|
|
|
|
return min + (int)(Math.random() * ((max - min) + 1));
|
|
|
|
}
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-07-20 17:02:43 +02:00
|
|
|
/**
|
|
|
|
* Create a valid #ServiceUsageRecord with scope set automatically.
|
|
|
|
* @return the created #ServiceUsageRecord
|
|
|
|
*/
|
2016-02-10 15:14:31 +01:00
|
|
|
public static ServiceUsageRecord createTestServiceUsageRecord() {
|
2015-06-25 17:41:56 +02:00
|
|
|
ServiceUsageRecord usageRecord = new ServiceUsageRecord();
|
2015-06-25 14:30:50 +02:00
|
|
|
try {
|
2015-06-25 17:41:56 +02:00
|
|
|
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
2016-02-17 15:09:32 +01:00
|
|
|
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
2015-06-26 15:50:39 +02:00
|
|
|
usageRecord.setCallerHost(TEST_CALLER_HOST);
|
|
|
|
usageRecord.setHost(TEST_HOST);
|
2016-09-19 11:06:46 +02:00
|
|
|
usageRecord.setCallerQualifier(TEST_CALLER_QUALIFIER);
|
2015-06-26 15:50:39 +02:00
|
|
|
usageRecord.setServiceClass(TEST_SERVICE_CLASS);
|
2015-07-13 11:26:50 +02:00
|
|
|
usageRecord.setServiceName(TEST_SERVICE_NAME);
|
|
|
|
usageRecord.setCalledMethod(TEST_CALLED_METHOD);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
usageRecord.setDuration(generateRandomLong(MIN_DURATION, MAX_DURATION));
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
} catch (InvalidValueException e) {
|
2015-07-22 17:28:30 +02:00
|
|
|
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
|
|
|
throw new RuntimeException(e);
|
2015-06-25 14:30:50 +02:00
|
|
|
}
|
2015-06-25 17:41:56 +02:00
|
|
|
return usageRecord;
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
}
|
2015-06-25 17:41:56 +02:00
|
|
|
public final static String TEST_RESOUCE_OWNER = "resource.owner";
|
|
|
|
public final static String TEST_RESOUCE_SCOPE = TEST_SCOPE;
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public final static String TEST_PROVIDER_URI = "testprotocol://providerURI";
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
private final static long MIN_DATA_VOLUME = 1024;
|
|
|
|
private final static long MAX_DATA_VOLUME = 10240;
|
2015-07-20 17:02:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a valid #StorageUsageRecord with scope set automatically.
|
|
|
|
* @return the created #StorageUsageRecord
|
|
|
|
*/
|
2016-02-10 15:14:31 +01:00
|
|
|
public static StorageUsageRecord createTestStorageUsageRecord() {
|
2015-06-25 17:41:56 +02:00
|
|
|
StorageUsageRecord usageRecord = new StorageUsageRecord();
|
|
|
|
try {
|
|
|
|
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
2016-02-17 15:09:32 +01:00
|
|
|
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
usageRecord.setResourceOwner(TEST_RESOUCE_OWNER);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
usageRecord.setProviderURI(new URI(TEST_PROVIDER_URI));
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
usageRecord.setOperationType(AbstractStorageUsageRecord.OperationType.READ);
|
|
|
|
usageRecord.setDataType(AbstractStorageUsageRecord.DataType.STORAGE);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
usageRecord.setDataVolume(generateRandomLong(MIN_DATA_VOLUME, MAX_DATA_VOLUME));
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-06-26 17:13:26 +02:00
|
|
|
usageRecord.setQualifier("image/png");
|
2015-07-01 16:40:49 +02:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
|
|
|
|
} catch (InvalidValueException | URISyntaxException e) {
|
2015-07-22 17:28:30 +02:00
|
|
|
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
|
|
|
throw new RuntimeException(e);
|
2015-06-25 17:41:56 +02:00
|
|
|
}
|
|
|
|
return usageRecord;
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a valid #StorageVolumeUsageRecord with scope set automatically.
|
|
|
|
* @return the created #StorageVolumeUsageRecord
|
|
|
|
*/
|
|
|
|
public static StorageStatusRecord createTestStorageVolumeUsageRecord() {
|
|
|
|
StorageStatusRecord usageRecord = new StorageStatusRecord();
|
|
|
|
try {
|
|
|
|
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
|
|
|
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
|
|
|
usageRecord.setDataVolume(generateRandomLong(MIN_DATA_VOLUME, MAX_DATA_VOLUME));
|
2021-04-13 21:26:27 +02:00
|
|
|
usageRecord.setDataType(AbstractStorageUsageRecord.DataType.STORAGE);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
usageRecord.setDataCount(generateRandomLong(MIN_DATA_VOLUME, MAX_DATA_VOLUME));
|
|
|
|
usageRecord.setProviderId(new URI(TEST_PROVIDER_URI));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (InvalidValueException | URISyntaxException e) {
|
|
|
|
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
return usageRecord;
|
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
}
|
2016-02-10 15:14:31 +01:00
|
|
|
|
2015-07-20 17:02:43 +02:00
|
|
|
/**
|
|
|
|
* @return
|
|
|
|
*/
|
2016-02-10 15:14:31 +01:00
|
|
|
public static JobUsageRecord createTestJobUsageRecord() {
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-07-01 16:40:49 +02:00
|
|
|
JobUsageRecord usageRecord = new JobUsageRecord();
|
|
|
|
try {
|
|
|
|
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
2016-02-17 15:09:32 +01:00
|
|
|
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
2016-01-28 11:28:38 +01:00
|
|
|
usageRecord.setHost(TEST_HOST);
|
2017-09-14 14:21:23 +02:00
|
|
|
usageRecord.setCallerQualifier(TEST_CALLER_QUALIFIER);
|
|
|
|
usageRecord.setServiceClass(TEST_SERVICE_CLASS);
|
|
|
|
usageRecord.setServiceName(TEST_SERVICE_NAME);
|
|
|
|
usageRecord.setJobName(TEST_JOB_NAME);
|
|
|
|
usageRecord.setDuration(generateRandomLong(MIN_DURATION, MAX_DURATION));
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-07-01 16:40:49 +02:00
|
|
|
} catch (InvalidValueException e) {
|
2015-07-22 17:28:30 +02:00
|
|
|
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
2015-07-01 16:40:49 +02:00
|
|
|
}
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2015-07-01 16:40:49 +02:00
|
|
|
return usageRecord;
|
|
|
|
}
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-02-17 15:09:32 +01:00
|
|
|
/**
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public static PortletUsageRecord createTestPortletUsageRecord() {
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-02-17 15:09:32 +01:00
|
|
|
PortletUsageRecord usageRecord = new PortletUsageRecord();
|
|
|
|
try {
|
|
|
|
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
|
|
|
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-02-17 15:09:32 +01:00
|
|
|
usageRecord.setPortletId(TEST_PORTLET_ID);
|
|
|
|
usageRecord.setOperationId(TEST_PORTLET_OPERATION_ID);
|
|
|
|
usageRecord.setMessage(TEST_PORTLET_MESSAGE);
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-02-17 15:09:32 +01:00
|
|
|
} catch (InvalidValueException e) {
|
|
|
|
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
|
|
|
}
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
2016-02-17 15:09:32 +01:00
|
|
|
return usageRecord;
|
|
|
|
}
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-25 14:30:50 +02:00
|
|
|
}
|