iotagent-node-lib 2.15.1 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +17 -1
- package/.readthedocs.yml +7 -0
- package/CHANGES_NEXT_RELEASE +0 -1
- package/README.md +1 -0
- package/doc/Contribution.md +60 -1
- package/doc/advanced-topics.md +136 -14
- package/doc/api.md +38 -22
- package/doc/apiary/iotagent.apib +1 -3
- package/doc/architecture.md +2 -2
- package/doc/config-basic-example.js +0 -1
- package/doc/deprecated.md +2 -2
- package/doc/development.md +13 -6
- package/doc/expressionLanguage.md +519 -277
- package/doc/getting-started.md +0 -1
- package/doc/howto.md +13 -17
- package/doc/installationguide.md +67 -69
- package/doc/usermanual.md +48 -16
- package/docker/Mosquitto/Dockerfile +4 -9
- package/docker/Mosquitto/README.md +2 -0
- package/docker/Mosquitto/startMosquitto.sh +18 -1
- package/lib/command/commandLine.js +1 -1
- package/lib/commonConfig.js +5 -14
- package/lib/errors.js +0 -16
- package/lib/fiware-iotagent-lib.js +5 -0
- package/lib/jexlTranformsMap.js +71 -0
- package/lib/model/Command.js +1 -1
- package/lib/model/Device.js +5 -2
- package/lib/model/Group.js +20 -2
- package/lib/model/dbConn.js +7 -1
- package/lib/plugins/attributeAlias.js +6 -13
- package/lib/plugins/bidirectionalData.js +2 -27
- package/lib/plugins/expressionParser.js +41 -17
- package/lib/plugins/expressionPlugin.js +21 -27
- package/lib/plugins/jexlParser.js +71 -67
- package/lib/plugins/multiEntity.js +68 -147
- package/lib/plugins/pluginUtils.js +12 -48
- package/lib/plugins/timestampProcessPlugin.js +1 -46
- package/lib/request-shim.js +111 -0
- package/lib/services/common/domain.js +2 -2
- package/lib/services/common/genericMiddleware.js +6 -2
- package/lib/services/common/iotManagerService.js +1 -1
- package/lib/services/common/securityServiceKeystone.js +1 -1
- package/lib/services/common/securityServiceOAuth2.js +3 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +29 -22
- package/lib/services/devices/deviceService.js +56 -33
- package/lib/services/devices/devices-NGSI-LD.js +42 -14
- package/lib/services/devices/devices-NGSI-mixed.js +3 -3
- package/lib/services/devices/devices-NGSI-v2.js +48 -24
- package/lib/services/devices/registrationUtils.js +1 -134
- package/lib/services/groups/groupRegistryMemory.js +2 -0
- package/lib/services/groups/groupRegistryMongoDB.js +58 -76
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +205 -124
- package/lib/services/ngsi/entities-NGSI-v2.js +142 -32
- package/lib/services/ngsi/ngsiService.js +4 -6
- package/lib/services/ngsi/ngsiUtils.js +0 -21
- package/lib/services/ngsi/subscription-NGSI-LD.js +14 -5
- package/lib/services/ngsi/subscriptionService.js +1 -4
- package/lib/services/northBound/contextServer-NGSI-LD.js +7 -2
- package/lib/services/northBound/contextServer-NGSI-v2.js +25 -13
- package/lib/services/northBound/contextServer.js +1 -4
- package/lib/services/northBound/contextServerUtils.js +0 -81
- package/lib/services/northBound/deviceProvisioningServer.js +36 -9
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/northBound/restUtils.js +2 -39
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +13 -13
- package/test/tools/utils.js +2 -0
- package/test/unit/examples/deviceProvisioningRequests/provisionAnotherDevice.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionDuplicatedDev.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json +1 -1
- package/test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json +1 -1
- package/test/unit/examples/iotamRequests/registrationEmpty.json +1 -1
- package/test/unit/examples/iotamRequests/registrationWithGroups.json +2 -2
- package/test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json +2 -2
- package/test/unit/examples/iotamRequests/registrationWithStaticGroups.json +2 -2
- package/test/unit/expressions/jexlExpression-test.js +119 -0
- package/test/unit/general/config-multi-core-test.js +1 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +30 -77
- package/test/unit/general/deviceService-test.js +19 -35
- package/test/unit/general/loglevel-api_test.js +8 -13
- package/test/unit/general/migration-test.js +1 -0
- package/test/unit/general/startup-test.js +3 -2
- package/test/unit/general/statistics-persistence_test.js +2 -2
- package/test/unit/general/statistics-service_test.js +2 -2
- package/test/unit/lazyAndCommands/commandRegistry_test.js +18 -18
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +16 -24
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +2 -2
- package/test/unit/mongodb/mongodb-group-registry-test.js +11 -11
- package/test/unit/mongodb/mongodb-registry-test.js +55 -131
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateCommands1.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent1.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -14
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -14
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json +1 -15
- package/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast5.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin12a.json +7 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin13.json +13 -13
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin16.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin17.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin31.json +15 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin33.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin34.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +36 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin5.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +16 -16
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextGeoproperties3.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +6 -6
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +3 -3
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionDeviceStatic.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionMinimumDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +20 -17
- package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest.json +18 -15
- package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest2.json +18 -15
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +21 -21
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1018 -0
- package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -2
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +24 -24
- package/test/unit/ngsi-ld/general/deviceService-test.js +7 -7
- package/test/unit/ngsi-ld/general/https-support-test.js +14 -13
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +8 -7
- package/test/unit/ngsi-ld/general/startup-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +10 -8
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +11 -12
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +25 -29
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +16 -15
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +18 -17
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +13 -12
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +10 -9
- package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +3 -3
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +25 -24
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +13 -12
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +27 -26
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +5 -5
- package/test/unit/ngsi-ld/plugins/event-plugin_test.js +3 -3
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +75 -14
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +3 -3
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +54 -53
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +20 -19
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +23 -22
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +58 -70
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +8 -7
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +19 -19
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +18 -20
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +43 -49
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +16 -14
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent3.json +19 -0
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent5.json +19 -0
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateCommands1.json +3 -3
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent1.json +3 -3
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +17 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin16.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin18.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin19.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +13 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin20.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin21.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin22.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin23.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin24.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin25.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin26.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin27.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin28.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +18 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +16 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +17 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware1.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware2.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +13 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +25 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateProvisionDevice.json +20 -0
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +1 -1
- package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest.json +1 -1
- package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest2.json +1 -1
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +93 -60
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +16 -16
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +548 -164
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +34 -33
- package/test/unit/ngsiv2/general/deviceService-test.js +15 -14
- package/test/unit/ngsiv2/general/https-support-test.js +14 -13
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +8 -7
- package/test/unit/ngsiv2/general/startup-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +9 -7
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +13 -12
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +323 -51
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +22 -20
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +114 -26
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +16 -16
- package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +39 -38
- package/test/unit/{ngsiService → ngsiv2/ngsiService}/queryDeviceInformationInCb-test.js +25 -54
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +5 -5
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +25 -24
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +22 -22
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +27 -26
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +7 -7
- package/test/unit/ngsiv2/plugins/event-plugin_test.js +4 -4
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +549 -24
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +4 -4
- package/test/unit/{plugins → ngsiv2/plugins}/translation-inPlugins_test.js +25 -25
- package/test/unit/{provisioning → ngsiv2/provisioning}/device-group-api-test.js +44 -75
- package/test/unit/{provisioning/device-group-utils_test.js → ngsiv2/provisioning/device-group-utils-test.js} +15 -14
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +74 -73
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +20 -19
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +30 -29
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +58 -69
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +8 -7
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +19 -19
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +18 -19
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +49 -52
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +6 -4
- package/test/unit/plugins/capture-provision-inPlugins_test.js +13 -23
- package/.nyc_output/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
- package/.nyc_output/processinfo/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/lib/services/devices/devices-NGSI-v1.js +0 -293
- package/lib/services/devices/registrationUtils.js_avega +0 -589
- package/lib/services/ngsi/entities-NGSI-v1.js +0 -300
- package/lib/services/ngsi/subscription-NGSI-v1.js +0 -234
- package/lib/services/northBound/contextServer-NGSI-v1.js +0 -526
- package/lib/templates/notificationTemplateNgsi1.json +0 -75
- package/lib/templates/updateContextNgsi1.json +0 -50
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent2.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json +0 -25
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent4.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentAttributeUpdates.json +0 -16
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerNewDevice2.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json +0 -25
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +0 -33
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +0 -33
- package/test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/unregisterDevice3.json +0 -26
- package/test/unit/examples/contextAvailabilityRequests/unregisterProvisionedDevice.json +0 -26
- package/test/unit/examples/contextAvailabilityRequests/updateCommands1.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent2.json +0 -26
- package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent3.json +0 -22
- package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json +0 -8
- package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Failed.json +0 -8
- package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/updateCommands1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json +0 -6
- package/test/unit/examples/contextProviderResponses/queryInformationResponse.json +0 -22
- package/test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json +0 -22
- package/test/unit/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json +0 -27
- package/test/unit/examples/contextProviderResponses/updateInformationResponse.json +0 -22
- package/test/unit/examples/contextProviderResponses/updateInformationResponse2.json +0 -22
- package/test/unit/examples/contextRequests/contextSubscriptionRequest.json +0 -20
- package/test/unit/examples/contextRequests/contextSubscriptionRequest2.json +0 -20
- package/test/unit/examples/contextRequests/createBidirectionalDevice.json +0 -17
- package/test/unit/examples/contextRequests/createDatetimeProvisionedDevice.json +0 -17
- package/test/unit/examples/contextRequests/createGeopointProvisionedDevice.json +0 -17
- package/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json +0 -17
- package/test/unit/examples/contextRequests/createProvisionedDevice.json +0 -32
- package/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -32
- package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json +0 -47
- package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -52
- package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -52
- package/test/unit/examples/contextRequests/createTimeinstantDevice.json +0 -17
- package/test/unit/examples/contextRequests/queryContext1.json +0 -13
- package/test/unit/examples/contextRequests/queryContext2.json +0 -13
- package/test/unit/examples/contextRequests/queryContextAliasPlugin1.json +0 -10
- package/test/unit/examples/contextRequests/queryContextCompressTimestamp1.json +0 -13
- package/test/unit/examples/contextRequests/updateActiveAttributes.json +0 -11
- package/test/unit/examples/contextRequests/updateContext1.json +0 -22
- package/test/unit/examples/contextRequests/updateContext2.json +0 -22
- package/test/unit/examples/contextRequests/updateContext3.json +0 -17
- package/test/unit/examples/contextRequests/updateContext3WithStatic.json +0 -22
- package/test/unit/examples/contextRequests/updateContext4.json +0 -22
- package/test/unit/examples/contextRequests/updateContext5.json +0 -19
- package/test/unit/examples/contextRequests/updateContextAliasPlugin.json +0 -22
- package/test/unit/examples/contextRequests/updateContextAliasPlugin2.json +0 -17
- package/test/unit/examples/contextRequests/updateContextAppendMode.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandError.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandExpired.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandFinish.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandStatus.json +0 -17
- package/test/unit/examples/contextRequests/updateContextCompressTimestamp1.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCompressTimestamp2.json +0 -29
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin1.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin2.json +0 -27
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin3.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin4.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin5.json +0 -27
- package/test/unit/examples/contextRequests/updateContextMiddleware1.json +0 -22
- package/test/unit/examples/contextRequests/updateContextMultiEntityPlugin3.json +0 -35
- package/test/unit/examples/contextRequests/updateContextMultientityPlugin1.json +0 -30
- package/test/unit/examples/contextRequests/updateContextMultientityPlugin2.json +0 -30
- package/test/unit/examples/contextRequests/updateContextProcessTimestamp1.json +0 -29
- package/test/unit/examples/contextRequests/updateContextStaticAttributes.json +0 -22
- package/test/unit/examples/contextRequests/updateContextTimestamp.json +0 -41
- package/test/unit/examples/contextRequests/updateContextTimestampOverride.json +0 -22
- package/test/unit/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +0 -22
- package/test/unit/examples/contextRequests/updateContextTimestampTimezone.json +0 -41
- package/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -17
- package/test/unit/examples/contextRequests/updateProvisionCommands1.json +0 -27
- package/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json +0 -38
- package/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json +0 -17
- package/test/unit/examples/contextResponses/contextSubscriptionRequest2Success.json +0 -7
- package/test/unit/examples/contextResponses/contextSubscriptionRequestSuccess.json +0 -7
- package/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createDatetimeProvisionedDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createGeopointProvisionedDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createTimeinstantSuccess.json +0 -22
- package/test/unit/examples/contextResponses/queryContext1Success.json +0 -27
- package/test/unit/examples/contextResponses/queryContext2Error.json +0 -7
- package/test/unit/examples/contextResponses/queryContext2UnknownError.json +0 -6
- package/test/unit/examples/contextResponses/queryContext3Error.json +0 -34
- package/test/unit/examples/contextResponses/queryContextAliasPlugin1Success.json +0 -27
- package/test/unit/examples/contextResponses/queryContextCompressTimestamp1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateActiveAttributesSuccess.json +0 -16
- package/test/unit/examples/contextResponses/updateContext1Failed.json +0 -7
- package/test/unit/examples/contextResponses/updateContext1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContext2Failed.json +0 -35
- package/test/unit/examples/contextResponses/updateContextAliasPlugin2Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContextAliasPluginSuccess.json +0 -27
- package/test/unit/examples/contextResponses/updateContextCommandFinishSuccess.json +0 -27
- package/test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json +0 -22
- package/test/unit/examples/contextResponses/updateContextCompressTimestamp1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContextCompressTimestamp2Success.json +0 -34
- package/test/unit/examples/contextResponses/updateContextEvents1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json +0 -22
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin2Success.json +0 -22
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin3Success.json +0 -22
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin5Success.json +0 -32
- package/test/unit/examples/contextResponses/updateContextMultientityPlugin1Success.json +0 -40
- package/test/unit/examples/contextResponses/updateContextMultientityPlugin2Success.json +0 -40
- package/test/unit/examples/contextResponses/updateContextMultientityPlugin3Success.json +0 -40
- package/test/unit/examples/contextResponses/updateContextProcessTimestamp1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateProvisionActiveAttributes1Success.json +0 -22
- package/test/unit/examples/contextResponses/updateProvisionCommands1Success.json +0 -32
- package/test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json +0 -22
- package/test/unit/examples/subscriptionRequests/bidirectionalNotification.json +0 -24
- package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRemove.json +0 -3
- package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -22
- package/test/unit/examples/subscriptionRequests/errorNotification.json +0 -24
- package/test/unit/examples/subscriptionRequests/simpleNotification.json +0 -24
- package/test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json +0 -3
- package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json +0 -19
- package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json +0 -19
- package/test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json +0 -6
- package/test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json +0 -6
- package/test/unit/expressions/expressionBasedTransformations-test.js +0 -328
- package/test/unit/expressions/expressionCombinedTransformations-test.js +0 -306
- package/test/unit/expressions/jexlBasedTransformations-test.js +0 -334
- package/test/unit/general/contextBrokerOAuthSecurityAccess-test.js +0 -902
- package/test/unit/general/https-support-test.js +0 -286
- package/test/unit/general/iotam-autoregistration-test.js +0 -368
- package/test/unit/lazyAndCommands/active-devices-attribute-update-test.js +0 -168
- package/test/unit/lazyAndCommands/command-test.js +0 -341
- package/test/unit/lazyAndCommands/lazy-devices-test.js +0 -878
- package/test/unit/lazyAndCommands/polling-commands-test.js +0 -421
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin20.json +0 -25
- package/test/unit/ngsiService/active-devices-test.js +0 -692
- package/test/unit/ngsiService/staticAttributes-test.js +0 -148
- package/test/unit/ngsiService/subscriptions-test.js +0 -345
- package/test/unit/plugins/alias-plugin_test.js +0 -158
- package/test/unit/plugins/bidirectional-plugin_test.js +0 -564
- package/test/unit/plugins/compress-timestamp-plugin_test.js +0 -257
- package/test/unit/plugins/event-plugin_test.js +0 -119
- package/test/unit/plugins/multientity-plugin_test.js +0 -248
- package/test/unit/plugins/timestamp-processing-plugin_test.js +0 -119
- package/test/unit/provisioning/device-provisioning-api_test.js +0 -748
- package/test/unit/provisioning/device-registration_test.js +0 -432
- package/test/unit/provisioning/device-update-registration_test.js +0 -326
- package/test/unit/provisioning/listProvisionedDevices-test.js +0 -488
- package/test/unit/provisioning/provisionDeviceMultientity-test.js +0 -123
- package/test/unit/provisioning/removeProvisionedDevice-test.js +0 -244
- package/test/unit/provisioning/singleConfigurationMode-test.js +0 -346
- package/test/unit/provisioning/updateProvisionedDevices-test.js +0 -436
|
@@ -30,6 +30,7 @@ const utils = require('../../../tools/utils');
|
|
|
30
30
|
const should = require('should');
|
|
31
31
|
const logger = require('logops');
|
|
32
32
|
const nock = require('nock');
|
|
33
|
+
const timekeeper = require('timekeeper');
|
|
33
34
|
let contextBrokerMock;
|
|
34
35
|
const iotAgentConfig = {
|
|
35
36
|
logLevel: 'FATAL',
|
|
@@ -140,6 +141,37 @@ const iotAgentConfig = {
|
|
|
140
141
|
}
|
|
141
142
|
]
|
|
142
143
|
},
|
|
144
|
+
WeatherStationUndef: {
|
|
145
|
+
commands: [],
|
|
146
|
+
type: 'WeatherStation',
|
|
147
|
+
lazy: [],
|
|
148
|
+
active: [
|
|
149
|
+
{
|
|
150
|
+
object_id: 'u',
|
|
151
|
+
name: 'undef',
|
|
152
|
+
type: 'json',
|
|
153
|
+
expression: 'u["no"]'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
object_id: 'n',
|
|
157
|
+
name: 'nil',
|
|
158
|
+
type: 'json',
|
|
159
|
+
expression: 'u["no"]?u["no"]:null'
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
object_id: 'f',
|
|
163
|
+
name: 'falsy',
|
|
164
|
+
type: 'Boolean',
|
|
165
|
+
expression: 'u["no"]?u["no"]:false'
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
object_id: 'z',
|
|
169
|
+
name: 'zero',
|
|
170
|
+
type: 'Number',
|
|
171
|
+
expression: 'u["no"]?u["no"]:0'
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
143
175
|
WeatherStationMultiple: {
|
|
144
176
|
commands: [],
|
|
145
177
|
type: 'WeatherStation',
|
|
@@ -185,15 +217,175 @@ const iotAgentConfig = {
|
|
|
185
217
|
expression: 'updated|trim'
|
|
186
218
|
}
|
|
187
219
|
]
|
|
220
|
+
},
|
|
221
|
+
GPS: {
|
|
222
|
+
commands: [],
|
|
223
|
+
type: 'GPS',
|
|
224
|
+
lazy: [],
|
|
225
|
+
active: [
|
|
226
|
+
{
|
|
227
|
+
name: 'location',
|
|
228
|
+
type: 'geo:json',
|
|
229
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'TimeInstant',
|
|
233
|
+
type: 'DateTime',
|
|
234
|
+
expression: 'ts|toisodate'
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
explicitAttrs: true
|
|
238
|
+
},
|
|
239
|
+
GPS2: {
|
|
240
|
+
commands: [],
|
|
241
|
+
type: 'GPS',
|
|
242
|
+
lazy: [],
|
|
243
|
+
active: [
|
|
244
|
+
{
|
|
245
|
+
name: 'location',
|
|
246
|
+
type: 'geo:json',
|
|
247
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
explicitAttrs: true
|
|
251
|
+
},
|
|
252
|
+
GPS3: {
|
|
253
|
+
commands: [],
|
|
254
|
+
type: 'GPS',
|
|
255
|
+
lazy: [],
|
|
256
|
+
static: [
|
|
257
|
+
{
|
|
258
|
+
name: 'color',
|
|
259
|
+
type: 'string',
|
|
260
|
+
value: 'blue'
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
active: [
|
|
264
|
+
{
|
|
265
|
+
name: 'price',
|
|
266
|
+
type: 'number'
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'location',
|
|
270
|
+
type: 'geo:json',
|
|
271
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
explicitAttrs: '[ "location" ]'
|
|
275
|
+
},
|
|
276
|
+
GPS4: {
|
|
277
|
+
commands: [],
|
|
278
|
+
type: 'GPS',
|
|
279
|
+
lazy: [],
|
|
280
|
+
static: [
|
|
281
|
+
{
|
|
282
|
+
name: 'color',
|
|
283
|
+
type: 'string',
|
|
284
|
+
value: 'blue'
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
active: [
|
|
288
|
+
{
|
|
289
|
+
name: 'price',
|
|
290
|
+
type: 'number'
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: 'location',
|
|
294
|
+
type: 'geo:json',
|
|
295
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
explicitAttrs: '[ "loca" + "tion" ]'
|
|
299
|
+
},
|
|
300
|
+
GPS5: {
|
|
301
|
+
commands: [],
|
|
302
|
+
type: 'GPS',
|
|
303
|
+
lazy: [],
|
|
304
|
+
static: [
|
|
305
|
+
{
|
|
306
|
+
name: 'color',
|
|
307
|
+
type: 'string',
|
|
308
|
+
value: 'blue'
|
|
309
|
+
}
|
|
310
|
+
],
|
|
311
|
+
active: [
|
|
312
|
+
{
|
|
313
|
+
name: 'price',
|
|
314
|
+
type: 'number'
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: 'location',
|
|
318
|
+
type: 'geo:json',
|
|
319
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
explicitAttrs: '[ myattr ]'
|
|
323
|
+
},
|
|
324
|
+
GPS6: {
|
|
325
|
+
commands: [],
|
|
326
|
+
type: 'GPS',
|
|
327
|
+
lazy: [],
|
|
328
|
+
static: [
|
|
329
|
+
{
|
|
330
|
+
name: 'lat',
|
|
331
|
+
type: 'Number',
|
|
332
|
+
value: 52
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: 'lon',
|
|
336
|
+
type: 'Number',
|
|
337
|
+
value: 13
|
|
338
|
+
}
|
|
339
|
+
],
|
|
340
|
+
active: [
|
|
341
|
+
{
|
|
342
|
+
name: 'location',
|
|
343
|
+
type: 'geo:json',
|
|
344
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
explicitAttrs: true
|
|
188
348
|
}
|
|
189
349
|
},
|
|
190
|
-
service: '
|
|
350
|
+
service: 'smartgondor',
|
|
191
351
|
subservice: 'gardens',
|
|
192
|
-
providerUrl: 'http://
|
|
352
|
+
providerUrl: 'http://smartgondor.com',
|
|
193
353
|
deviceRegistrationDuration: 'P1M',
|
|
194
354
|
throttling: 'PT5S'
|
|
195
355
|
};
|
|
196
356
|
|
|
357
|
+
const iotAgentConfigTS = {
|
|
358
|
+
logLevel: 'FATAL',
|
|
359
|
+
contextBroker: {
|
|
360
|
+
host: '192.168.1.1',
|
|
361
|
+
port: '1026',
|
|
362
|
+
ngsiVersion: 'v2'
|
|
363
|
+
},
|
|
364
|
+
defaultExpressionLanguage: 'jexl',
|
|
365
|
+
server: {
|
|
366
|
+
port: 4041
|
|
367
|
+
},
|
|
368
|
+
types: {
|
|
369
|
+
GPS: {
|
|
370
|
+
commands: [],
|
|
371
|
+
type: 'GPS',
|
|
372
|
+
lazy: [],
|
|
373
|
+
active: [
|
|
374
|
+
{
|
|
375
|
+
name: 'location',
|
|
376
|
+
type: 'geo:json',
|
|
377
|
+
expression: "{coordinates: [lon,lat], type: 'Point'}"
|
|
378
|
+
}
|
|
379
|
+
],
|
|
380
|
+
explicitAttrs: true
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
timestamp: true,
|
|
384
|
+
service: 'smartgondor',
|
|
385
|
+
subservice: 'gardens',
|
|
386
|
+
providerUrl: 'http://smartgondor.com'
|
|
387
|
+
};
|
|
388
|
+
|
|
197
389
|
describe('Java expression language (JEXL) based transformations plugin', function () {
|
|
198
390
|
beforeEach(function (done) {
|
|
199
391
|
logger.setLevel('FATAL');
|
|
@@ -253,9 +445,9 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
253
445
|
nock.cleanAll();
|
|
254
446
|
|
|
255
447
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
256
|
-
.matchHeader('fiware-service', '
|
|
448
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
257
449
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
258
|
-
.
|
|
450
|
+
.patch(
|
|
259
451
|
'/v2/entities/ws1/attrs',
|
|
260
452
|
utils.readExampleFile(
|
|
261
453
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json'
|
|
@@ -294,9 +486,9 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
294
486
|
nock.cleanAll();
|
|
295
487
|
|
|
296
488
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
297
|
-
.matchHeader('fiware-service', '
|
|
489
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
298
490
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
299
|
-
.
|
|
491
|
+
.patch(
|
|
300
492
|
'/v2/entities/ws1/attrs',
|
|
301
493
|
utils.readExampleFile(
|
|
302
494
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json'
|
|
@@ -329,9 +521,9 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
329
521
|
nock.cleanAll();
|
|
330
522
|
|
|
331
523
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
332
|
-
.matchHeader('fiware-service', '
|
|
524
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
333
525
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
334
|
-
.
|
|
526
|
+
.patch(
|
|
335
527
|
'/v2/entities/light1/attrs',
|
|
336
528
|
utils.readExampleFile(
|
|
337
529
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json'
|
|
@@ -364,9 +556,9 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
364
556
|
nock.cleanAll();
|
|
365
557
|
|
|
366
558
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
367
|
-
.matchHeader('fiware-service', '
|
|
559
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
368
560
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
369
|
-
.
|
|
561
|
+
.patch(
|
|
370
562
|
'/v2/entities/ws1/attrs',
|
|
371
563
|
utils.readExampleFile(
|
|
372
564
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json'
|
|
@@ -385,13 +577,14 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
385
577
|
});
|
|
386
578
|
});
|
|
387
579
|
|
|
388
|
-
describe('When an update comes for attributes
|
|
389
|
-
// Case: Update for
|
|
580
|
+
describe('When an update comes for attributes without expressions and type float', function () {
|
|
581
|
+
// Case: Update for a Float attribute without expressions
|
|
582
|
+
|
|
390
583
|
const values = [
|
|
391
584
|
{
|
|
392
585
|
name: 'e',
|
|
393
586
|
type: 'Number',
|
|
394
|
-
value:
|
|
587
|
+
value: 0.44
|
|
395
588
|
}
|
|
396
589
|
];
|
|
397
590
|
|
|
@@ -399,20 +592,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
399
592
|
nock.cleanAll();
|
|
400
593
|
|
|
401
594
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
402
|
-
.matchHeader('fiware-service', '
|
|
595
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
403
596
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
404
|
-
.
|
|
405
|
-
'/v2/entities/
|
|
597
|
+
.patch(
|
|
598
|
+
'/v2/entities/light1/attrs',
|
|
406
599
|
utils.readExampleFile(
|
|
407
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
600
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json'
|
|
408
601
|
)
|
|
409
602
|
)
|
|
410
|
-
.query({ type: '
|
|
603
|
+
.query({ type: 'Light' })
|
|
411
604
|
.reply(204);
|
|
412
605
|
});
|
|
413
606
|
|
|
414
607
|
it('should apply the expression before sending the values', function (done) {
|
|
415
|
-
iotAgentLib.update('
|
|
608
|
+
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
416
609
|
should.not.exist(error);
|
|
417
610
|
contextBrokerMock.done();
|
|
418
611
|
done();
|
|
@@ -420,8 +613,8 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
420
613
|
});
|
|
421
614
|
});
|
|
422
615
|
|
|
423
|
-
describe('When an update comes for attributes
|
|
424
|
-
// Case: Update for a Float attribute
|
|
616
|
+
describe('When an update comes for attributes with numeric expressions and type float', function () {
|
|
617
|
+
// Case: Update for a Float attribute with arithmetic expression
|
|
425
618
|
|
|
426
619
|
const values = [
|
|
427
620
|
{
|
|
@@ -435,12 +628,48 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
435
628
|
nock.cleanAll();
|
|
436
629
|
|
|
437
630
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
438
|
-
.matchHeader('fiware-service', '
|
|
631
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
632
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
633
|
+
.patch(
|
|
634
|
+
'/v2/entities/ws1/attrs',
|
|
635
|
+
utils.readExampleFile(
|
|
636
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json'
|
|
637
|
+
)
|
|
638
|
+
)
|
|
639
|
+
.query({ type: 'WeatherStation' })
|
|
640
|
+
.reply(204);
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
it('should apply the expression before sending the values', function (done) {
|
|
644
|
+
iotAgentLib.update('ws1', 'WeatherStation', '', values, function (error) {
|
|
645
|
+
should.not.exist(error);
|
|
646
|
+
contextBrokerMock.done();
|
|
647
|
+
done();
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
describe('When an update comes for attributes without expressions and NULL type', function () {
|
|
653
|
+
// Case: Update for a Null attribute without expression
|
|
654
|
+
|
|
655
|
+
const values = [
|
|
656
|
+
{
|
|
657
|
+
name: 'a',
|
|
658
|
+
type: 'None',
|
|
659
|
+
value: null
|
|
660
|
+
}
|
|
661
|
+
];
|
|
662
|
+
|
|
663
|
+
beforeEach(function () {
|
|
664
|
+
nock.cleanAll();
|
|
665
|
+
|
|
666
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
667
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
439
668
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
440
|
-
.
|
|
669
|
+
.patch(
|
|
441
670
|
'/v2/entities/light1/attrs',
|
|
442
671
|
utils.readExampleFile(
|
|
443
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
672
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json'
|
|
444
673
|
)
|
|
445
674
|
)
|
|
446
675
|
.query({ type: 'Light' })
|
|
@@ -456,14 +685,14 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
456
685
|
});
|
|
457
686
|
});
|
|
458
687
|
|
|
459
|
-
describe('When an update comes for attributes
|
|
460
|
-
// Case: Update for a
|
|
688
|
+
describe('When an update comes for attributes without expressions and Boolean type', function () {
|
|
689
|
+
// Case: Update for a Boolean attribute without expression
|
|
461
690
|
|
|
462
691
|
const values = [
|
|
463
692
|
{
|
|
464
|
-
name: '
|
|
465
|
-
type: '
|
|
466
|
-
value:
|
|
693
|
+
name: 'u',
|
|
694
|
+
type: 'Boolean',
|
|
695
|
+
value: true
|
|
467
696
|
}
|
|
468
697
|
];
|
|
469
698
|
|
|
@@ -471,20 +700,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
471
700
|
nock.cleanAll();
|
|
472
701
|
|
|
473
702
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
474
|
-
.matchHeader('fiware-service', '
|
|
703
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
475
704
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
476
|
-
.
|
|
477
|
-
'/v2/entities/
|
|
705
|
+
.patch(
|
|
706
|
+
'/v2/entities/light1/attrs',
|
|
478
707
|
utils.readExampleFile(
|
|
479
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
708
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json'
|
|
480
709
|
)
|
|
481
710
|
)
|
|
482
|
-
.query({ type: '
|
|
711
|
+
.query({ type: 'Light' })
|
|
483
712
|
.reply(204);
|
|
484
713
|
});
|
|
485
714
|
|
|
486
715
|
it('should apply the expression before sending the values', function (done) {
|
|
487
|
-
iotAgentLib.update('
|
|
716
|
+
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
488
717
|
should.not.exist(error);
|
|
489
718
|
contextBrokerMock.done();
|
|
490
719
|
done();
|
|
@@ -492,14 +721,13 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
492
721
|
});
|
|
493
722
|
});
|
|
494
723
|
|
|
495
|
-
describe('When an update comes for attributes
|
|
496
|
-
// Case: Update for a
|
|
497
|
-
|
|
724
|
+
describe('When an update comes for attributes without expressions and Object type', function () {
|
|
725
|
+
// Case: Update for a JSON document attribute without expression
|
|
498
726
|
const values = [
|
|
499
727
|
{
|
|
500
|
-
name: '
|
|
501
|
-
type: '
|
|
502
|
-
value:
|
|
728
|
+
name: 'm',
|
|
729
|
+
type: 'Object',
|
|
730
|
+
value: { name: 'Manufacturer1', VAT: 'U12345678' }
|
|
503
731
|
}
|
|
504
732
|
];
|
|
505
733
|
|
|
@@ -507,20 +735,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
507
735
|
nock.cleanAll();
|
|
508
736
|
|
|
509
737
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
510
|
-
.matchHeader('fiware-service', '
|
|
738
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
511
739
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
512
|
-
.
|
|
513
|
-
'/v2/entities/
|
|
740
|
+
.patch(
|
|
741
|
+
'/v2/entities/light1/attrs',
|
|
514
742
|
utils.readExampleFile(
|
|
515
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
743
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json'
|
|
516
744
|
)
|
|
517
745
|
)
|
|
518
|
-
.query({ type: '
|
|
746
|
+
.query({ type: 'Light' })
|
|
519
747
|
.reply(204);
|
|
520
748
|
});
|
|
521
749
|
|
|
522
750
|
it('should apply the expression before sending the values', function (done) {
|
|
523
|
-
iotAgentLib.update('
|
|
751
|
+
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
524
752
|
should.not.exist(error);
|
|
525
753
|
contextBrokerMock.done();
|
|
526
754
|
done();
|
|
@@ -528,14 +756,14 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
528
756
|
});
|
|
529
757
|
});
|
|
530
758
|
|
|
531
|
-
describe('When an update comes for attributes without expressions and
|
|
532
|
-
// Case: Update for a
|
|
759
|
+
describe('When an update comes for attributes without expressions and Object type', function () {
|
|
760
|
+
// Case: Update for a JSON array attribute without expression
|
|
533
761
|
|
|
534
762
|
const values = [
|
|
535
763
|
{
|
|
536
|
-
name: '
|
|
537
|
-
type: '
|
|
538
|
-
value:
|
|
764
|
+
name: 'r',
|
|
765
|
+
type: 'Object',
|
|
766
|
+
value: ['v0.1', 'v0.2', 'v0.3']
|
|
539
767
|
}
|
|
540
768
|
];
|
|
541
769
|
|
|
@@ -543,12 +771,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
543
771
|
nock.cleanAll();
|
|
544
772
|
|
|
545
773
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
546
|
-
.matchHeader('fiware-service', '
|
|
774
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
547
775
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
548
|
-
.
|
|
776
|
+
.patch(
|
|
549
777
|
'/v2/entities/light1/attrs',
|
|
550
778
|
utils.readExampleFile(
|
|
551
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
779
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json'
|
|
552
780
|
)
|
|
553
781
|
)
|
|
554
782
|
.query({ type: 'Light' })
|
|
@@ -564,14 +792,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
564
792
|
});
|
|
565
793
|
});
|
|
566
794
|
|
|
567
|
-
describe('When
|
|
568
|
-
// Case: Update for a Null attribute with arithmetic expression
|
|
569
|
-
|
|
795
|
+
describe('When there are expressions including other attributes and they are not updated', function () {
|
|
570
796
|
const values = [
|
|
571
797
|
{
|
|
572
|
-
name: '
|
|
573
|
-
type: '
|
|
574
|
-
value:
|
|
798
|
+
name: 'x',
|
|
799
|
+
type: 'Number',
|
|
800
|
+
value: 0.44
|
|
575
801
|
}
|
|
576
802
|
];
|
|
577
803
|
|
|
@@ -579,20 +805,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
579
805
|
nock.cleanAll();
|
|
580
806
|
|
|
581
807
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
582
|
-
.matchHeader('fiware-service', '
|
|
808
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
583
809
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
584
|
-
.
|
|
585
|
-
'/v2/entities/
|
|
810
|
+
.patch(
|
|
811
|
+
'/v2/entities/light1/attrs',
|
|
586
812
|
utils.readExampleFile(
|
|
587
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
813
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json'
|
|
588
814
|
)
|
|
589
815
|
)
|
|
590
|
-
.query({ type: '
|
|
816
|
+
.query({ type: 'Light' })
|
|
591
817
|
.reply(204);
|
|
592
818
|
});
|
|
593
819
|
|
|
594
820
|
it('should apply the expression before sending the values', function (done) {
|
|
595
|
-
iotAgentLib.update('
|
|
821
|
+
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
596
822
|
should.not.exist(error);
|
|
597
823
|
contextBrokerMock.done();
|
|
598
824
|
done();
|
|
@@ -600,14 +826,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
600
826
|
});
|
|
601
827
|
});
|
|
602
828
|
|
|
603
|
-
describe('When
|
|
604
|
-
// Case: Update for a Null attribute with string expression
|
|
605
|
-
|
|
829
|
+
describe('When there are expressions including other attributes and they are updated', function () {
|
|
606
830
|
const values = [
|
|
607
831
|
{
|
|
608
|
-
name: '
|
|
609
|
-
type: '
|
|
610
|
-
value:
|
|
832
|
+
name: 'p',
|
|
833
|
+
type: 'Number',
|
|
834
|
+
value: 10
|
|
611
835
|
}
|
|
612
836
|
];
|
|
613
837
|
|
|
@@ -615,20 +839,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
615
839
|
nock.cleanAll();
|
|
616
840
|
|
|
617
841
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
618
|
-
.matchHeader('fiware-service', '
|
|
842
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
619
843
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
620
|
-
.
|
|
621
|
-
'/v2/entities/
|
|
844
|
+
.patch(
|
|
845
|
+
'/v2/entities/light1/attrs',
|
|
622
846
|
utils.readExampleFile(
|
|
623
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
847
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
|
|
624
848
|
)
|
|
625
849
|
)
|
|
626
|
-
.query({ type: '
|
|
850
|
+
.query({ type: 'Light' })
|
|
627
851
|
.reply(204);
|
|
628
852
|
});
|
|
629
853
|
|
|
630
854
|
it('should apply the expression before sending the values', function (done) {
|
|
631
|
-
iotAgentLib.update('
|
|
855
|
+
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
632
856
|
should.not.exist(error);
|
|
633
857
|
contextBrokerMock.done();
|
|
634
858
|
done();
|
|
@@ -636,14 +860,17 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
636
860
|
});
|
|
637
861
|
});
|
|
638
862
|
|
|
639
|
-
describe('When
|
|
640
|
-
// Case: Update for a Boolean attribute without expression
|
|
641
|
-
|
|
863
|
+
describe('When there are expressions including other attributes and they are updated (overriding situation)', function () {
|
|
642
864
|
const values = [
|
|
643
865
|
{
|
|
644
|
-
name: '
|
|
645
|
-
type: '
|
|
646
|
-
value:
|
|
866
|
+
name: 'x',
|
|
867
|
+
type: 'Number',
|
|
868
|
+
value: 0.44
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
name: 'p',
|
|
872
|
+
type: 'Number',
|
|
873
|
+
value: 10
|
|
647
874
|
}
|
|
648
875
|
];
|
|
649
876
|
|
|
@@ -651,12 +878,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
651
878
|
nock.cleanAll();
|
|
652
879
|
|
|
653
880
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
654
|
-
.matchHeader('fiware-service', '
|
|
881
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
655
882
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
656
|
-
.
|
|
883
|
+
.patch(
|
|
657
884
|
'/v2/entities/light1/attrs',
|
|
658
885
|
utils.readExampleFile(
|
|
659
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
886
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
|
|
660
887
|
)
|
|
661
888
|
)
|
|
662
889
|
.query({ type: 'Light' })
|
|
@@ -672,14 +899,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
672
899
|
});
|
|
673
900
|
});
|
|
674
901
|
|
|
675
|
-
describe('When
|
|
676
|
-
// Case: Update for a Boolean attribute with arithmetic expression
|
|
677
|
-
|
|
902
|
+
describe('When a measure arrives and there is not enough information to calculate an expression', function () {
|
|
678
903
|
const values = [
|
|
679
904
|
{
|
|
680
|
-
name: '
|
|
681
|
-
type: '
|
|
682
|
-
value:
|
|
905
|
+
name: 'p',
|
|
906
|
+
type: 'centigrades',
|
|
907
|
+
value: '52'
|
|
683
908
|
}
|
|
684
909
|
];
|
|
685
910
|
|
|
@@ -687,19 +912,19 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
687
912
|
nock.cleanAll();
|
|
688
913
|
|
|
689
914
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
690
|
-
.matchHeader('fiware-service', '
|
|
915
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
691
916
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
692
|
-
.
|
|
917
|
+
.patch(
|
|
693
918
|
'/v2/entities/ws1/attrs',
|
|
694
919
|
utils.readExampleFile(
|
|
695
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
920
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json'
|
|
696
921
|
)
|
|
697
922
|
)
|
|
698
923
|
.query({ type: 'WeatherStation' })
|
|
699
924
|
.reply(204);
|
|
700
925
|
});
|
|
701
926
|
|
|
702
|
-
it('should
|
|
927
|
+
it('should not calculate the expression', function (done) {
|
|
703
928
|
iotAgentLib.update('ws1', 'WeatherStation', '', values, function (error) {
|
|
704
929
|
should.not.exist(error);
|
|
705
930
|
contextBrokerMock.done();
|
|
@@ -707,14 +932,12 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
707
932
|
});
|
|
708
933
|
});
|
|
709
934
|
});
|
|
710
|
-
|
|
711
|
-
describe('When an update comes for attributes with string expressions and Boolean type', function () {
|
|
712
|
-
// Case: Update for a Boolean attribute with string expression
|
|
935
|
+
describe('When a measure arrives and there is not enough information to calculate an expression', function () {
|
|
713
936
|
const values = [
|
|
714
937
|
{
|
|
715
938
|
name: 'u',
|
|
716
|
-
type: '
|
|
717
|
-
value:
|
|
939
|
+
type: 'json',
|
|
940
|
+
value: '{}'
|
|
718
941
|
}
|
|
719
942
|
];
|
|
720
943
|
|
|
@@ -722,20 +945,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
722
945
|
nock.cleanAll();
|
|
723
946
|
|
|
724
947
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
725
|
-
.matchHeader('fiware-service', '
|
|
948
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
726
949
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
727
|
-
.
|
|
950
|
+
.patch(
|
|
728
951
|
'/v2/entities/ws1/attrs',
|
|
729
952
|
utils.readExampleFile(
|
|
730
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
953
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json'
|
|
731
954
|
)
|
|
732
955
|
)
|
|
733
956
|
.query({ type: 'WeatherStation' })
|
|
734
957
|
.reply(204);
|
|
735
958
|
});
|
|
736
959
|
|
|
737
|
-
it('should
|
|
738
|
-
iotAgentLib.update('ws1', '
|
|
960
|
+
it('should not calculate the expression and allow falsy values', function (done) {
|
|
961
|
+
iotAgentLib.update('ws1', 'WeatherStationUndef', '', values, function (error) {
|
|
739
962
|
should.not.exist(error);
|
|
740
963
|
contextBrokerMock.done();
|
|
741
964
|
done();
|
|
@@ -743,13 +966,23 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
743
966
|
});
|
|
744
967
|
});
|
|
745
968
|
|
|
746
|
-
describe('When
|
|
747
|
-
// Case:
|
|
969
|
+
describe('When there are additional attributes sent by the device to be calculated and removed', function () {
|
|
970
|
+
// Case: Expression which results is sent as a new attribute
|
|
748
971
|
const values = [
|
|
749
972
|
{
|
|
750
|
-
name: '
|
|
751
|
-
type: '
|
|
752
|
-
value:
|
|
973
|
+
name: 'lat',
|
|
974
|
+
type: 'Number',
|
|
975
|
+
value: 52
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
name: 'lon',
|
|
979
|
+
type: 'Number',
|
|
980
|
+
value: 13
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
name: 'ts',
|
|
984
|
+
type: 'Number',
|
|
985
|
+
value: 1
|
|
753
986
|
}
|
|
754
987
|
];
|
|
755
988
|
|
|
@@ -757,20 +990,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
757
990
|
nock.cleanAll();
|
|
758
991
|
|
|
759
992
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
760
|
-
.matchHeader('fiware-service', '
|
|
993
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
761
994
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
762
|
-
.
|
|
763
|
-
'/v2/entities/
|
|
995
|
+
.patch(
|
|
996
|
+
'/v2/entities/gps1/attrs',
|
|
764
997
|
utils.readExampleFile(
|
|
765
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
998
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json'
|
|
766
999
|
)
|
|
767
1000
|
)
|
|
768
|
-
.query({ type: '
|
|
1001
|
+
.query({ type: 'GPS' })
|
|
769
1002
|
.reply(204);
|
|
770
1003
|
});
|
|
771
1004
|
|
|
772
|
-
it('should
|
|
773
|
-
iotAgentLib.update('
|
|
1005
|
+
it('should calculate them and remove non-explicitAttrs from the payload', function (done) {
|
|
1006
|
+
iotAgentLib.update('gps1', 'GPS', '', values, function (error) {
|
|
774
1007
|
should.not.exist(error);
|
|
775
1008
|
contextBrokerMock.done();
|
|
776
1009
|
done();
|
|
@@ -778,14 +1011,68 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
778
1011
|
});
|
|
779
1012
|
});
|
|
780
1013
|
|
|
781
|
-
describe('When an
|
|
782
|
-
// Case:
|
|
1014
|
+
describe('When there is an extra TimeInstant sent by the device to be removed', function () {
|
|
1015
|
+
// Case: Expression which results is sent as a new attribute
|
|
1016
|
+
const values = [
|
|
1017
|
+
{
|
|
1018
|
+
name: 'lat',
|
|
1019
|
+
type: 'Number',
|
|
1020
|
+
value: 52
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
name: 'lon',
|
|
1024
|
+
type: 'Number',
|
|
1025
|
+
value: 13
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
name: 'TimeInstant',
|
|
1029
|
+
type: 'DateTime',
|
|
1030
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
1031
|
+
}
|
|
1032
|
+
];
|
|
1033
|
+
|
|
1034
|
+
beforeEach(function () {
|
|
1035
|
+
nock.cleanAll();
|
|
1036
|
+
|
|
1037
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1038
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1039
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1040
|
+
.patch(
|
|
1041
|
+
'/v2/entities/gps1/attrs',
|
|
1042
|
+
utils.readExampleFile(
|
|
1043
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
1044
|
+
)
|
|
1045
|
+
)
|
|
1046
|
+
.query({ type: 'GPS' })
|
|
1047
|
+
.reply(204);
|
|
1048
|
+
});
|
|
783
1049
|
|
|
1050
|
+
it('should calculate them and remove non-explicitAttrs from the payload', function (done) {
|
|
1051
|
+
iotAgentLib.update('gps1', 'GPS2', '', values, function (error) {
|
|
1052
|
+
should.not.exist(error);
|
|
1053
|
+
contextBrokerMock.done();
|
|
1054
|
+
done();
|
|
1055
|
+
});
|
|
1056
|
+
});
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
describe('When there is an extra TimeInstant sent by the device to be removed by string', function () {
|
|
1060
|
+
// Case: Expression which results is sent as a new attribute
|
|
784
1061
|
const values = [
|
|
785
1062
|
{
|
|
786
|
-
name: '
|
|
787
|
-
type: '
|
|
788
|
-
value:
|
|
1063
|
+
name: 'lat',
|
|
1064
|
+
type: 'Number',
|
|
1065
|
+
value: 52
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
name: 'lon',
|
|
1069
|
+
type: 'Number',
|
|
1070
|
+
value: 13
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
name: 'TimeInstant',
|
|
1074
|
+
type: 'DateTime',
|
|
1075
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
789
1076
|
}
|
|
790
1077
|
];
|
|
791
1078
|
|
|
@@ -793,20 +1080,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
793
1080
|
nock.cleanAll();
|
|
794
1081
|
|
|
795
1082
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
796
|
-
.matchHeader('fiware-service', '
|
|
1083
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
797
1084
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
798
|
-
.
|
|
799
|
-
'/v2/entities/
|
|
1085
|
+
.patch(
|
|
1086
|
+
'/v2/entities/gps1/attrs',
|
|
800
1087
|
utils.readExampleFile(
|
|
801
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
1088
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
802
1089
|
)
|
|
803
1090
|
)
|
|
804
|
-
.query({ type: '
|
|
1091
|
+
.query({ type: 'GPS' })
|
|
805
1092
|
.reply(204);
|
|
806
1093
|
});
|
|
807
1094
|
|
|
808
|
-
it('should
|
|
809
|
-
iotAgentLib.update('
|
|
1095
|
+
it('should calculate them and remove non-explicitAttrs by string from the payload', function (done) {
|
|
1096
|
+
iotAgentLib.update('gps1', 'GPS3', '', values, function (error) {
|
|
810
1097
|
should.not.exist(error);
|
|
811
1098
|
contextBrokerMock.done();
|
|
812
1099
|
done();
|
|
@@ -814,12 +1101,23 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
814
1101
|
});
|
|
815
1102
|
});
|
|
816
1103
|
|
|
817
|
-
describe('When there
|
|
1104
|
+
describe('When there is an extra TimeInstant sent by the device to be removed by jexl expression', function () {
|
|
1105
|
+
// Case: Expression which results is sent as a new attribute
|
|
818
1106
|
const values = [
|
|
819
1107
|
{
|
|
820
|
-
name: '
|
|
1108
|
+
name: 'lat',
|
|
821
1109
|
type: 'Number',
|
|
822
|
-
value:
|
|
1110
|
+
value: 52
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
name: 'lon',
|
|
1114
|
+
type: 'Number',
|
|
1115
|
+
value: 13
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
name: 'TimeInstant',
|
|
1119
|
+
type: 'DateTime',
|
|
1120
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
823
1121
|
}
|
|
824
1122
|
];
|
|
825
1123
|
|
|
@@ -827,20 +1125,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
827
1125
|
nock.cleanAll();
|
|
828
1126
|
|
|
829
1127
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
830
|
-
.matchHeader('fiware-service', '
|
|
1128
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
831
1129
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
832
|
-
.
|
|
833
|
-
'/v2/entities/
|
|
1130
|
+
.patch(
|
|
1131
|
+
'/v2/entities/gps1/attrs',
|
|
834
1132
|
utils.readExampleFile(
|
|
835
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
1133
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
836
1134
|
)
|
|
837
1135
|
)
|
|
838
|
-
.query({ type: '
|
|
1136
|
+
.query({ type: 'GPS' })
|
|
839
1137
|
.reply(204);
|
|
840
1138
|
});
|
|
841
1139
|
|
|
842
|
-
it('should
|
|
843
|
-
iotAgentLib.update('
|
|
1140
|
+
it('should calculate them and remove non-explicitAttrs by jexl expression from the payload', function (done) {
|
|
1141
|
+
iotAgentLib.update('gps1', 'GPS4', '', values, function (error) {
|
|
844
1142
|
should.not.exist(error);
|
|
845
1143
|
contextBrokerMock.done();
|
|
846
1144
|
done();
|
|
@@ -848,12 +1146,28 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
848
1146
|
});
|
|
849
1147
|
});
|
|
850
1148
|
|
|
851
|
-
describe('When there
|
|
1149
|
+
describe('When there is an extra TimeInstant sent by the device to be removed by jexl expression with context ', function () {
|
|
1150
|
+
// Case: Expression which results is sent as a new attribute
|
|
852
1151
|
const values = [
|
|
853
1152
|
{
|
|
854
|
-
name: '
|
|
1153
|
+
name: 'lat',
|
|
855
1154
|
type: 'Number',
|
|
856
|
-
value:
|
|
1155
|
+
value: 52
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
name: 'lon',
|
|
1159
|
+
type: 'Number',
|
|
1160
|
+
value: 13
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
name: 'myattr',
|
|
1164
|
+
type: 'String',
|
|
1165
|
+
value: 'location'
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
name: 'TimeInstant',
|
|
1169
|
+
type: 'DateTime',
|
|
1170
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
857
1171
|
}
|
|
858
1172
|
];
|
|
859
1173
|
|
|
@@ -861,20 +1175,20 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
861
1175
|
nock.cleanAll();
|
|
862
1176
|
|
|
863
1177
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
864
|
-
.matchHeader('fiware-service', '
|
|
1178
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
865
1179
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
866
|
-
.
|
|
867
|
-
'/v2/entities/
|
|
1180
|
+
.patch(
|
|
1181
|
+
'/v2/entities/gps1/attrs',
|
|
868
1182
|
utils.readExampleFile(
|
|
869
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
1183
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
870
1184
|
)
|
|
871
1185
|
)
|
|
872
|
-
.query({ type: '
|
|
1186
|
+
.query({ type: 'GPS' })
|
|
873
1187
|
.reply(204);
|
|
874
1188
|
});
|
|
875
1189
|
|
|
876
|
-
it('should
|
|
877
|
-
iotAgentLib.update('
|
|
1190
|
+
it('should calculate them and remove non-explicitAttrs by jexl expression with context from the payload ', function (done) {
|
|
1191
|
+
iotAgentLib.update('gps1', 'GPS5', '', values, function (error) {
|
|
878
1192
|
should.not.exist(error);
|
|
879
1193
|
contextBrokerMock.done();
|
|
880
1194
|
done();
|
|
@@ -882,38 +1196,108 @@ describe('Java expression language (JEXL) based transformations plugin', functio
|
|
|
882
1196
|
});
|
|
883
1197
|
});
|
|
884
1198
|
|
|
885
|
-
describe('When there
|
|
1199
|
+
describe('When there is an extra TimeInstant sent by the device to be removedb jexl expression using static attrs', function () {
|
|
1200
|
+
// Case: Expression which results is sent as a new attribute
|
|
886
1201
|
const values = [
|
|
887
1202
|
{
|
|
888
|
-
name: '
|
|
1203
|
+
name: 'TimeInstant',
|
|
1204
|
+
type: 'DateTime',
|
|
1205
|
+
value: '2015-08-05T07:35:01.468+00:00'
|
|
1206
|
+
}
|
|
1207
|
+
];
|
|
1208
|
+
|
|
1209
|
+
beforeEach(function () {
|
|
1210
|
+
nock.cleanAll();
|
|
1211
|
+
|
|
1212
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1213
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1214
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1215
|
+
.patch(
|
|
1216
|
+
'/v2/entities/gps1/attrs',
|
|
1217
|
+
utils.readExampleFile(
|
|
1218
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
|
|
1219
|
+
)
|
|
1220
|
+
)
|
|
1221
|
+
.query({ type: 'GPS' })
|
|
1222
|
+
.reply(204);
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
it('should calculate them and remove non-explicitAttrs from the payload', function (done) {
|
|
1226
|
+
iotAgentLib.update('gps1', 'GPS6', '', values, function (error) {
|
|
1227
|
+
should.not.exist(error);
|
|
1228
|
+
contextBrokerMock.done();
|
|
1229
|
+
done();
|
|
1230
|
+
});
|
|
1231
|
+
});
|
|
1232
|
+
});
|
|
1233
|
+
});
|
|
1234
|
+
|
|
1235
|
+
describe('Java expression language (JEXL) based transformations plugin - Timestamps', function () {
|
|
1236
|
+
beforeEach(function (done) {
|
|
1237
|
+
logger.setLevel('FATAL');
|
|
1238
|
+
|
|
1239
|
+
iotAgentLib.activate(iotAgentConfigTS, function () {
|
|
1240
|
+
iotAgentLib.clearAll(function () {
|
|
1241
|
+
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.attributeAlias.update);
|
|
1242
|
+
iotAgentLib.addQueryMiddleware(iotAgentLib.dataPlugins.attributeAlias.query);
|
|
1243
|
+
iotAgentLib.addUpdateMiddleware(iotAgentLib.dataPlugins.expressionTransformation.update);
|
|
1244
|
+
done();
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
afterEach(function (done) {
|
|
1250
|
+
iotAgentLib.clearAll(function () {
|
|
1251
|
+
iotAgentLib.deactivate(done);
|
|
1252
|
+
});
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1255
|
+
describe('When timestamps are added but are not explicitly defined', function () {
|
|
1256
|
+
// Case: Expression which results is sent as a new attribute
|
|
1257
|
+
const values = [
|
|
1258
|
+
{
|
|
1259
|
+
name: 'lat',
|
|
889
1260
|
type: 'Number',
|
|
890
|
-
value:
|
|
1261
|
+
value: 52
|
|
891
1262
|
},
|
|
892
1263
|
{
|
|
893
|
-
name: '
|
|
1264
|
+
name: 'lon',
|
|
894
1265
|
type: 'Number',
|
|
895
|
-
value:
|
|
1266
|
+
value: 13
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
name: 'ts',
|
|
1270
|
+
type: 'Number',
|
|
1271
|
+
value: 1
|
|
896
1272
|
}
|
|
897
1273
|
];
|
|
898
1274
|
|
|
899
1275
|
beforeEach(function () {
|
|
1276
|
+
const time = new Date(1438760101468); // 2015-08-05T07:35:01.468+00:00
|
|
1277
|
+
|
|
1278
|
+
timekeeper.freeze(time);
|
|
900
1279
|
nock.cleanAll();
|
|
901
1280
|
|
|
902
1281
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
903
|
-
.matchHeader('fiware-service', '
|
|
1282
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
904
1283
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
905
|
-
.
|
|
906
|
-
'/v2/entities/
|
|
1284
|
+
.patch(
|
|
1285
|
+
'/v2/entities/gps1/attrs',
|
|
907
1286
|
utils.readExampleFile(
|
|
908
|
-
'./test/unit/ngsiv2/examples/contextRequests/
|
|
1287
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json'
|
|
909
1288
|
)
|
|
910
1289
|
)
|
|
911
|
-
.query({ type: '
|
|
1290
|
+
.query({ type: 'GPS' })
|
|
912
1291
|
.reply(204);
|
|
913
1292
|
});
|
|
914
1293
|
|
|
915
|
-
|
|
916
|
-
|
|
1294
|
+
afterEach(function (done) {
|
|
1295
|
+
timekeeper.reset();
|
|
1296
|
+
done();
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
it('should calculate them and not remove the timestamp from the payload', function (done) {
|
|
1300
|
+
iotAgentLib.update('gps1', 'GPS', '', values, function (error) {
|
|
917
1301
|
should.not.exist(error);
|
|
918
1302
|
contextBrokerMock.done();
|
|
919
1303
|
done();
|