iotagent-node-lib 2.17.0 → 2.20.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 -2
- package/.nyc_output/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +1 -0
- package/.nyc_output/processinfo/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGES_NEXT_RELEASE +1 -0
- package/README.md +3 -54
- package/doc/advanced-topics.md +121 -85
- package/doc/api.md +52 -52
- package/doc/development.md +13 -6
- package/doc/expressionLanguage.md +514 -312
- package/doc/installationguide.md +66 -64
- package/doc/usermanual.md +48 -16
- package/docker/Mosquitto/Dockerfile +1 -0
- package/docker/Mosquitto/README.md +1 -0
- package/docker/Mosquitto/startMosquitto.sh +9 -4
- package/lib/commonConfig.js +1 -14
- package/lib/errors.js +0 -16
- package/lib/fiware-iotagent-lib.js +4 -2
- package/lib/jexlTranformsMap.js +13 -2
- package/lib/model/Device.js +4 -1
- package/lib/model/Group.js +19 -1
- package/lib/plugins/attributeAlias.js +6 -13
- package/lib/plugins/bidirectionalData.js +1 -21
- package/lib/plugins/expressionParser.js +7 -6
- package/lib/plugins/expressionPlugin.js +11 -25
- package/lib/plugins/jexlParser.js +8 -4
- package/lib/plugins/multiEntity.js +54 -145
- 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 +6 -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 +2 -0
- package/lib/services/devices/deviceService.js +2 -5
- package/lib/services/devices/devices-NGSI-LD.js +1 -1
- package/lib/services/devices/devices-NGSI-v2.js +4 -8
- package/lib/services/devices/registrationUtils.js +1 -134
- package/lib/services/ngsi/entities-NGSI-LD.js +205 -124
- package/lib/services/ngsi/entities-NGSI-v2.js +109 -15
- package/lib/services/ngsi/ngsiService.js +4 -6
- package/lib/services/ngsi/ngsiUtils.js +0 -36
- 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 +24 -12
- package/lib/services/northBound/contextServer.js +1 -4
- package/lib/services/northBound/contextServerUtils.js +0 -81
- package/lib/services/northBound/deviceProvisioningServer.js +31 -7
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/northBound/restUtils.js +1 -38
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +10 -16
- package/test/tools/utils.js +2 -0
- package/test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json +1 -1
- package/test/unit/expressions/jexlExpression-test.js +44 -5
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +19 -66
- package/test/unit/general/deviceService-test.js +11 -27
- package/test/unit/general/loglevel-api_test.js +6 -11
- package/test/unit/general/startup-test.js +2 -1
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +8 -16
- package/test/unit/mongodb/mongodb-group-registry-test.js +1 -1
- package/test/unit/mongodb/mongodb-registry-test.js +38 -114
- 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/expressions/jexlBasedTransformations-test.js +1018 -0
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
- package/test/unit/ngsi-ld/general/deviceService-test.js +1 -1
- package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsi-ld/general/startup-test.js +1 -0
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +2 -6
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +1 -0
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +61 -0
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +42 -54
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +3 -5
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +12 -18
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +3 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent3.json +19 -0
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent5.json +19 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +22 -0
- 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/updateContextMiddleware1.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware2.json +10 -0
- 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/updateContextMultientityTimestampPlugin1.json +6 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +3 -3
- package/test/unit/{examples → ngsiv2/examples}/contextRequests/updateProvisionDevice.json +0 -0
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +37 -4
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +598 -0
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +3 -2
- package/test/unit/ngsiv2/general/deviceService-test.js +9 -8
- package/test/unit/ngsiv2/general/https-support-test.js +2 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsiv2/general/startup-test.js +1 -0
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +287 -15
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +3 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +88 -0
- package/test/unit/{ngsiService → ngsiv2/ngsiService}/queryDeviceInformationInCb-test.js +20 -49
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +526 -0
- package/test/unit/{plugins → ngsiv2/plugins}/translation-inPlugins_test.js +21 -21
- package/test/unit/{provisioning → ngsiv2/provisioning}/device-group-api-test.js +19 -50
- package/test/unit/{provisioning/device-group-utils_test.js → ngsiv2/provisioning/device-group-utils-test.js} +5 -4
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -3
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +42 -53
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +3 -4
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +14 -20
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +3 -1
- package/test/unit/plugins/capture-provision-inPlugins_test.js +8 -18
- package/.eslintcache +0 -1
- package/.nyc_output/dca24ca1-851e-490c-9d34-8d13b3330297.json +0 -1
- package/.nyc_output/processinfo/dca24ca1-851e-490c-9d34-8d13b3330297.json +0 -1
- package/bin/agentConsole.js +0 -257
- package/bin/iotAgentTester.js +0 -44
- package/lib/command/commandLine.js +0 -918
- package/lib/command/migration.js +0 -176
- package/lib/services/devices/devices-NGSI-v1.js +0 -310
- package/lib/services/ngsi/entities-NGSI-v1.js +0 -299
- 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 -26
- 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 -32
- 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/updateContextExpressionPlugin10.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/updateContextExpressionPlugin6.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin7.json +0 -27
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin8.json +0 -22
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin9.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 -42
- 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/general/migration-test.js +0 -256
- 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
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const utils = require('../../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const should = require('should');
|
|
31
32
|
const logger = require('logops');
|
|
32
33
|
const nock = require('nock');
|
|
@@ -242,6 +243,46 @@ const iotAgentConfig = {
|
|
|
242
243
|
}
|
|
243
244
|
]
|
|
244
245
|
},
|
|
246
|
+
WeatherStation9Jexl: {
|
|
247
|
+
commands: [],
|
|
248
|
+
type: 'WeatherStation',
|
|
249
|
+
expressionLanguage: 'jexl',
|
|
250
|
+
lazy: [],
|
|
251
|
+
static: [
|
|
252
|
+
{
|
|
253
|
+
name: 'st1',
|
|
254
|
+
type: 'Number',
|
|
255
|
+
value: 1
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'st2',
|
|
259
|
+
type: 'Number',
|
|
260
|
+
value: 2
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
active: [
|
|
264
|
+
{
|
|
265
|
+
object_id: 'v1',
|
|
266
|
+
name: 'vol',
|
|
267
|
+
expression: 'st1 * 100',
|
|
268
|
+
type: 'Number',
|
|
269
|
+
entity_name: 'WeatherStation1'
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
object_id: 'v2',
|
|
273
|
+
name: 'vol',
|
|
274
|
+
expression: 'st2 * 100',
|
|
275
|
+
type: 'Number',
|
|
276
|
+
entity_name: 'WeatherStation2'
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
object_id: 'v',
|
|
280
|
+
name: 'vol',
|
|
281
|
+
expression: 'v * 100',
|
|
282
|
+
type: 'Number'
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
},
|
|
245
286
|
Sensor001: {
|
|
246
287
|
commands: [],
|
|
247
288
|
type: 'Sensor',
|
|
@@ -293,6 +334,187 @@ const iotAgentConfig = {
|
|
|
293
334
|
],
|
|
294
335
|
type: 'SensorCommand',
|
|
295
336
|
lazy: []
|
|
337
|
+
},
|
|
338
|
+
WrongStation: {
|
|
339
|
+
commands: [],
|
|
340
|
+
type: 'WrongStation',
|
|
341
|
+
expressionLanguage: 'jexl',
|
|
342
|
+
lazy: [],
|
|
343
|
+
active: [
|
|
344
|
+
{
|
|
345
|
+
object_id: 'v1',
|
|
346
|
+
name: 'type',
|
|
347
|
+
type: 'string',
|
|
348
|
+
entity_name: 'WrongStation1'
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
object_id: 'v2',
|
|
352
|
+
name: 'id',
|
|
353
|
+
type: 'string',
|
|
354
|
+
entity_name: 'WrongStation1'
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
object_id: 'v',
|
|
358
|
+
name: 'vol',
|
|
359
|
+
type: 'Number',
|
|
360
|
+
entity_name: 'WrongStation1'
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
},
|
|
364
|
+
SharedIds1: {
|
|
365
|
+
commands: [],
|
|
366
|
+
type: 'ShareStation',
|
|
367
|
+
lazy: [],
|
|
368
|
+
active: [
|
|
369
|
+
{
|
|
370
|
+
object_id: 'v1',
|
|
371
|
+
name: 'volt1',
|
|
372
|
+
type: 'Number',
|
|
373
|
+
entity_name: 'WeatherStation1',
|
|
374
|
+
entity_type: 'Type1'
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
object_id: 'v2',
|
|
378
|
+
name: 'volt2',
|
|
379
|
+
type: 'Number',
|
|
380
|
+
entity_name: 'WeatherStation1',
|
|
381
|
+
entity_type: 'Type2'
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
object_id: 'v3',
|
|
385
|
+
name: 'extravolt2',
|
|
386
|
+
type: 'Number',
|
|
387
|
+
entity_name: 'WeatherStation1',
|
|
388
|
+
entity_type: 'Type2'
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
object_id: 'v',
|
|
392
|
+
name: 'vol',
|
|
393
|
+
type: 'Number'
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
},
|
|
397
|
+
SharedIds2: {
|
|
398
|
+
commands: [],
|
|
399
|
+
type: 'ShareStation',
|
|
400
|
+
lazy: [],
|
|
401
|
+
active: [
|
|
402
|
+
{
|
|
403
|
+
object_id: 'v1',
|
|
404
|
+
name: 'vol',
|
|
405
|
+
type: 'Number',
|
|
406
|
+
entity_name: 'WeatherStation1',
|
|
407
|
+
entity_type: 'Type1'
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
object_id: 'v2',
|
|
411
|
+
name: 'vol',
|
|
412
|
+
type: 'Number',
|
|
413
|
+
entity_name: 'WeatherStation1',
|
|
414
|
+
entity_type: 'Type2'
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
object_id: 'v3',
|
|
418
|
+
name: 'extravol',
|
|
419
|
+
type: 'Number',
|
|
420
|
+
entity_name: 'WeatherStation1',
|
|
421
|
+
entity_type: 'Type2'
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
object_id: 'v',
|
|
425
|
+
name: 'vol',
|
|
426
|
+
type: 'Number'
|
|
427
|
+
}
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
SharedIds3: {
|
|
431
|
+
commands: [],
|
|
432
|
+
type: 'ShareStation',
|
|
433
|
+
expressionLanguage: 'jexl',
|
|
434
|
+
lazy: [],
|
|
435
|
+
active: [
|
|
436
|
+
{
|
|
437
|
+
object_id: 'fakev1',
|
|
438
|
+
expression: 'v',
|
|
439
|
+
name: 'vol',
|
|
440
|
+
type: 'Number',
|
|
441
|
+
entity_name: 'WeatherStation1',
|
|
442
|
+
entity_type: 'Type1'
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
object_id: 'fakev2',
|
|
446
|
+
expression: 'v',
|
|
447
|
+
name: 'vol',
|
|
448
|
+
type: 'Number',
|
|
449
|
+
entity_name: 'WeatherStation1',
|
|
450
|
+
entity_type: 'Type2'
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
object_id: 'fakev3',
|
|
454
|
+
expression: 'v',
|
|
455
|
+
name: 'extravol',
|
|
456
|
+
type: 'Number',
|
|
457
|
+
entity_name: 'WeatherStation1',
|
|
458
|
+
entity_type: 'Type2'
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
object_id: 'v',
|
|
462
|
+
name: 'vol',
|
|
463
|
+
type: 'Number'
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
GPS: {
|
|
468
|
+
commands: [],
|
|
469
|
+
type: 'GPS',
|
|
470
|
+
lazy: [],
|
|
471
|
+
active: [
|
|
472
|
+
{
|
|
473
|
+
name: 'explicit',
|
|
474
|
+
type: 'number',
|
|
475
|
+
entity_name: 'SO5',
|
|
476
|
+
object_id: 'x'
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: 'explicit',
|
|
480
|
+
type: 'number',
|
|
481
|
+
entity_name: 'SO6',
|
|
482
|
+
object_id: 'y'
|
|
483
|
+
}
|
|
484
|
+
],
|
|
485
|
+
explicitAttrs: true
|
|
486
|
+
},
|
|
487
|
+
GPS2: {
|
|
488
|
+
commands: [],
|
|
489
|
+
type: 'GPS',
|
|
490
|
+
lazy: [],
|
|
491
|
+
active: [
|
|
492
|
+
{
|
|
493
|
+
name: 'foo',
|
|
494
|
+
type: 'text',
|
|
495
|
+
object_id: 'f'
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: 'attr1',
|
|
499
|
+
type: 'number',
|
|
500
|
+
entity_name: 'SO5',
|
|
501
|
+
object_id: 'x'
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: 'attr2',
|
|
505
|
+
type: 'number',
|
|
506
|
+
entity_name: 'SO6',
|
|
507
|
+
object_id: 'y'
|
|
508
|
+
}
|
|
509
|
+
],
|
|
510
|
+
static: [
|
|
511
|
+
{
|
|
512
|
+
name: 'bar',
|
|
513
|
+
type: 'text',
|
|
514
|
+
value: 'b'
|
|
515
|
+
}
|
|
516
|
+
],
|
|
517
|
+
explicitAttrs: '[ "attr1", "attr2" ]'
|
|
296
518
|
}
|
|
297
519
|
},
|
|
298
520
|
service: 'smartgondor',
|
|
@@ -598,6 +820,135 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
598
820
|
});
|
|
599
821
|
});
|
|
600
822
|
|
|
823
|
+
describe('When an update comes for a multientity with same entity_id and different entity_type with different attrs', function () {
|
|
824
|
+
const values = [
|
|
825
|
+
{
|
|
826
|
+
name: 'v',
|
|
827
|
+
type: 'Number',
|
|
828
|
+
value: 0
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
name: 'v1',
|
|
832
|
+
type: 'Number',
|
|
833
|
+
value: 1
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
name: 'v2',
|
|
837
|
+
type: 'Number',
|
|
838
|
+
value: 2
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
name: 'v3',
|
|
842
|
+
type: 'Number',
|
|
843
|
+
value: 3
|
|
844
|
+
}
|
|
845
|
+
];
|
|
846
|
+
|
|
847
|
+
beforeEach(function () {
|
|
848
|
+
nock.cleanAll();
|
|
849
|
+
|
|
850
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
851
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
852
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
853
|
+
.post(
|
|
854
|
+
'/v2/op/update',
|
|
855
|
+
utils.readExampleFile(
|
|
856
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json'
|
|
857
|
+
)
|
|
858
|
+
)
|
|
859
|
+
.reply(204);
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
it('should send the update value to three entities with different attribute names and different object_id', function (done) {
|
|
863
|
+
iotAgentLib.update('sh1', 'SharedIds1', '', values, function (error) {
|
|
864
|
+
should.not.exist(error);
|
|
865
|
+
contextBrokerMock.done();
|
|
866
|
+
done();
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
describe('When an update comes for a multientity with same entity_id and different entity_type whit shared attrs', function () {
|
|
872
|
+
const values = [
|
|
873
|
+
{
|
|
874
|
+
name: 'v',
|
|
875
|
+
type: 'Number',
|
|
876
|
+
value: 0
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
name: 'v1',
|
|
880
|
+
type: 'Number',
|
|
881
|
+
value: 1
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
name: 'v2',
|
|
885
|
+
type: 'Number',
|
|
886
|
+
value: 2
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
name: 'v3',
|
|
890
|
+
type: 'Number',
|
|
891
|
+
value: 3
|
|
892
|
+
}
|
|
893
|
+
];
|
|
894
|
+
|
|
895
|
+
beforeEach(function () {
|
|
896
|
+
nock.cleanAll();
|
|
897
|
+
|
|
898
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
899
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
900
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
901
|
+
.post(
|
|
902
|
+
'/v2/op/update',
|
|
903
|
+
utils.readExampleFile(
|
|
904
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json'
|
|
905
|
+
)
|
|
906
|
+
)
|
|
907
|
+
.reply(204);
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
it('should send the update value to three entities with same attribute names', function (done) {
|
|
911
|
+
iotAgentLib.update('sh2', 'SharedIds2', '', values, function (error) {
|
|
912
|
+
should.not.exist(error);
|
|
913
|
+
contextBrokerMock.done();
|
|
914
|
+
done();
|
|
915
|
+
});
|
|
916
|
+
});
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
describe('When an update comes for a multientity with same entity_id and different entity_type whit shared attrs and shared object_id', function () {
|
|
920
|
+
const values = [
|
|
921
|
+
{
|
|
922
|
+
name: 'v',
|
|
923
|
+
type: 'Number',
|
|
924
|
+
value: 0
|
|
925
|
+
}
|
|
926
|
+
];
|
|
927
|
+
|
|
928
|
+
beforeEach(function () {
|
|
929
|
+
nock.cleanAll();
|
|
930
|
+
|
|
931
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
932
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
933
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
934
|
+
.post(
|
|
935
|
+
'/v2/op/update',
|
|
936
|
+
utils.readExampleFile(
|
|
937
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json'
|
|
938
|
+
)
|
|
939
|
+
)
|
|
940
|
+
.reply(204);
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
it('should send the update value to three entities with same attribute names', function (done) {
|
|
944
|
+
iotAgentLib.update('sh3', 'SharedIds3', '', values, function (error) {
|
|
945
|
+
should.not.exist(error);
|
|
946
|
+
contextBrokerMock.done();
|
|
947
|
+
done();
|
|
948
|
+
});
|
|
949
|
+
});
|
|
950
|
+
});
|
|
951
|
+
|
|
601
952
|
describe('When an update comes for a multientity defined with an expression (multi values / multiple entities / same attribute) - JEXL', function () {
|
|
602
953
|
const values = [
|
|
603
954
|
{
|
|
@@ -641,6 +992,97 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
641
992
|
});
|
|
642
993
|
});
|
|
643
994
|
|
|
995
|
+
describe('When an update comes for a multientity defined with an expression (multi values / multiple entities / same attribute) - JEXL with static', function () {
|
|
996
|
+
const values = [
|
|
997
|
+
{
|
|
998
|
+
name: 'v',
|
|
999
|
+
type: 'Number',
|
|
1000
|
+
value: 0
|
|
1001
|
+
}
|
|
1002
|
+
];
|
|
1003
|
+
|
|
1004
|
+
beforeEach(function () {
|
|
1005
|
+
nock.cleanAll();
|
|
1006
|
+
|
|
1007
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1008
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1009
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1010
|
+
.post(
|
|
1011
|
+
'/v2/op/update',
|
|
1012
|
+
utils.readExampleFile(
|
|
1013
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json'
|
|
1014
|
+
)
|
|
1015
|
+
)
|
|
1016
|
+
.reply(204);
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
it('should send the update value to the resulting value of the expression', function (done) {
|
|
1020
|
+
iotAgentLib.update('ws9', 'WeatherStation9Jexl', '', values, function (error) {
|
|
1021
|
+
should.not.exist(error);
|
|
1022
|
+
contextBrokerMock.done();
|
|
1023
|
+
done();
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
beforeEach(function () {
|
|
1029
|
+
nock.cleanAll();
|
|
1030
|
+
|
|
1031
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1032
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1033
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1034
|
+
.post(
|
|
1035
|
+
'/v2/op/update',
|
|
1036
|
+
utils.readExampleFile(
|
|
1037
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json'
|
|
1038
|
+
)
|
|
1039
|
+
)
|
|
1040
|
+
.reply(204);
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
describe('When an update comes for a multientity whith a wrong mapping)', function () {
|
|
1044
|
+
const values = [
|
|
1045
|
+
{
|
|
1046
|
+
name: 'v',
|
|
1047
|
+
type: 'Number',
|
|
1048
|
+
value: 0
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
name: 'v1',
|
|
1052
|
+
type: 'Number',
|
|
1053
|
+
value: 1
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
name: 'v2',
|
|
1057
|
+
type: 'Number',
|
|
1058
|
+
value: 2
|
|
1059
|
+
}
|
|
1060
|
+
];
|
|
1061
|
+
|
|
1062
|
+
beforeEach(function () {
|
|
1063
|
+
nock.cleanAll();
|
|
1064
|
+
|
|
1065
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1066
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1067
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1068
|
+
.post(
|
|
1069
|
+
'/v2/op/update',
|
|
1070
|
+
utils.readExampleFile(
|
|
1071
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json'
|
|
1072
|
+
)
|
|
1073
|
+
)
|
|
1074
|
+
.reply(204);
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
it('should send the update value to the resulting value of the expression overwriting wrong id and type mapped attributes', function (done) {
|
|
1078
|
+
iotAgentLib.update('ws11', 'WrongStation', '', values, function (error) {
|
|
1079
|
+
should.not.exist(error);
|
|
1080
|
+
contextBrokerMock.done();
|
|
1081
|
+
done();
|
|
1082
|
+
});
|
|
1083
|
+
});
|
|
1084
|
+
});
|
|
1085
|
+
|
|
644
1086
|
describe('When an update comes for a multientity measurement without type for one entity', function () {
|
|
645
1087
|
const values = [
|
|
646
1088
|
{
|
|
@@ -679,6 +1121,90 @@ describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
|
679
1121
|
});
|
|
680
1122
|
});
|
|
681
1123
|
|
|
1124
|
+
describe('When an update comes for a multientity measurement explicitAttrs for one entity', function () {
|
|
1125
|
+
const values = [
|
|
1126
|
+
{
|
|
1127
|
+
name: 'x',
|
|
1128
|
+
type: 'Number',
|
|
1129
|
+
value: 52
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
name: 'y',
|
|
1133
|
+
type: 'Number',
|
|
1134
|
+
value: 13
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
name: 'z',
|
|
1138
|
+
type: 'Number',
|
|
1139
|
+
value: 12
|
|
1140
|
+
}
|
|
1141
|
+
];
|
|
1142
|
+
|
|
1143
|
+
beforeEach(function () {
|
|
1144
|
+
nock.cleanAll();
|
|
1145
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1146
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1147
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1148
|
+
.post(
|
|
1149
|
+
'/v2/op/update',
|
|
1150
|
+
utils.readExampleFile(
|
|
1151
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json'
|
|
1152
|
+
)
|
|
1153
|
+
)
|
|
1154
|
+
.reply(204);
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
it('should remove hidden attrs from the value', function (done) {
|
|
1158
|
+
iotAgentLib.update('gps1', 'GPS', '', values, function (error) {
|
|
1159
|
+
should.not.exist(error);
|
|
1160
|
+
contextBrokerMock.done();
|
|
1161
|
+
done();
|
|
1162
|
+
});
|
|
1163
|
+
});
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
describe('When an update comes for a multientity measurement explicitAttrs as jexl for one entity', function () {
|
|
1167
|
+
const values = [
|
|
1168
|
+
{
|
|
1169
|
+
name: 'x',
|
|
1170
|
+
type: 'Number',
|
|
1171
|
+
value: 52
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
name: 'y',
|
|
1175
|
+
type: 'Number',
|
|
1176
|
+
value: 13
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
name: 'z',
|
|
1180
|
+
type: 'Number',
|
|
1181
|
+
value: 12
|
|
1182
|
+
}
|
|
1183
|
+
];
|
|
1184
|
+
|
|
1185
|
+
beforeEach(function () {
|
|
1186
|
+
nock.cleanAll();
|
|
1187
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1188
|
+
.matchHeader('fiware-service', 'smartgondor')
|
|
1189
|
+
.matchHeader('fiware-servicepath', 'gardens')
|
|
1190
|
+
.post(
|
|
1191
|
+
'/v2/op/update',
|
|
1192
|
+
utils.readExampleFile(
|
|
1193
|
+
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json'
|
|
1194
|
+
)
|
|
1195
|
+
)
|
|
1196
|
+
.reply(204);
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
it('should remove hidden attrs from the value', function (done) {
|
|
1200
|
+
iotAgentLib.update('gps1', 'GPS2', '', values, function (error) {
|
|
1201
|
+
should.not.exist(error);
|
|
1202
|
+
contextBrokerMock.done();
|
|
1203
|
+
done();
|
|
1204
|
+
});
|
|
1205
|
+
});
|
|
1206
|
+
});
|
|
1207
|
+
|
|
682
1208
|
describe(
|
|
683
1209
|
'When an update comes for a multientity measurement and there are attributes with' +
|
|
684
1210
|
' the same name but different alias and mapped to different CB entities',
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
/* eslint-disable no-unused-vars */
|
|
25
25
|
|
|
26
|
-
const iotAgentLib = require('
|
|
27
|
-
const utils = require('
|
|
26
|
+
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
27
|
+
const utils = require('../../../tools/utils');
|
|
28
|
+
const request = utils.request;
|
|
28
29
|
const should = require('should');
|
|
29
30
|
const logger = require('logops');
|
|
30
31
|
const nock = require('nock');
|
|
@@ -32,7 +33,8 @@ let contextBrokerMock;
|
|
|
32
33
|
const iotAgentConfig = {
|
|
33
34
|
contextBroker: {
|
|
34
35
|
host: '192.168.1.1',
|
|
35
|
-
port: '1026'
|
|
36
|
+
port: '1026',
|
|
37
|
+
nsgiVersion: 'v2'
|
|
36
38
|
},
|
|
37
39
|
server: {
|
|
38
40
|
port: 4041
|
|
@@ -117,7 +119,7 @@ const iotAgentConfig = {
|
|
|
117
119
|
deviceRegistrationDuration: 'P1M'
|
|
118
120
|
};
|
|
119
121
|
|
|
120
|
-
describe('Data Mapping Plugins: translation', function () {
|
|
122
|
+
describe('NGSI-v2 - Data Mapping Plugins: translation', function () {
|
|
121
123
|
beforeEach(function (done) {
|
|
122
124
|
logger.setLevel('FATAL');
|
|
123
125
|
|
|
@@ -139,11 +141,11 @@ describe('Data Mapping Plugins: translation', function () {
|
|
|
139
141
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
140
142
|
.matchHeader('fiware-service', 'smartgondor')
|
|
141
143
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
142
|
-
.
|
|
143
|
-
'/
|
|
144
|
-
utils.readExampleFile('./test/unit/examples/contextRequests/updateContextMiddleware1.json')
|
|
144
|
+
.patch(
|
|
145
|
+
'/v2/entities/light1/attrs?type=Light',
|
|
146
|
+
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware1.json')
|
|
145
147
|
)
|
|
146
|
-
.reply(
|
|
148
|
+
.reply(204);
|
|
147
149
|
});
|
|
148
150
|
|
|
149
151
|
it('should execute the translation middlewares', function (done) {
|
|
@@ -163,7 +165,7 @@ describe('Data Mapping Plugins: translation', function () {
|
|
|
163
165
|
let executed = false;
|
|
164
166
|
|
|
165
167
|
function testMiddleware(entity, typeInformation, callback) {
|
|
166
|
-
entity.
|
|
168
|
+
entity.dimming.value = entity.dimming.value + '%';
|
|
167
169
|
executed = true;
|
|
168
170
|
callback(null, entity, typeInformation);
|
|
169
171
|
}
|
|
@@ -192,7 +194,7 @@ describe('Data Mapping Plugins: translation', function () {
|
|
|
192
194
|
];
|
|
193
195
|
|
|
194
196
|
function testMiddleware(entity, typeInformation, callback) {
|
|
195
|
-
entity.
|
|
197
|
+
entity.dimming.value = entity.dimming.value + '%';
|
|
196
198
|
callback(null, entity, typeInformation);
|
|
197
199
|
}
|
|
198
200
|
|
|
@@ -215,19 +217,19 @@ describe('Data Mapping Plugins: translation', function () {
|
|
|
215
217
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
216
218
|
.matchHeader('fiware-service', 'smartgondor')
|
|
217
219
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
218
|
-
.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
.get('/v2/entities/light1/attrs?attrs=state,dimming&type=Light')
|
|
221
|
+
|
|
222
|
+
.reply(
|
|
223
|
+
200,
|
|
224
|
+
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware2.json')
|
|
225
|
+
);
|
|
223
226
|
});
|
|
224
227
|
|
|
225
228
|
it('should call the middleware', function (done) {
|
|
226
229
|
let called = false;
|
|
227
230
|
|
|
228
231
|
function testMiddleware(entity, typeInformation, callback) {
|
|
229
|
-
entity.
|
|
230
|
-
entity.contextResponses[0].contextElement.attributes[1].value + '%';
|
|
232
|
+
entity.dimming.value = entity.dimming.value + '%';
|
|
231
233
|
|
|
232
234
|
called = true;
|
|
233
235
|
|
|
@@ -244,9 +246,7 @@ describe('Data Mapping Plugins: translation', function () {
|
|
|
244
246
|
});
|
|
245
247
|
it('should call the middleware', function (done) {
|
|
246
248
|
function testMiddleware(entity, typeInformation, callback) {
|
|
247
|
-
entity.
|
|
248
|
-
entity.contextResponses[0].contextElement.attributes[1].value + '%';
|
|
249
|
-
|
|
249
|
+
entity.dimming.value = entity.dimming.value + '%';
|
|
250
250
|
callback(null, entity, typeInformation);
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -254,7 +254,7 @@ describe('Data Mapping Plugins: translation', function () {
|
|
|
254
254
|
|
|
255
255
|
iotAgentLib.query('light1', 'Light', '', attributes, function (error, result) {
|
|
256
256
|
should.not.exist(error);
|
|
257
|
-
result.
|
|
257
|
+
result.dimming.value.should.equal('23%');
|
|
258
258
|
done();
|
|
259
259
|
});
|
|
260
260
|
});
|