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.
Files changed (448) hide show
  1. package/.github/workflows/ci.yml +17 -1
  2. package/.readthedocs.yml +7 -0
  3. package/CHANGES_NEXT_RELEASE +0 -1
  4. package/README.md +1 -0
  5. package/doc/Contribution.md +60 -1
  6. package/doc/advanced-topics.md +136 -14
  7. package/doc/api.md +38 -22
  8. package/doc/apiary/iotagent.apib +1 -3
  9. package/doc/architecture.md +2 -2
  10. package/doc/config-basic-example.js +0 -1
  11. package/doc/deprecated.md +2 -2
  12. package/doc/development.md +13 -6
  13. package/doc/expressionLanguage.md +519 -277
  14. package/doc/getting-started.md +0 -1
  15. package/doc/howto.md +13 -17
  16. package/doc/installationguide.md +67 -69
  17. package/doc/usermanual.md +48 -16
  18. package/docker/Mosquitto/Dockerfile +4 -9
  19. package/docker/Mosquitto/README.md +2 -0
  20. package/docker/Mosquitto/startMosquitto.sh +18 -1
  21. package/lib/command/commandLine.js +1 -1
  22. package/lib/commonConfig.js +5 -14
  23. package/lib/errors.js +0 -16
  24. package/lib/fiware-iotagent-lib.js +5 -0
  25. package/lib/jexlTranformsMap.js +71 -0
  26. package/lib/model/Command.js +1 -1
  27. package/lib/model/Device.js +5 -2
  28. package/lib/model/Group.js +20 -2
  29. package/lib/model/dbConn.js +7 -1
  30. package/lib/plugins/attributeAlias.js +6 -13
  31. package/lib/plugins/bidirectionalData.js +2 -27
  32. package/lib/plugins/expressionParser.js +41 -17
  33. package/lib/plugins/expressionPlugin.js +21 -27
  34. package/lib/plugins/jexlParser.js +71 -67
  35. package/lib/plugins/multiEntity.js +68 -147
  36. package/lib/plugins/pluginUtils.js +12 -48
  37. package/lib/plugins/timestampProcessPlugin.js +1 -46
  38. package/lib/request-shim.js +111 -0
  39. package/lib/services/common/domain.js +2 -2
  40. package/lib/services/common/genericMiddleware.js +6 -2
  41. package/lib/services/common/iotManagerService.js +1 -1
  42. package/lib/services/common/securityServiceKeystone.js +1 -1
  43. package/lib/services/common/securityServiceOAuth2.js +3 -2
  44. package/lib/services/devices/deviceRegistryMongoDB.js +29 -22
  45. package/lib/services/devices/deviceService.js +56 -33
  46. package/lib/services/devices/devices-NGSI-LD.js +42 -14
  47. package/lib/services/devices/devices-NGSI-mixed.js +3 -3
  48. package/lib/services/devices/devices-NGSI-v2.js +48 -24
  49. package/lib/services/devices/registrationUtils.js +1 -134
  50. package/lib/services/groups/groupRegistryMemory.js +2 -0
  51. package/lib/services/groups/groupRegistryMongoDB.js +58 -76
  52. package/lib/services/groups/groupService.js +1 -1
  53. package/lib/services/ngsi/entities-NGSI-LD.js +205 -124
  54. package/lib/services/ngsi/entities-NGSI-v2.js +142 -32
  55. package/lib/services/ngsi/ngsiService.js +4 -6
  56. package/lib/services/ngsi/ngsiUtils.js +0 -21
  57. package/lib/services/ngsi/subscription-NGSI-LD.js +14 -5
  58. package/lib/services/ngsi/subscriptionService.js +1 -4
  59. package/lib/services/northBound/contextServer-NGSI-LD.js +7 -2
  60. package/lib/services/northBound/contextServer-NGSI-v2.js +25 -13
  61. package/lib/services/northBound/contextServer.js +1 -4
  62. package/lib/services/northBound/contextServerUtils.js +0 -81
  63. package/lib/services/northBound/deviceProvisioningServer.js +36 -9
  64. package/lib/services/northBound/northboundServer.js +2 -0
  65. package/lib/services/northBound/restUtils.js +2 -39
  66. package/lib/templates/updateDevice.json +4 -0
  67. package/lib/templates/updateDeviceLax.json +4 -0
  68. package/package.json +13 -13
  69. package/test/tools/utils.js +2 -0
  70. package/test/unit/examples/deviceProvisioningRequests/provisionAnotherDevice.json +1 -1
  71. package/test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json +1 -1
  72. package/test/unit/examples/deviceProvisioningRequests/provisionDuplicatedDev.json +1 -1
  73. package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -1
  74. package/test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json +1 -1
  75. package/test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json +1 -1
  76. package/test/unit/examples/iotamRequests/registrationEmpty.json +1 -1
  77. package/test/unit/examples/iotamRequests/registrationWithGroups.json +2 -2
  78. package/test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json +2 -2
  79. package/test/unit/examples/iotamRequests/registrationWithStaticGroups.json +2 -2
  80. package/test/unit/expressions/jexlExpression-test.js +119 -0
  81. package/test/unit/general/config-multi-core-test.js +1 -1
  82. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +30 -77
  83. package/test/unit/general/deviceService-test.js +19 -35
  84. package/test/unit/general/loglevel-api_test.js +8 -13
  85. package/test/unit/general/migration-test.js +1 -0
  86. package/test/unit/general/startup-test.js +3 -2
  87. package/test/unit/general/statistics-persistence_test.js +2 -2
  88. package/test/unit/general/statistics-service_test.js +2 -2
  89. package/test/unit/lazyAndCommands/commandRegistry_test.js +18 -18
  90. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +16 -24
  91. package/test/unit/mongodb/mongodb-connectionoptions-test.js +2 -2
  92. package/test/unit/mongodb/mongodb-group-registry-test.js +11 -11
  93. package/test/unit/mongodb/mongodb-registry-test.js +55 -131
  94. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
  95. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
  96. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
  97. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
  98. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
  99. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
  100. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
  101. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
  102. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
  103. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateCommands1.json +1 -1
  104. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent1.json +1 -1
  105. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
  106. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
  107. package/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json +0 -7
  108. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json +0 -7
  109. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -7
  110. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -14
  111. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -14
  112. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json +1 -15
  113. package/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json +0 -7
  114. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +0 -7
  115. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast5.json +0 -7
  116. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin12a.json +7 -0
  117. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin13.json +13 -13
  118. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin16.json +0 -7
  119. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin17.json +0 -7
  120. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +18 -0
  121. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +18 -0
  122. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin31.json +15 -0
  123. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +17 -0
  124. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin33.json +18 -0
  125. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin34.json +17 -0
  126. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +36 -0
  127. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin5.json +0 -7
  128. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +16 -16
  129. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +18 -0
  130. package/test/unit/ngsi-ld/examples/contextRequests/updateContextGeoproperties3.json +0 -7
  131. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
  132. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +6 -6
  133. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +3 -3
  134. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -7
  135. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json +0 -7
  136. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionDeviceStatic.json +0 -7
  137. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionMinimumDevice.json +0 -7
  138. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +20 -17
  139. package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest.json +18 -15
  140. package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest2.json +18 -15
  141. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +21 -21
  142. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1018 -0
  143. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -2
  144. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +24 -24
  145. package/test/unit/ngsi-ld/general/deviceService-test.js +7 -7
  146. package/test/unit/ngsi-ld/general/https-support-test.js +14 -13
  147. package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +8 -7
  148. package/test/unit/ngsi-ld/general/startup-test.js +2 -1
  149. package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +10 -8
  150. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +11 -12
  151. package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +25 -29
  152. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +16 -15
  153. package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +18 -17
  154. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +13 -12
  155. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +10 -9
  156. package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +3 -3
  157. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +25 -24
  158. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +13 -12
  159. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +27 -26
  160. package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +5 -5
  161. package/test/unit/ngsi-ld/plugins/event-plugin_test.js +3 -3
  162. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +75 -14
  163. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +3 -3
  164. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +54 -53
  165. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +20 -19
  166. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +23 -22
  167. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +58 -70
  168. package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +8 -7
  169. package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +19 -19
  170. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +18 -20
  171. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +43 -49
  172. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +16 -14
  173. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
  174. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
  175. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent3.json +19 -0
  176. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
  177. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent5.json +19 -0
  178. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
  179. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
  180. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
  181. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
  182. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
  183. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
  184. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateCommands1.json +3 -3
  185. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent1.json +3 -3
  186. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
  187. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
  188. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +17 -1
  189. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +5 -1
  190. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -2
  191. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json +6 -0
  192. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin16.json +14 -0
  193. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +14 -0
  194. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin18.json +6 -0
  195. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin19.json +6 -0
  196. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +13 -1
  197. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin20.json +6 -0
  198. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin21.json +6 -0
  199. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin22.json +6 -0
  200. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin23.json +6 -0
  201. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin24.json +6 -0
  202. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin25.json +6 -0
  203. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin26.json +6 -0
  204. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin27.json +6 -0
  205. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin28.json +6 -0
  206. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +22 -0
  207. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +5 -1
  208. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +6 -0
  209. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +18 -0
  210. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +16 -0
  211. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +22 -0
  212. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +12 -0
  213. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +12 -0
  214. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +5 -1
  215. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +5 -1
  216. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +5 -1
  217. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +17 -1
  218. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +5 -1
  219. package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware1.json +10 -0
  220. package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware2.json +10 -0
  221. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +2 -2
  222. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
  223. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +13 -0
  224. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +33 -0
  225. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +33 -0
  226. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +33 -0
  227. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
  228. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +25 -0
  229. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +2 -2
  230. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
  231. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
  232. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
  233. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
  234. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
  235. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +2 -2
  236. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
  237. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -8
  238. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +4 -4
  239. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
  240. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -2
  241. package/test/unit/ngsiv2/examples/contextRequests/updateProvisionDevice.json +20 -0
  242. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +1 -1
  243. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest.json +1 -1
  244. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest2.json +1 -1
  245. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +93 -60
  246. package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +16 -16
  247. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +548 -164
  248. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +34 -33
  249. package/test/unit/ngsiv2/general/deviceService-test.js +15 -14
  250. package/test/unit/ngsiv2/general/https-support-test.js +14 -13
  251. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +8 -7
  252. package/test/unit/ngsiv2/general/startup-test.js +2 -1
  253. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +9 -7
  254. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +13 -12
  255. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +323 -51
  256. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +22 -20
  257. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +114 -26
  258. package/test/unit/ngsiv2/ngsiService/autocast-test.js +16 -16
  259. package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +39 -38
  260. package/test/unit/{ngsiService → ngsiv2/ngsiService}/queryDeviceInformationInCb-test.js +25 -54
  261. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +5 -5
  262. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +25 -24
  263. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +22 -22
  264. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +27 -26
  265. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +7 -7
  266. package/test/unit/ngsiv2/plugins/event-plugin_test.js +4 -4
  267. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +549 -24
  268. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +4 -4
  269. package/test/unit/{plugins → ngsiv2/plugins}/translation-inPlugins_test.js +25 -25
  270. package/test/unit/{provisioning → ngsiv2/provisioning}/device-group-api-test.js +44 -75
  271. package/test/unit/{provisioning/device-group-utils_test.js → ngsiv2/provisioning/device-group-utils-test.js} +15 -14
  272. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +74 -73
  273. package/test/unit/ngsiv2/provisioning/device-registration_test.js +20 -19
  274. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +30 -29
  275. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +58 -69
  276. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +8 -7
  277. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +19 -19
  278. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +18 -19
  279. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +49 -52
  280. package/test/unit/plugins/capture-configuration-inPlugins_test.js +6 -4
  281. package/test/unit/plugins/capture-provision-inPlugins_test.js +13 -23
  282. package/.nyc_output/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
  283. package/.nyc_output/processinfo/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
  284. package/.nyc_output/processinfo/index.json +0 -1
  285. package/lib/services/devices/devices-NGSI-v1.js +0 -293
  286. package/lib/services/devices/registrationUtils.js_avega +0 -589
  287. package/lib/services/ngsi/entities-NGSI-v1.js +0 -300
  288. package/lib/services/ngsi/subscription-NGSI-v1.js +0 -234
  289. package/lib/services/northBound/contextServer-NGSI-v1.js +0 -526
  290. package/lib/templates/notificationTemplateNgsi1.json +0 -75
  291. package/lib/templates/updateContextNgsi1.json +0 -50
  292. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json +0 -21
  293. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent2.json +0 -21
  294. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json +0 -25
  295. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent4.json +0 -22
  296. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentAttributeUpdates.json +0 -16
  297. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +0 -21
  298. package/test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json +0 -21
  299. package/test/unit/examples/contextAvailabilityRequests/registerNewDevice2.json +0 -21
  300. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json +0 -25
  301. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +0 -21
  302. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +0 -33
  303. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +0 -33
  304. package/test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json +0 -22
  305. package/test/unit/examples/contextAvailabilityRequests/unregisterDevice3.json +0 -26
  306. package/test/unit/examples/contextAvailabilityRequests/unregisterProvisionedDevice.json +0 -26
  307. package/test/unit/examples/contextAvailabilityRequests/updateCommands1.json +0 -22
  308. package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json +0 -22
  309. package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent2.json +0 -26
  310. package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent3.json +0 -22
  311. package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json +0 -8
  312. package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json +0 -4
  313. package/test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json +0 -4
  314. package/test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json +0 -4
  315. package/test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json +0 -4
  316. package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Failed.json +0 -8
  317. package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json +0 -4
  318. package/test/unit/examples/contextAvailabilityResponses/updateCommands1Success.json +0 -4
  319. package/test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json +0 -6
  320. package/test/unit/examples/contextProviderResponses/queryInformationResponse.json +0 -22
  321. package/test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json +0 -22
  322. package/test/unit/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json +0 -27
  323. package/test/unit/examples/contextProviderResponses/updateInformationResponse.json +0 -22
  324. package/test/unit/examples/contextProviderResponses/updateInformationResponse2.json +0 -22
  325. package/test/unit/examples/contextRequests/contextSubscriptionRequest.json +0 -20
  326. package/test/unit/examples/contextRequests/contextSubscriptionRequest2.json +0 -20
  327. package/test/unit/examples/contextRequests/createBidirectionalDevice.json +0 -17
  328. package/test/unit/examples/contextRequests/createDatetimeProvisionedDevice.json +0 -17
  329. package/test/unit/examples/contextRequests/createGeopointProvisionedDevice.json +0 -17
  330. package/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json +0 -17
  331. package/test/unit/examples/contextRequests/createProvisionedDevice.json +0 -32
  332. package/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -32
  333. package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json +0 -47
  334. package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -52
  335. package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -52
  336. package/test/unit/examples/contextRequests/createTimeinstantDevice.json +0 -17
  337. package/test/unit/examples/contextRequests/queryContext1.json +0 -13
  338. package/test/unit/examples/contextRequests/queryContext2.json +0 -13
  339. package/test/unit/examples/contextRequests/queryContextAliasPlugin1.json +0 -10
  340. package/test/unit/examples/contextRequests/queryContextCompressTimestamp1.json +0 -13
  341. package/test/unit/examples/contextRequests/updateActiveAttributes.json +0 -11
  342. package/test/unit/examples/contextRequests/updateContext1.json +0 -22
  343. package/test/unit/examples/contextRequests/updateContext2.json +0 -22
  344. package/test/unit/examples/contextRequests/updateContext3.json +0 -17
  345. package/test/unit/examples/contextRequests/updateContext3WithStatic.json +0 -22
  346. package/test/unit/examples/contextRequests/updateContext4.json +0 -22
  347. package/test/unit/examples/contextRequests/updateContext5.json +0 -19
  348. package/test/unit/examples/contextRequests/updateContextAliasPlugin.json +0 -22
  349. package/test/unit/examples/contextRequests/updateContextAliasPlugin2.json +0 -17
  350. package/test/unit/examples/contextRequests/updateContextAppendMode.json +0 -22
  351. package/test/unit/examples/contextRequests/updateContextCommandError.json +0 -22
  352. package/test/unit/examples/contextRequests/updateContextCommandExpired.json +0 -22
  353. package/test/unit/examples/contextRequests/updateContextCommandFinish.json +0 -22
  354. package/test/unit/examples/contextRequests/updateContextCommandStatus.json +0 -17
  355. package/test/unit/examples/contextRequests/updateContextCompressTimestamp1.json +0 -22
  356. package/test/unit/examples/contextRequests/updateContextCompressTimestamp2.json +0 -29
  357. package/test/unit/examples/contextRequests/updateContextExpressionPlugin1.json +0 -17
  358. package/test/unit/examples/contextRequests/updateContextExpressionPlugin2.json +0 -27
  359. package/test/unit/examples/contextRequests/updateContextExpressionPlugin3.json +0 -17
  360. package/test/unit/examples/contextRequests/updateContextExpressionPlugin4.json +0 -17
  361. package/test/unit/examples/contextRequests/updateContextExpressionPlugin5.json +0 -27
  362. package/test/unit/examples/contextRequests/updateContextMiddleware1.json +0 -22
  363. package/test/unit/examples/contextRequests/updateContextMultiEntityPlugin3.json +0 -35
  364. package/test/unit/examples/contextRequests/updateContextMultientityPlugin1.json +0 -30
  365. package/test/unit/examples/contextRequests/updateContextMultientityPlugin2.json +0 -30
  366. package/test/unit/examples/contextRequests/updateContextProcessTimestamp1.json +0 -29
  367. package/test/unit/examples/contextRequests/updateContextStaticAttributes.json +0 -22
  368. package/test/unit/examples/contextRequests/updateContextTimestamp.json +0 -41
  369. package/test/unit/examples/contextRequests/updateContextTimestampOverride.json +0 -22
  370. package/test/unit/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +0 -22
  371. package/test/unit/examples/contextRequests/updateContextTimestampTimezone.json +0 -41
  372. package/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -17
  373. package/test/unit/examples/contextRequests/updateProvisionCommands1.json +0 -27
  374. package/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json +0 -38
  375. package/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json +0 -17
  376. package/test/unit/examples/contextResponses/contextSubscriptionRequest2Success.json +0 -7
  377. package/test/unit/examples/contextResponses/contextSubscriptionRequestSuccess.json +0 -7
  378. package/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json +0 -22
  379. package/test/unit/examples/contextResponses/createDatetimeProvisionedDeviceSuccess.json +0 -22
  380. package/test/unit/examples/contextResponses/createGeopointProvisionedDeviceSuccess.json +0 -22
  381. package/test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json +0 -22
  382. package/test/unit/examples/contextResponses/createTimeinstantSuccess.json +0 -22
  383. package/test/unit/examples/contextResponses/queryContext1Success.json +0 -27
  384. package/test/unit/examples/contextResponses/queryContext2Error.json +0 -7
  385. package/test/unit/examples/contextResponses/queryContext2UnknownError.json +0 -6
  386. package/test/unit/examples/contextResponses/queryContext3Error.json +0 -34
  387. package/test/unit/examples/contextResponses/queryContextAliasPlugin1Success.json +0 -27
  388. package/test/unit/examples/contextResponses/queryContextCompressTimestamp1Success.json +0 -27
  389. package/test/unit/examples/contextResponses/updateActiveAttributesSuccess.json +0 -16
  390. package/test/unit/examples/contextResponses/updateContext1Failed.json +0 -7
  391. package/test/unit/examples/contextResponses/updateContext1Success.json +0 -27
  392. package/test/unit/examples/contextResponses/updateContext2Failed.json +0 -35
  393. package/test/unit/examples/contextResponses/updateContextAliasPlugin2Success.json +0 -27
  394. package/test/unit/examples/contextResponses/updateContextAliasPluginSuccess.json +0 -27
  395. package/test/unit/examples/contextResponses/updateContextCommandFinishSuccess.json +0 -27
  396. package/test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json +0 -22
  397. package/test/unit/examples/contextResponses/updateContextCompressTimestamp1Success.json +0 -27
  398. package/test/unit/examples/contextResponses/updateContextCompressTimestamp2Success.json +0 -34
  399. package/test/unit/examples/contextResponses/updateContextEvents1Success.json +0 -27
  400. package/test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json +0 -22
  401. package/test/unit/examples/contextResponses/updateContextExpressionPlugin2Success.json +0 -22
  402. package/test/unit/examples/contextResponses/updateContextExpressionPlugin3Success.json +0 -22
  403. package/test/unit/examples/contextResponses/updateContextExpressionPlugin5Success.json +0 -32
  404. package/test/unit/examples/contextResponses/updateContextMultientityPlugin1Success.json +0 -40
  405. package/test/unit/examples/contextResponses/updateContextMultientityPlugin2Success.json +0 -40
  406. package/test/unit/examples/contextResponses/updateContextMultientityPlugin3Success.json +0 -40
  407. package/test/unit/examples/contextResponses/updateContextProcessTimestamp1Success.json +0 -27
  408. package/test/unit/examples/contextResponses/updateProvisionActiveAttributes1Success.json +0 -22
  409. package/test/unit/examples/contextResponses/updateProvisionCommands1Success.json +0 -32
  410. package/test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json +0 -22
  411. package/test/unit/examples/subscriptionRequests/bidirectionalNotification.json +0 -24
  412. package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRemove.json +0 -3
  413. package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -22
  414. package/test/unit/examples/subscriptionRequests/errorNotification.json +0 -24
  415. package/test/unit/examples/subscriptionRequests/simpleNotification.json +0 -24
  416. package/test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json +0 -3
  417. package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json +0 -19
  418. package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json +0 -19
  419. package/test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json +0 -6
  420. package/test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json +0 -6
  421. package/test/unit/expressions/expressionBasedTransformations-test.js +0 -328
  422. package/test/unit/expressions/expressionCombinedTransformations-test.js +0 -306
  423. package/test/unit/expressions/jexlBasedTransformations-test.js +0 -334
  424. package/test/unit/general/contextBrokerOAuthSecurityAccess-test.js +0 -902
  425. package/test/unit/general/https-support-test.js +0 -286
  426. package/test/unit/general/iotam-autoregistration-test.js +0 -368
  427. package/test/unit/lazyAndCommands/active-devices-attribute-update-test.js +0 -168
  428. package/test/unit/lazyAndCommands/command-test.js +0 -341
  429. package/test/unit/lazyAndCommands/lazy-devices-test.js +0 -878
  430. package/test/unit/lazyAndCommands/polling-commands-test.js +0 -421
  431. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin20.json +0 -25
  432. package/test/unit/ngsiService/active-devices-test.js +0 -692
  433. package/test/unit/ngsiService/staticAttributes-test.js +0 -148
  434. package/test/unit/ngsiService/subscriptions-test.js +0 -345
  435. package/test/unit/plugins/alias-plugin_test.js +0 -158
  436. package/test/unit/plugins/bidirectional-plugin_test.js +0 -564
  437. package/test/unit/plugins/compress-timestamp-plugin_test.js +0 -257
  438. package/test/unit/plugins/event-plugin_test.js +0 -119
  439. package/test/unit/plugins/multientity-plugin_test.js +0 -248
  440. package/test/unit/plugins/timestamp-processing-plugin_test.js +0 -119
  441. package/test/unit/provisioning/device-provisioning-api_test.js +0 -748
  442. package/test/unit/provisioning/device-registration_test.js +0 -432
  443. package/test/unit/provisioning/device-update-registration_test.js +0 -326
  444. package/test/unit/provisioning/listProvisionedDevices-test.js +0 -488
  445. package/test/unit/provisioning/provisionDeviceMultientity-test.js +0 -123
  446. package/test/unit/provisioning/removeProvisionedDevice-test.js +0 -244
  447. package/test/unit/provisioning/singleConfigurationMode-test.js +0 -346
  448. 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: 'smartGondor',
