Change Tenant ID to Object Asset Storage
MODIFY
src/scheduler/tasks/AssetGetConsumptionTask.ts
src/scheduler/tasks/AssetGetConsumptionTask.ts
@@ -30,7 +30,7 @@ export default class AssetGetConsumptionTask extends SchedulerTask {
// Create Helper Array with site areas to trigger smart charging
const triggerSmartChargingSiteAreas = [];
// Get dynamic assets only
- const dynamicAssets = await AssetStorage.getAssets(tenant.id,
+ const dynamicAssets = await AssetStorage.getAssets(tenant,
{
dynamicOnly: true,
withSiteArea: true
@@ -83,7 +83,7 @@ export default class AssetGetConsumptionTask extends SchedulerTask {
this.assignAssetConsumption(asset, consumption);
}
// Save Asset
- await AssetStorage.saveAsset(tenant.id, asset);
+ await AssetStorage.saveAsset(tenant, asset);
// Check if variation since last smart charging run exceeds the variation threshold
if (smartChargingActive && this.checkVariationSinceLastSmartChargingRun(asset)) {
// Check if Site Area is already pushed

MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -15,13 +15,16 @@ import Authorizations from '../../../../authorization/Authorizations';
import Constants from '../../../../utils/Constants';
import Consumption from '../../../../types/Consumption';
import ConsumptionStorage from '../../../../storage/mongodb/ConsumptionStorage';
+import DatabaseUtils from '../../../../storage/mongodb/DatabaseUtils';
import Logging from '../../../../utils/Logging';
import OCPPUtils from '../../../../server/ocpp/utils/OCPPUtils';
import { ServerAction } from '../../../../types/Server';
import SiteArea from '../../../../types/SiteArea';
import SiteAreaStorage from '../../../../storage/mongodb/SiteAreaStorage';
import { StatusCodes } from 'http-status-codes';
+import Tenant from '../../../../types/Tenant';
import TenantComponents from '../../../../types/TenantComponents';
+import TenantStorage from '../../../../storage/mongodb/TenantStorage';
import Utils from '../../../../utils/Utils';
import UtilsService from './UtilsService';
import moment from 'moment';
@@ -49,7 +52,7 @@ export default class AssetService {
});
}
// Get it
- const asset = await AssetStorage.getAsset(req.user.tenantID, filteredRequest.AssetID, {},
+ const asset = await AssetStorage.getAsset(req.tenant, filteredRequest.AssetID, {},
[ 'id', 'name' ]
);
UtilsService.assertObjectExists(action, asset, `Asset ID '${filteredRequest.AssetID}' does not exist`,
@@ -109,7 +112,7 @@ export default class AssetService {
});
}
// Get Asset
- const asset = await AssetStorage.getAsset(req.user.tenantID, filteredRequest.assetID, { withSiteArea: true });
+ const asset = await AssetStorage.getAsset(req.tenant, filteredRequest.assetID, { withSiteArea: true });
UtilsService.assertObjectExists(action, asset, `Asset ID '${filteredRequest.assetID}' does not exist`,
MODULE_NAME, 'handleCreateAssetConsumption', req.user);
// Check if connection ID exists
@@ -185,7 +188,7 @@ export default class AssetService {
asset.currentStateOfCharge = filteredRequest.stateOfCharge;
asset.lastConsumption = { timestamp: consumptionToSave.endedAt, value: consumptionToSave.consumptionWh };
// Save Asset
- await AssetStorage.saveAsset(req.user.tenantID, asset);
+ await AssetStorage.saveAsset(req.tenant, asset);
// Create response
res.status(StatusCodes.CREATED).json(Object.assign({ consumption: consumptionToSave }, Constants.REST_RESPONSE_SUCCESS));
next();
@@ -258,7 +261,7 @@ export default class AssetService {
const assetID = AssetSecurity.filterAssetRequestByID(req.query);
UtilsService.assertIdIsProvided(action, assetID, MODULE_NAME, 'handleRetrieveConsumption', req.user);
// Get
- const asset = await AssetStorage.getAsset(req.user.tenantID, assetID);
+ const asset = await AssetStorage.getAsset(req.tenant, assetID);
UtilsService.assertObjectExists(action, asset, `Asset ID '${assetID}' does not exist`,
MODULE_NAME, 'handleRetrieveConsumption', req.user);
// Dynamic asset ?
@@ -318,7 +321,7 @@ export default class AssetService {
asset.currentInstantWattsL3 = consumption.currentInstantWattsL3;
asset.currentStateOfCharge = consumption.currentStateOfCharge;
// Save Asset
- await AssetStorage.saveAsset(req.user.tenantID, asset);
+ await AssetStorage.saveAsset(req.tenant, asset);
}
} else {
// TODO: Return a specific HTTP code to tell the user that the consumption cannot be retrieved
@@ -346,7 +349,7 @@ export default class AssetService {
// Build error type
const errorType = (filteredRequest.ErrorType ? filteredRequest.ErrorType.split('|') : [AssetInErrorType.MISSING_SITE_AREA]);
// Get the assets
- const assets = await AssetStorage.getAssetsInError(req.user.tenantID,
+ const assets = await AssetStorage.getAssetsInError(req.tenant,
{
issuer: filteredRequest.Issuer,
search: filteredRequest.Search,
@@ -384,7 +387,7 @@ export default class AssetService {
});
}
// Get
- const asset = await AssetStorage.getAsset(req.user.tenantID, filteredRequest.ID,
+ const asset = await AssetStorage.getAsset(req.tenant, filteredRequest.ID,
{ withSiteArea: filteredRequest.WithSiteArea });
// Found?
UtilsService.assertObjectExists(action, asset, `Asset ID '${filteredRequest.ID}' does not exist`,
@@ -400,7 +403,7 @@ export default class AssetService {
});
}
// Delete
- await AssetStorage.deleteAsset(req.user.tenantID, asset.id);
+ await AssetStorage.deleteAsset(req.tenant, asset.id);
// Log
await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
@@ -434,7 +437,7 @@ export default class AssetService {
});
}
// Get it
- const asset = await AssetStorage.getAsset(req.user.tenantID, filteredRequest.ID,
+ const asset = await AssetStorage.getAsset(req.tenant, filteredRequest.ID,
{ withSiteArea: filteredRequest.WithSiteArea });
UtilsService.assertObjectExists(action, asset, `Asset ID '${filteredRequest.ID}' does not exist`,
MODULE_NAME, 'handleGetAsset', req.user);
@@ -447,7 +450,7 @@ export default class AssetService {
const filteredRequest = AssetSecurity.filterAssetImageRequest(req.query);
UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleGetAssetImage', req.user);
// Get it
- const assetImage = await AssetStorage.getAssetImage(filteredRequest.TenantID, filteredRequest.ID);
+ const assetImage = await AssetStorage.getAssetImage(req.tenant, filteredRequest.ID);
// Return
if (assetImage?.image) {
let header = 'image';
@@ -489,7 +492,7 @@ export default class AssetService {
return;
}
// Get the assets
- const assets = await AssetStorage.getAssets(req.user.tenantID,
+ const assets = await AssetStorage.getAssets(req.tenant,
{
search: filteredRequest.Search,
issuer: filteredRequest.Issuer,
@@ -551,7 +554,7 @@ export default class AssetService {
createdOn: new Date()
} as Asset;
// Save
- newAsset.id = await AssetStorage.saveAsset(req.user.tenantID, newAsset);
+ newAsset.id = await AssetStorage.saveAsset(req.tenant, newAsset);
// Log
await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
@@ -590,7 +593,7 @@ export default class AssetService {
MODULE_NAME, 'handleUpdateAsset', req.user);
}
// Check email
- const asset = await AssetStorage.getAsset(req.user.tenantID, filteredRequest.id);
+ const asset = await AssetStorage.getAsset(req.tenant, filteredRequest.id);
// Check
UtilsService.assertObjectExists(action, asset, `Site Area ID '${filteredRequest.id}' does not exist`,
MODULE_NAME, 'handleUpdateAsset', req.user);
@@ -624,7 +627,7 @@ export default class AssetService {
asset.lastChangedBy = { 'id': req.user.id };
asset.lastChangedOn = new Date();
// Update Asset
- await AssetStorage.saveAsset(req.user.tenantID, asset);
+ await AssetStorage.saveAsset(req.tenant, asset);
// Log
await Logging.logSecurityInfo({
tenantID: req.user.tenantID,

MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -178,7 +178,7 @@ export default class AuthorizationService {
if (!Utils.isEmptyArray(filteredRequest.assetIDs)) {
let foundInvalidAssetID = false;
// Get Asset IDs already assigned to the site
- const assetIDs = await AuthorizationService.getAssignedAssetIDs(tenant.id, siteArea.siteID);
+ const assetIDs = await AuthorizationService.getAssignedAssetIDs(tenant, siteArea.siteID);
// Check if any of the Assets we want to unassign are missing
for (const assetID of filteredRequest.assetIDs) {
switch (action) {
@@ -616,9 +616,9 @@ export default class AuthorizationService {
return sites.result.map((site) => site.id);
}
- private static async getAssignedAssetIDs(tenantID: string, siteID: string): Promise<string[]> {
+ private static async getAssignedAssetIDs(tenant: Tenant, siteID: string): Promise<string[]> {
// Get the Assets assigned to the Site
- const assets = await AssetStorage.getAssets(tenantID,
+ const assets = await AssetStorage.getAssets(tenant,
{
siteIDs: [siteID],
// TODO: Uncomment when the bug will be fixed: https://github.com/sap-labs-france/ev-dashboard/issues/2266

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -417,7 +417,7 @@ export default class UtilsService {
});
}
// Get Assets
- const assets = (await AssetStorage.getAssets(tenant.id,
+ const assets = (await AssetStorage.getAssets(tenant,
{
assetIDs,
...additionalFilters,

MODIFY
src/storage/mongodb/AssetStorage.ts
src/storage/mongodb/AssetStorage.ts
@@ -8,41 +8,42 @@ import DatabaseUtils from './DatabaseUtils';
import DbParams from '../../types/database/DbParams';
import Logging from '../../utils/Logging';
import { ObjectID } from 'mongodb';
+import Tenant from '../../types/Tenant';
import Utils from '../../utils/Utils';
const MODULE_NAME = 'AssetStorage';
export default class AssetStorage {
- public static async getAsset(tenantID: string, id: string = Constants.UNKNOWN_OBJECT_ID,
+ public static async getAsset(tenant: Tenant, id: string = Constants.UNKNOWN_OBJECT_ID,
params: { withSiteArea?: boolean } = {}, projectFields?: string[]): Promise<Asset> {
- const assetsMDB = await AssetStorage.getAssets(tenantID, {
+ const assetsMDB = await AssetStorage.getAssets(tenant, {
assetIDs: [id],
withSiteArea: params.withSiteArea
}, Constants.DB_PARAMS_SINGLE_RECORD, projectFields);
return assetsMDB.count === 1 ? assetsMDB.result[0] : null;
}
- public static async getAssetImage(tenantID: string, id: string): Promise<{ id: string; image: string }> {
+ public static async getAssetImage(tenant: Tenant, id: string): Promise<{ id: string; image: string }> {
// Debug
- const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'getAssetImage');
+ const uniqueTimerID = Logging.traceStart(tenant.id, MODULE_NAME, 'getAssetImage');
// Check Tenant
- await DatabaseUtils.checkTenant(tenantID);
+ DatabaseUtils.checkTenantObject(tenant);
// Read DB
- const assetImageMDB = await global.database.getCollection<{ _id: ObjectID; image: string }>(tenantID, 'assetimages')
+ const assetImageMDB = await global.database.getCollection<{ _id: ObjectID; image: string }>(tenant.id, 'assetimages')
.findOne({ _id: DatabaseUtils.convertToObjectID(id) });
// Debug
- await Logging.traceEnd(tenantID, MODULE_NAME, 'getAssetImage', uniqueTimerID, assetImageMDB);
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'getAssetImage', uniqueTimerID, assetImageMDB);
return {
id: id,
image: assetImageMDB ? assetImageMDB.image : null
};
}
- public static async saveAsset(tenantID: string, assetToSave: Asset, saveImage = true): Promise<string> {
+ public static async saveAsset(tenant: Tenant, assetToSave: Asset, saveImage = true): Promise<string> {
// Debug
- const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'saveAsset');
+ const uniqueTimerID = Logging.traceStart(tenant.id, MODULE_NAME, 'saveAsset');
// Check Tenant
- await DatabaseUtils.checkTenant(tenantID);
+ DatabaseUtils.checkTenantObject(tenant);
// Set
const assetMDB: any = {
_id: assetToSave.id ? DatabaseUtils.convertToObjectID(assetToSave.id) : new ObjectID(),
@@ -86,28 +87,28 @@ export default class AssetStorage {
// Add Last Changed/Created props
DatabaseUtils.addLastChangedCreatedProps(assetMDB, assetToSave);
// Modify
- await global.database.getCollection<Asset>(tenantID, 'assets').findOneAndUpdate(
+ await global.database.getCollection<Asset>(tenant.id, 'assets').findOneAndUpdate(
{ _id: assetMDB._id },
{ $set: assetMDB },
{ upsert: true }
);
// Save Image
if (saveImage) {
- await AssetStorage.saveAssetImage(tenantID, assetMDB._id.toHexString(), assetToSave.image);
+ await AssetStorage.saveAssetImage(tenant, assetMDB._id.toHexString(), assetToSave.image);
}
// Debug
- await Logging.traceEnd(tenantID, MODULE_NAME, 'saveAsset', uniqueTimerID, assetMDB);
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'saveAsset', uniqueTimerID, assetMDB);
return assetMDB._id.toHexString();
}
- public static async getAssets(tenantID: string,
+ public static async getAssets(tenant: Tenant,
params: { search?: string; assetIDs?: string[]; siteAreaIDs?: string[]; siteIDs?: string[]; withSiteArea?: boolean;
withNoSiteArea?: boolean; dynamicOnly?: boolean; issuer?: boolean; } = {},
dbParams?: DbParams, projectFields?: string[]): Promise<DataResult<Asset>> {
// Debug
- const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'getAssets');
+ const uniqueTimerID = Logging.traceStart(tenant.id, MODULE_NAME, 'getAssets');
// Check Tenant
- await DatabaseUtils.checkTenant(tenantID);
+ DatabaseUtils.checkTenantObject(tenant);
// Clone before updating the values
dbParams = Utils.cloneObject(dbParams);
// Check Limit
@@ -164,13 +165,13 @@ export default class AssetStorage {
aggregation.push({ $limit: Constants.DB_RECORD_COUNT_CEIL });
}
// Count Records
- const assetsCountMDB = await global.database.getCollection<DataResult<Asset>>(tenantID, 'assets')
+ const assetsCountMDB = await global.database.getCollection<DataResult<Asset>>(tenant.id, 'assets')
.aggregate([...aggregation, { $count: 'count' }], { allowDiskUse: true })
.toArray();
// Check if only the total count is requested
if (dbParams.onlyRecordCount) {
// Return only the count
- await Logging.traceEnd(tenantID, MODULE_NAME, 'getAssets', uniqueTimerID, assetsCountMDB);
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'getAssets', uniqueTimerID, assetsCountMDB);
return {
count: (assetsCountMDB.length > 0 ? assetsCountMDB[0].count : 0),
result: []
@@ -196,7 +197,7 @@ export default class AssetStorage {
// Site Area
if (params.withSiteArea) {
DatabaseUtils.pushSiteAreaLookupInAggregation({
- tenantID, aggregation, localField: 'siteAreaID', foreignField: '_id',
+ tenantID: tenant.id, aggregation, localField: 'siteAreaID', foreignField: '_id',
asField: 'siteArea', oneToOneCardinality: true
});
}
@@ -205,17 +206,17 @@ export default class AssetStorage {
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'siteAreaID');
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'siteArea.siteID');
// Add Created By / Last Changed By
- DatabaseUtils.pushCreatedLastChangedInAggregation(tenantID, aggregation);
+ DatabaseUtils.pushCreatedLastChangedInAggregation(tenant.id, aggregation);
// Project
DatabaseUtils.projectFields(aggregation, projectFields);
// Read DB
- const assetsMDB = await global.database.getCollection<any>(tenantID, 'assets')
+ const assetsMDB = await global.database.getCollection<any>(tenant.id, 'assets')
.aggregate(aggregation, {
allowDiskUse: true
})
.toArray();
// Debug
- await Logging.traceEnd(tenantID, MODULE_NAME, 'getAssets', uniqueTimerID, assetsMDB);
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'getAssets', uniqueTimerID, assetsMDB);
return {
count: (assetsCountMDB.length > 0 ?
(assetsCountMDB[0].count === Constants.DB_RECORD_COUNT_CEIL ? -1 : assetsCountMDB[0].count) : 0),
@@ -223,13 +224,13 @@ export default class AssetStorage {
};
}
- public static async getAssetsInError(tenantID: string,
+ public static async getAssetsInError(tenant: Tenant,
params: { search?: string; siteAreaIDs?: string[]; siteIDs?: string[]; errorType?: string[]; issuer?: boolean } = {},
dbParams?: DbParams, projectFields?: string[]): Promise<DataResult<Asset>> {
// Debug
- const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'getAssetsInError');
+ const uniqueTimerID = Logging.traceStart(tenant.id, MODULE_NAME, 'getAssetsInError');
// Check Tenant
- await DatabaseUtils.checkTenant(tenantID);
+ DatabaseUtils.checkTenantObject(tenant);
// Clone before updating the values
dbParams = Utils.cloneObject(dbParams);
// Check Limit
@@ -279,7 +280,7 @@ export default class AssetStorage {
DatabaseUtils.pushRenameDatabaseID(aggregation);
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'siteAreaID');
// Add Created By / Last Changed By
- DatabaseUtils.pushCreatedLastChangedInAggregation(tenantID, aggregation);
+ DatabaseUtils.pushCreatedLastChangedInAggregation(tenant.id, aggregation);
// Sort
if (!dbParams.sort) {
dbParams.sort = { name: 1 };
@@ -298,13 +299,13 @@ export default class AssetStorage {
// Project
DatabaseUtils.projectFields(aggregation, projectFields);
// Read DB
- const assetsMDB = await global.database.getCollection<any>(tenantID, 'assets')
+ const assetsMDB = await global.database.getCollection<any>(tenant.id, 'assets')
.aggregate(aggregation, {
allowDiskUse: true
})
.toArray();
// Debug
- await Logging.traceEnd(tenantID, MODULE_NAME, 'getAssetsInError', uniqueTimerID, assetsMDB);
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'getAssetsInError', uniqueTimerID, assetsMDB);
// Ok
return {
count: assetsMDB.length,
@@ -312,33 +313,33 @@ export default class AssetStorage {
};
}
- public static async deleteAsset(tenantID: string, id: string): Promise<void> {
+ public static async deleteAsset(tenant: Tenant, id: string): Promise<void> {
// Debug
- const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'deleteAsset');
+ const uniqueTimerID = Logging.traceStart(tenant.id, MODULE_NAME, 'deleteAsset');
// Check Tenant
- await DatabaseUtils.checkTenant(tenantID);
+ DatabaseUtils.checkTenantObject(tenant);
// Delete the Asset
- await global.database.getCollection<Asset>(tenantID, 'assets')
+ await global.database.getCollection<Asset>(tenant.id, 'assets')
.findOneAndDelete({ '_id': DatabaseUtils.convertToObjectID(id) });
// Delete Image
- await global.database.getCollection<any>(tenantID, 'assetimages')
+ await global.database.getCollection<any>(tenant.id, 'assetimages')
.findOneAndDelete({ '_id': DatabaseUtils.convertToObjectID(id) });
// Debug
- await Logging.traceEnd(tenantID, MODULE_NAME, 'deleteAsset', uniqueTimerID, { id });
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'deleteAsset', uniqueTimerID, { id });
}
- private static async saveAssetImage(tenantID: string, assetID: string, assetImageToSave: string): Promise<void> {
+ private static async saveAssetImage(tenant: Tenant, assetID: string, assetImageToSave: string): Promise<void> {
// Debug
- const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'saveAssetImage');
+ const uniqueTimerID = Logging.traceStart(tenant.id, MODULE_NAME, 'saveAssetImage');
// Check Tenant
- await DatabaseUtils.checkTenant(tenantID);
+ DatabaseUtils.checkTenantObject(tenant);
// Modify
- await global.database.getCollection<any>(tenantID, 'assetimages').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'assetimages').findOneAndUpdate(
{ '_id': DatabaseUtils.convertToObjectID(assetID) },
{ $set: { image: assetImageToSave } },
{ upsert: true });
// Debug
- await Logging.traceEnd(tenantID, MODULE_NAME, 'saveAssetImage', uniqueTimerID, assetImageToSave);
+ await Logging.traceEnd(tenant.id, MODULE_NAME, 'saveAssetImage', uniqueTimerID, assetImageToSave);
}
private static getAssetInErrorFacet(errorType: string) {

MODIFY
test/api/SmartChargingTest.ts
test/api/SmartChargingTest.ts
@@ -1275,7 +1275,7 @@ describe('Smart Charging Service', function() {
}
} as Asset;
// Create Assets
- await AssetStorage.saveAsset(testData.tenantContext.getTenant().id, testData.newAsset);
+ await AssetStorage.saveAsset(testData.tenantContext.getTenant(), testData.newAsset);
});
after(async () => {
@@ -1287,7 +1287,7 @@ describe('Smart Charging Service', function() {
testData.siteAreaContext.getSiteArea().maximumPower = 200000;
await testData.userService.siteAreaApi.update(testData.siteAreaContext.getSiteArea());
- await AssetStorage.deleteAsset(testData.tenantContext.getTenant().id, testData.newAsset.id);
+ await AssetStorage.deleteAsset(testData.tenantContext.getTenant(), testData.newAsset.id);
});
@@ -1319,7 +1319,7 @@ describe('Smart Charging Service', function() {
testData.newAsset.lastConsumption = { timestamp: new Date('2021-02-05T14:16:19.001Z'), value: 0 };
testData.siteAreaContext.getSiteArea().maximumPower = 120000;
await testData.userService.siteAreaApi.update(testData.siteAreaContext.getSiteArea());
- await AssetStorage.saveAsset(testData.tenantContext.getTenant().id, testData.newAsset);
+ await AssetStorage.saveAsset(testData.tenantContext.getTenant(), testData.newAsset);
await testData.chargingStationContext.startTransaction(1, testData.userContext.tags[0].id, 180, new Date);
chargingStationConnector1Charging.timestamp = new Date().toISOString();
await testData.chargingStationContext.setConnectorStatus(chargingStationConnector1Charging);
@@ -1344,7 +1344,7 @@ describe('Smart Charging Service', function() {
testData.siteAreaContext.getSiteArea().maximumPower = 22080;
await testData.userService.siteAreaApi.update(testData.siteAreaContext.getSiteArea());
testData.newAsset.excludeFromSmartCharging = true;
- await AssetStorage.saveAsset(testData.tenantContext.getTenant().id, testData.newAsset);
+ await AssetStorage.saveAsset(testData.tenantContext.getTenant(), testData.newAsset);
const chargingProfiles = await smartChargingIntegration.buildChargingProfiles(testData.siteAreaContext.getSiteArea());
expect(chargingProfiles[0].profile.chargingSchedule.chargingSchedulePeriod).containSubset(limit96);
});
@@ -1359,7 +1359,7 @@ describe('Smart Charging Service', function() {
testData.newAsset.assetType = AssetType.PRODUCTION;
testData.newAsset.excludeFromSmartCharging = false;
testData.newAsset.lastConsumption = { timestamp: new Date(), value: 0 };
- await AssetStorage.saveAsset(testData.tenantContext.getTenant().id, testData.newAsset);
+ await AssetStorage.saveAsset(testData.tenantContext.getTenant(), testData.newAsset);
const chargingProfiles = await smartChargingIntegration.buildChargingProfiles(testData.siteAreaContext.getSiteArea());
expect(chargingProfiles[0].profile.chargingSchedule.chargingSchedulePeriod).containSubset([
{

Change Tenant ID to Object Asset Storage