From e55ab7f5b76b99987bd8c16dd4db787dd5170573 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 12 Nov 2015 16:23:09 +0000 Subject: [PATCH] Fixes tests git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@120268 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../usagerecords/JobUsageRecordTest.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java index 60eccc5..4496337 100644 --- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java @@ -8,6 +8,7 @@ import java.util.Set; import org.gcube.accounting.datamodel.BasicUsageRecord; import org.gcube.accounting.datamodel.BasicUsageRecordUtility; +import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord; import org.gcube.accounting.datamodel.basetypes.TestUsageRecord; import org.gcube.accounting.exception.InvalidValueException; import org.gcube.common.scope.api.ScopeProvider; @@ -28,42 +29,45 @@ public class JobUsageRecordTest { expectedRequiredFields.add(BasicUsageRecordUtility.USAGE_RECORD_TYPE); expectedRequiredFields.add(BasicUsageRecord.SCOPE); expectedRequiredFields.add(BasicUsageRecord.OPERATION_RESULT); - expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.CALLER_HOST); - + expectedRequiredFields.add(AbstractJobUsageRecord.JOB_ID); + expectedRequiredFields.add(AbstractJobUsageRecord.JOB_QUALIFIER); + expectedRequiredFields.add(AbstractJobUsageRecord.JOB_NAME); + expectedRequiredFields.add(AbstractJobUsageRecord.JOB_START_TIME); + expectedRequiredFields.add(AbstractJobUsageRecord.JOB_END_TIME); return expectedRequiredFields; } @Test(expected=InvalidValueException.class) public void scopeNotSetValidationError() throws InvalidValueException { ScopeProvider.instance.reset(); - ServiceUsageRecord serviceUsageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope(); - serviceUsageRecord.validate(); + JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope(); + jobUsageRecord.validate(); } @Test public void testRequiredFields() throws InvalidValueException{ ScopeProvider.instance.set(TestUsageRecord.TEST_SCOPE); - ServiceUsageRecord serviceUsageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope(); + JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope(); Set expectedRequiredFields = getExpectedRequiredFields(); - Set gotRequiredFields = serviceUsageRecord.getRequiredFields(); + Set gotRequiredFields = jobUsageRecord.getRequiredFields(); Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields)); Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields)); - serviceUsageRecord.validate(); + jobUsageRecord.validate(); } @Test public void testRequiredFieldsWithScopeSetExplicitely() throws InvalidValueException{ - ServiceUsageRecord serviceUsageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope(); - serviceUsageRecord.setScope(TestUsageRecord.TEST_SCOPE); + JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope(); + jobUsageRecord.setScope(TestUsageRecord.TEST_SCOPE); Set expectedRequiredFields = getExpectedRequiredFields(); - Set gotRequiredFields = serviceUsageRecord.getRequiredFields(); + Set gotRequiredFields = jobUsageRecord.getRequiredFields(); Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields)); Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields)); - serviceUsageRecord.validate(); + jobUsageRecord.validate(); } }