From 1a09eef999b76152e823f35dd39ebe8bf0761c24 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 7 Aug 2024 09:56:15 +0200 Subject: [PATCH 1/2] access to service and subservice in jexl context for functional test --- test/functional/functional-tests-runner.js | 4 ++-- test/functional/functional-tests.js | 8 ++++---- test/functional/testCases.js | 20 ++++---------------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/test/functional/functional-tests-runner.js b/test/functional/functional-tests-runner.js index 4a0d6d0db..d98f91a5e 100755 --- a/test/functional/functional-tests-runner.js +++ b/test/functional/functional-tests-runner.js @@ -65,8 +65,8 @@ describe('FUNCTIONAL TESTS AUTO', function () { } let type = testUtils.groupToIoTAConfigType( testCase.provision.json.services[0], - testCase.provision.headers.fiwareService, - testCase.provision.headers.fiwareServicepath + testCase.provision.headers['fiware-service'], + testCase.provision.headers['fiware-servicepath'] ); config.iota.types[type.name] = type.type; iotAgentLib.activate(config.iota, function (error) { diff --git a/test/functional/functional-tests.js b/test/functional/functional-tests.js index 27445ef03..9023c11a6 100755 --- a/test/functional/functional-tests.js +++ b/test/functional/functional-tests.js @@ -115,8 +115,8 @@ describe('FUNCTIONAL TESTS', function () { beforeEach(function (done) { let type = testUtils.groupToIoTAConfigType( provision.json.services[0], - provision.headers.fiwareService, - provision.headers.fiwareServicepath + provision.headers['fiware-service'], + provision.headers['fiware-servicepath'] ); config.iota.types[type.name] = type.type; iotAgentLib.activate(config.iota, function (error) { @@ -214,8 +214,8 @@ describe('FUNCTIONAL TESTS', function () { beforeEach(function (done) { let type = testUtils.groupToIoTAConfigType( provision.json.services[0], - provision.headers.fiwareService, - provision.headers.fiwareServicepath + provision.headers['fiware-service'], + provision.headers['fiware-servicepath'] ); config.iota.types[type.name] = type.type; iotAgentLib.activate(config.iota, function (error) { diff --git a/test/functional/testCases.js b/test/functional/testCases.js index bb3f51bec..46957e6d0 100644 --- a/test/functional/testCases.js +++ b/test/functional/testCases.js @@ -1768,7 +1768,6 @@ const testCases = [ }, { describeName: '0170 - Simple group with active attribute + JEXL expression referencing context attributes', - skip: 'lib', // Explanation in #1523 provision: { url: 'http://localhost:' + config.iota.server.port + '/iot/services', method: 'POST', @@ -1785,7 +1784,7 @@ const testCases = [ object_id: 'a', name: 'attr_a', type: 'Text', - expression: 'a+":"+service+subservice+id+type' + expression: 'a+":"+service+subservice+type' } ] } @@ -1816,12 +1815,7 @@ const testCases = [ id: globalEnv.entity_name, type: globalEnv.entity_type, attr_a: { - value: - 'text:' + - globalEnv.service + - globalEnv.servicePath + - globalEnv.deviceId + - globalEnv.entity_type, + value: 'text:' + globalEnv.service + globalEnv.servicePath + globalEnv.entity_type, type: 'Text' } } @@ -1830,7 +1824,6 @@ const testCases = [ }, { describeName: '0180 - Simple group with active attributes + JEXL multiples expressions at same time', - skip: 'lib', // Explanation in #1523 provision: { url: 'http://localhost:' + config.iota.server.port + '/iot/services', method: 'POST', @@ -1859,7 +1852,7 @@ const testCases = [ object_id: 'c', name: 'attr_c', type: 'Text', - expression: 'c+":"+service+subservice+id+type' + expression: 'c+":"+service+subservice+type' }, { object_id: 'd', @@ -1923,12 +1916,7 @@ const testCases = [ }, attr_c: { type: 'Text', - value: - 'text:' + - globalEnv.service + - globalEnv.servicePath + - globalEnv.deviceId + - globalEnv.entity_type + value: 'text:' + globalEnv.service + globalEnv.servicePath + globalEnv.entity_type }, attr_d: { type: 'Float', From 9d7ff89e9b02022db01bc241a498822de9396725 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 7 Aug 2024 11:18:51 +0200 Subject: [PATCH 2/2] provide device id in typeInformation --- test/functional/functional-tests-runner.js | 9 +++++++-- test/functional/testCases.js | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/test/functional/functional-tests-runner.js b/test/functional/functional-tests-runner.js index d98f91a5e..9a732159d 100755 --- a/test/functional/functional-tests-runner.js +++ b/test/functional/functional-tests-runner.js @@ -63,12 +63,17 @@ describe('FUNCTIONAL TESTS AUTO', function () { if (testCase.loglevel) { logger.setLevel(testCase.loglevel); } - let type = testUtils.groupToIoTAConfigType( + let confType = testUtils.groupToIoTAConfigType( testCase.provision.json.services[0], testCase.provision.headers['fiware-service'], testCase.provision.headers['fiware-servicepath'] ); - config.iota.types[type.name] = type.type; + // Inject device id into config as real typeInformation + if (testCase.should[0] && testCase.should[0].measure.qs.i) { + confType.type['id'] = testCase.should[0].measure.qs.i; + } + config.iota.types[confType.name] = confType.type; + iotAgentLib.activate(config.iota, function (error) { done(error); }); diff --git a/test/functional/testCases.js b/test/functional/testCases.js index 46957e6d0..31def5e7d 100644 --- a/test/functional/testCases.js +++ b/test/functional/testCases.js @@ -1784,7 +1784,7 @@ const testCases = [ object_id: 'a', name: 'attr_a', type: 'Text', - expression: 'a+":"+service+subservice+type' + expression: 'a+":"+service+subservice+id+type' } ] } @@ -1815,7 +1815,12 @@ const testCases = [ id: globalEnv.entity_name, type: globalEnv.entity_type, attr_a: { - value: 'text:' + globalEnv.service + globalEnv.servicePath + globalEnv.entity_type, + value: + 'text:' + + globalEnv.service + + globalEnv.servicePath + + globalEnv.deviceId + + globalEnv.entity_type, type: 'Text' } } @@ -1852,7 +1857,7 @@ const testCases = [ object_id: 'c', name: 'attr_c', type: 'Text', - expression: 'c+":"+service+subservice+type' + expression: 'c+":"+service+subservice+id+type' }, { object_id: 'd', @@ -1916,7 +1921,12 @@ const testCases = [ }, attr_c: { type: 'Text', - value: 'text:' + globalEnv.service + globalEnv.servicePath + globalEnv.entity_type + value: + 'text:' + + globalEnv.service + + globalEnv.servicePath + + globalEnv.deviceId + + globalEnv.entity_type }, attr_d: { type: 'Float', @@ -4191,7 +4201,7 @@ const testCases = [ type: 'Number', entity_name: 'TestType:TestDevice2', entity_type: 'TestType', - expression: 'type+":"+(t*2*static_a)' // Only type is used as JEXL context attr due to #1523 + expression: 'type+":"+(t*2*static_a)' } ], static_attributes: [ @@ -4277,7 +4287,7 @@ const testCases = [ object_id: 't', name: 'temperature', type: 'Number', - entity_name: 'type+":"+(t*2*static_a)', // Only type is used as JEXL context attr due to #1523 + entity_name: 'type+":"+(t*2*static_a)', entity_type: 'TestType' } ],