From b2a8885fe3b01176c23690ac3cd1539316e3dd1f Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 14 Apr 2021 00:55:43 +0200 Subject: [PATCH] fixed tests --- .../basetypes/AbstractStorageUsageRecord.java | 6 +++++- .../aggregation/AggregatedStorageUsageRecordTest.java | 10 +++++++++- src/test/resources/logback-test.xml | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java index 361b804..be24635 100644 --- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java @@ -164,7 +164,11 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord { @Deprecated public void setResourceURI(URI resourceURI) throws InvalidValueException { - setResourceProperty(RESOURCE_SCOPE, NOT_NEEDED); + try { + setResourceProperty(RESOURCE_URI, new URI(NOT_NEEDED)); + }catch (Exception e) { + setResourceProperty(RESOURCE_URI, NOT_NEEDED); + } // setResourceProperty(RESOURCE_URI, resourceURI); } diff --git a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java index 603c284..3d20c6d 100644 --- a/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java +++ b/src/test/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecordTest.java @@ -3,6 +3,7 @@ */ package org.gcube.accounting.datamodel.aggregation; +import java.net.URI; import java.util.Set; import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord; @@ -84,11 +85,15 @@ public class AggregatedStorageUsageRecordTest extends ContextTest { Assert.assertFalse(aggregated.getResourceProperties().containsKey(TestUsageRecord.TEST_PROPERTY_NAME)); } + @SuppressWarnings("deprecation") @Test - public void secondAsAggregated() throws InvalidValueException, NotAggregatableRecordsExceptions { + public void secondAsAggregated() throws Exception { SecurityTokenProvider.instance.reset(); ScopeProvider.instance.reset(); StorageUsageRecord storageUsageRecord = TestUsageRecord.createTestStorageUsageRecord(); + storageUsageRecord.setResourceScope("/gcube"); + storageUsageRecord.setResourceURI(new URI("resourceURI")); + Assert.assertTrue(storageUsageRecord.getScope()==null); storageUsageRecord.setScope(TestUsageRecord.TEST_SCOPE); storageUsageRecord.validate(); @@ -99,6 +104,9 @@ public class AggregatedStorageUsageRecordTest extends ContextTest { aggregated.validate(); StorageUsageRecord storageUsageRecord2 = TestUsageRecord.createTestStorageUsageRecord(); + storageUsageRecord2.setResourceScope("/gcube/devsec"); + storageUsageRecord2.setResourceURI(new URI("anotherResourceURI")); + Assert.assertTrue(storageUsageRecord2.getScope()==null); storageUsageRecord2.setScope(TestUsageRecord.TEST_SCOPE); storageUsageRecord2.setResourceProperty(TestUsageRecord.TEST_PROPERTY_NAME, TestUsageRecord.TEST_PROPERTY_VALUE); diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 0703b78..6c1d98a 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -13,7 +13,7 @@ - +