refs #200: Create accouting-lib library

https://support.d4science.org/issues/200
Added example test

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115397 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-06-15 15:29:58 +00:00
parent 29a9f6106e
commit 6aa2f23d8f
2 changed files with 38 additions and 4 deletions

View File

@ -4,8 +4,6 @@
package org.gcube.accounting.persistence; package org.gcube.accounting.persistence;
import java.io.File; import java.io.File;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -93,11 +91,11 @@ public abstract class Persistence {
serviceUsageRecord.setResourceScope("/gcube/devsec"); serviceUsageRecord.setResourceScope("/gcube/devsec");
Calendar creationTime = new GregorianCalendar(); //Calendar creationTime = new GregorianCalendar();
//Calendar startTime = new GregorianCalendar(); //Calendar startTime = new GregorianCalendar();
//Calendar endTime = new GregorianCalendar(); //Calendar endTime = new GregorianCalendar();
serviceUsageRecord.setCreationTime(creationTime); //serviceUsageRecord.setCreationTime(creationTime);
//usageRecord.setStartTime(startTime); //usageRecord.setStartTime(startTime);
//usageRecord.setEndTime(endTime); //usageRecord.setEndTime(endTime);

View File

@ -0,0 +1,36 @@
/**
*
*/
package org.gcube.accounting.datamodel.implementation;
import org.gcube.accounting.datamodel.implementations.ServiceUsageRecord;
import org.gcube.accounting.exception.InvalidValueException;
import org.gcube.accounting.persistence.Persistence;
import org.junit.Test;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class ServiceUsageRecordTest {
@Test
public void exampleTest() throws InvalidValueException {
Persistence.setFallbackLocation(System.getProperty("user.home"));
Persistence persistence = Persistence.getInstance();
ServiceUsageRecord serviceUsageRecord = new ServiceUsageRecord();
serviceUsageRecord.setCreatorId("luca.frosini");
serviceUsageRecord.setConsumerId("accounting");
serviceUsageRecord.setResourceScope("/gcube/devsec");
serviceUsageRecord.setServiceClass("Accounting");
serviceUsageRecord.setServiceName("Accounting-Lib");
serviceUsageRecord.setRefHost("localhost");
serviceUsageRecord.setRefVM("local");
serviceUsageRecord.setCallerScope("/gcube/devsec");
serviceUsageRecord.setResourceProperty("ConnectionTest", "Test");
persistence.account(serviceUsageRecord);
}
}