350
+ service: 'smartgondor',
191
351
  subservice: 'gardens',
192
- providerUrl: 'http://smartGondor.com',
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', 'smartGondor')
448
+ .matchHeader('fiware-service', 'smartgondor')
257
449
  .matchHeader('fiware-servicepath', 'gardens')
258
- .post(
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', 'smartGondor')
489
+ .matchHeader('fiware-service', 'smartgondor')
298
490
  .matchHeader('fiware-servicepath', 'gardens')
299
- .post(
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', 'smartGondor')
524
+ .matchHeader('fiware-service', 'smartgondor')
333
525
  .matchHeader('fiware-servicepath', 'gardens')
334
- .post(
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', 'smartGondor')
559
+ .matchHeader('fiware-service', 'smartgondor')
368
560
  .matchHeader('fiware-servicepath', 'gardens')
369
- .post(
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 with string expression and type integer', function () {
389
- // Case: Update for an integer attribute with string expression
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: 52
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', 'smartGondor')
595
+ .matchHeader('fiware-service', 'smartgondor')
403
596
  .matchHeader('fiware-servicepath', 'gardens')
404
- .post(
405
- '/v2/entities/ws1/attrs',
597
+ .patch(
598
+ '/v2/entities/light1/attrs',
406
599
  utils.readExampleFile(
407
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json'
600
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json'
408
601
  )
409
602
  )
410
- .query({ type: 'WeatherStation' })
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('ws1', 'WeatherStationMultiple', '', values, function (error) {
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 without expressions and type float', function () {
424
- // Case: Update for a Float attribute without expressions
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', 'smartGondor')
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
- .post(
669
+ .patch(
441
670
  '/v2/entities/light1/attrs',
442
671
  utils.readExampleFile(
443
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json'
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 with numeric expressions and type float', function () {
460
- // Case: Update for a Float attribute with arithmetic expression
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: 'e',
465
- type: 'Number',
466
- value: 0.44
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', 'smartGondor')
703
+ .matchHeader('fiware-service', 'smartgondor')
475
704
  .matchHeader('fiware-servicepath', 'gardens')
476
- .post(
477
- '/v2/entities/ws1/attrs',
705
+ .patch(
706
+ '/v2/entities/light1/attrs',
478
707
  utils.readExampleFile(
479
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json'
708
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json'
480
709
  )
481
710
  )
482
- .query({ type: 'WeatherStation' })
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('ws1', 'WeatherStation', '', values, function (error) {
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 with string expressions and type float', function () {
496
- // Case: Update for a Float attribute with string expression
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: 'e',
501
- type: 'Number',
502
- value: 0.44
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', 'smartGondor')
738
+ .matchHeader('fiware-service', 'smartgondor')
511
739
  .matchHeader('fiware-servicepath', 'gardens')
512
- .post(
513
- '/v2/entities/ws1/attrs',
740
+ .patch(
741
+ '/v2/entities/light1/attrs',
514
742
  utils.readExampleFile(
515
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json'
743
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json'
516
744
  )
517
745
  )
518
- .query({ type: 'WeatherStation' })
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('ws1', 'WeatherStationMultiple', '', values, function (error) {
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 NULL type', function () {
532
- // Case: Update for a Null attribute without expression
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: 'a',
537
- type: 'None',
538
- value: null
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', 'smartGondor')
774
+ .matchHeader('fiware-service', 'smartgondor')
547
775
  .matchHeader('fiware-servicepath', 'gardens')
548
- .post(
776
+ .patch(
549
777
  '/v2/entities/light1/attrs',
550
778
  utils.readExampleFile(
551
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json'
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 an update comes for attributes with numeric expressions and NULL type', function () {
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: 'a',
573
- type: 'None',
574
- value: null
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', 'smartGondor')
808
+ .matchHeader('fiware-service', 'smartgondor')
583
809
  .matchHeader('fiware-servicepath', 'gardens')
584
- .post(
585
- '/v2/entities/ws1/attrs',
810
+ .patch(
811
+ '/v2/entities/light1/attrs',
586
812
  utils.readExampleFile(
587
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json'
813
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json'
588
814
  )
589
815
  )
590
- .query({ type: 'WeatherStation' })
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('ws1', 'WeatherStation', '', values, function (error) {
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 an update comes for attributes with string expressions and NULL type', function () {
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: 'a',
609
- type: 'None',
610
- value: null
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', 'smartGondor')
842
+ .matchHeader('fiware-service', 'smartgondor')
619
843
  .matchHeader('fiware-servicepath', 'gardens')
620
- .post(
621
- '/v2/entities/ws1/attrs',
844
+ .patch(
845
+ '/v2/entities/light1/attrs',
622
846
  utils.readExampleFile(
623
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json'
847
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
624
848
  )
625
849
  )
626
- .query({ type: 'WeatherStation' })
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('ws1', 'WeatherStationMultiple', '', values, function (error) {
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 an update comes for attributes without expressions and Boolean type', function () {
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: 'u',
645
- type: 'Boolean',
646
- value: true
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', 'smartGondor')
881
+ .matchHeader('fiware-service', 'smartgondor')
655
882
  .matchHeader('fiware-servicepath', 'gardens')
656
- .post(
883
+ .patch(
657
884
  '/v2/entities/light1/attrs',
658
885
  utils.readExampleFile(
659
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json'
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 an update comes for attributes with numeric expressions and Boolean type', function () {
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: 'u',
681
- type: 'Boolean',
682
- value: true
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', 'smartGondor')
915
+ .matchHeader('fiware-service', 'smartgondor')
691
916
  .matchHeader('fiware-servicepath', 'gardens')
692
- .post(
917
+ .patch(
693
918
  '/v2/entities/ws1/attrs',
694
919
  utils.readExampleFile(
695
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin10.json'
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 apply the expression before sending the values', function (done) {
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: 'Boolean',
717
- value: true
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', 'smartGondor')
948
+ .matchHeader('fiware-service', 'smartgondor')
726
949
  .matchHeader('fiware-servicepath', 'gardens')
727
- .post(
950
+ .patch(
728
951
  '/v2/entities/ws1/attrs',
729
952
  utils.readExampleFile(
730
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json'
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 apply the expression before sending the values', function (done) {
738
- iotAgentLib.update('ws1', 'WeatherStationMultiple', '', values, function (error) {
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 an update comes for attributes without expressions and Object type', function () {
747
- // Case: Update for a JSON document attribute without expression
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: 'm',
751
- type: 'Object',
752
- value: { name: 'Manufacturer1', VAT: 'U12345678' }
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', 'smartGondor')
993
+ .matchHeader('fiware-service', 'smartgondor')
761
994
  .matchHeader('fiware-servicepath', 'gardens')
762
- .post(
763
- '/v2/entities/light1/attrs',
995
+ .patch(
996
+ '/v2/entities/gps1/attrs',
764
997
  utils.readExampleFile(
765
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json'
998
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json'
766
999
  )
767
1000
  )
768
- .query({ type: 'Light' })
1001
+ .query({ type: 'GPS' })
769
1002
  .reply(204);
770
1003
  });
771
1004
 
772
- it('should apply the expression before sending the values', function (done) {
773
- iotAgentLib.update('light1', 'Light', '', values, function (error) {
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 update comes for attributes without expressions and Object type', function () {
782
- // Case: Update for a JSON array attribute without expression
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: 'r',
787
- type: 'Object',
788
- value: ['v0.1', 'v0.2', 'v0.3']
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', 'smartGondor')
1083
+ .matchHeader('fiware-service', 'smartgondor')
797
1084
  .matchHeader('fiware-servicepath', 'gardens')
798
- .post(
799
- '/v2/entities/light1/attrs',
1085
+ .patch(
1086
+ '/v2/entities/gps1/attrs',
800
1087
  utils.readExampleFile(
801
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json'
1088
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
802
1089
  )
803
1090
  )
804
- .query({ type: 'Light' })
1091
+ .query({ type: 'GPS' })
805
1092
  .reply(204);
806
1093
  });
807
1094
 
808
- it('should apply the expression before sending the values', function (done) {
809
- iotAgentLib.update('light1', 'Light', '', values, function (error) {
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 are expressions including other attributes and they are not updated', function () {
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: 'x',
1108
+ name: 'lat',
821
1109
  type: 'Number',
822
- value: 0.44
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', 'smartGondor')
1128
+ .matchHeader('fiware-service', 'smartgondor')
831
1129
  .matchHeader('fiware-servicepath', 'gardens')
832
- .post(
833
- '/v2/entities/light1/attrs',
1130
+ .patch(
1131
+ '/v2/entities/gps1/attrs',
834
1132
  utils.readExampleFile(
835
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json'
1133
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
836
1134
  )
837
1135
  )
838
- .query({ type: 'Light' })
1136
+ .query({ type: 'GPS' })
839
1137
  .reply(204);
840
1138
  });
841
1139
 
842
- it('should apply the expression before sending the values', function (done) {
843
- iotAgentLib.update('light1', 'Light', '', values, function (error) {
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 are expressions including other attributes and they are updated', function () {
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: 'p',
1153
+ name: 'lat',
855
1154
  type: 'Number',
856
- value: 10
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', 'smartGondor')
1178
+ .matchHeader('fiware-service', 'smartgondor')
865
1179
  .matchHeader('fiware-servicepath', 'gardens')
866
- .post(
867
- '/v2/entities/light1/attrs',
1180
+ .patch(
1181
+ '/v2/entities/gps1/attrs',
868
1182
  utils.readExampleFile(
869
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
1183
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json'
870
1184
  )
871
1185
  )
872
- .query({ type: 'Light' })
1186
+ .query({ type: 'GPS' })
873
1187
  .reply(204);
874
1188
  });
875
1189
 
876
- it('should apply the expression before sending the values', function (done) {
877
- iotAgentLib.update('light1', 'Light', '', values, function (error) {
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 are expressions including other attributes and they are updated (overriding situation)', function () {
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: 'x',
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: 0.44
1261
+ value: 52
891
1262
  },
892
1263
  {
893
- name: 'p',
1264
+ name: 'lon',
894
1265
  type: 'Number',
895
- value: 10
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', 'smartGondor')
1282
+ .matchHeader('fiware-service', 'smartgondor')
904
1283
  .matchHeader('fiware-servicepath', 'gardens')
905
- .post(
906
- '/v2/entities/light1/attrs',
1284
+ .patch(
1285
+ '/v2/entities/gps1/attrs',
907
1286
  utils.readExampleFile(
908
- './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json'
1287
+ './test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json'
909
1288
  )
910
1289
  )
911
- .query({ type: 'Light' })
1290
+ .query({ type: 'GPS' })
912
1291
  .reply(204);
913
1292
  });
914
1293
 
915
- it('should apply the expression before sending the values', function (done) {
916
- iotAgentLib.update('light1', 'Light', '', values, function (error) {
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();