From 66580ae65d41d0772d9fda89488fe1deeaa48b2a Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 26 Nov 2020 08:47:53 +0100 Subject: [PATCH 1/7] Revert "Revert "Task/default attribute value null instead blank"" --- CHANGES_NEXT_RELEASE | 1 + lib/constants.js | 2 +- .../contextRequests/createMinimumProvisionedDevice.json | 2 +- .../examples/contextRequests/createProvisionedDevice.json | 2 +- .../contextRequests/createProvisionedDeviceMultientity.json | 2 +- .../contextRequests/createProvisionedDeviceWithGroup.json | 4 ++-- .../createProvisionedDeviceWithGroupAndStatic.json | 4 ++-- .../createProvisionedDeviceWithGroupAndStatic2.json | 4 ++-- .../examples/contextRequests/createTimeinstantDevice.json | 2 +- test/unit/examples/contextRequests/updateContext5.json | 6 +++--- .../contextRequests/updateProvisionActiveAttributes1.json | 2 +- .../examples/contextRequests/updateProvisionCommands1.json | 2 +- .../contextRequests/updateProvisionDeviceStatic.json | 2 +- .../contextRequests/updateProvisionMinimumDevice.json | 2 +- .../contextResponses/createBidirectionalDeviceSuccess.json | 2 +- .../examples/contextResponses/createTimeinstantSuccess.json | 4 ++-- .../contextResponses/updateProvisionCommands1Success.json | 2 +- .../examples/contextRequests/createAutoprovisionDevice.json | 2 +- .../examples/contextRequests/createExplicitAttrsDevice.json | 2 +- .../contextRequests/createMinimumProvisionedDevice.json | 4 ++-- .../examples/contextRequests/createProvisionedDevice.json | 4 ++-- .../contextRequests/createProvisionedDeviceMultientity.json | 4 ++-- .../createProvisionedDeviceWithGroupAndStatic.json | 6 +++--- .../createProvisionedDeviceWithGroupAndStatic2.json | 6 +++--- .../createProvisionedDeviceWithGroupAndStatic3.json | 6 +++--- .../createStaticAttributesProvisionDevice.json | 2 +- .../createStaticAttributesProvisionDevice2.json | 2 +- .../createStaticAttributesProvisionDevice3.json | 2 +- .../contextRequests/createTimeInstantMinimumDevice.json | 4 ++-- .../examples/contextRequests/createTimeinstantDevice.json | 2 +- .../contextRequests/updateProvisionActiveAttributes1.json | 4 ++-- .../examples/contextRequests/updateProvisionCommands1.json | 4 ++-- .../contextRequests/updateProvisionDeviceStatic.json | 4 ++-- .../contextRequests/updateProvisionMinimumDevice.json | 4 ++-- test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js | 2 +- 35 files changed, 55 insertions(+), 54 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 400c995c7..6dc846ac0 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,3 +1,4 @@ +Use null instead of ' ' as default attribute value in entity provisioned (#938) Update codebase to use ES6 - Remove JSHint and jshint overrides - Add esLint using standard tamia presets diff --git a/lib/constants.js b/lib/constants.js index b3ca4e0cf..efca9c00f 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -48,7 +48,7 @@ module.exports = { DEFAULT_MONGODB_RETRIES: 5, DEFAULT_MONGODB_RETRY_TIME: 5, - ATTRIBUTE_DEFAULT: ' ', + ATTRIBUTE_DEFAULT: null, LOCATION_TYPE: 'geo:point', LOCATION_DEFAULT: '0, 0', diff --git a/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json b/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json index 9c89b65a6..603149496 100644 --- a/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json +++ b/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json @@ -8,7 +8,7 @@ { "name": "attr_name", "type": "string", - "value": " " + "value": null } ] } diff --git a/test/unit/examples/contextRequests/createProvisionedDevice.json b/test/unit/examples/contextRequests/createProvisionedDevice.json index 03849801e..1854c5082 100644 --- a/test/unit/examples/contextRequests/createProvisionedDevice.json +++ b/test/unit/examples/contextRequests/createProvisionedDevice.json @@ -8,7 +8,7 @@ { "name": "attr_name", "type": "string", - "value": " " + "value": null }, { "name": "hardcodedAttr", diff --git a/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json b/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json index 03849801e..1854c5082 100644 --- a/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json +++ b/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json @@ -8,7 +8,7 @@ { "name": "attr_name", "type": "string", - "value": " " + "value": null }, { "name": "hardcodedAttr", diff --git a/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json b/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json index 495f2f78e..33bea352e 100644 --- a/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json +++ b/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json @@ -8,12 +8,12 @@ { "name": "attr_name", "type": "string", - "value": " " + "value": null }, { "name": "status", "type": "Boolean", - "value": " " + "value": null }, { "name": "hardcodedAttr", diff --git a/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json b/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json index 38b3b8a84..e4fd7ce7c 100644 --- a/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +++ b/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json @@ -8,12 +8,12 @@ { "name": "attr_name", "type": "string", - "value": " " + "value": null }, { "name": "status", "type": "Boolean", - "value": " " + "value": null }, { "name": "hardcodedAttr", diff --git a/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json b/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json index 15945479b..6deb762c7 100644 --- a/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +++ b/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json @@ -8,12 +8,12 @@ { "name": "attr_name", "type": "string", - "value": " " + "value": null }, { "name": "status", "type": "Boolean", - "value": " " + "value": null }, { "name": "hardcodedAttr", diff --git a/test/unit/examples/contextRequests/createTimeinstantDevice.json b/test/unit/examples/contextRequests/createTimeinstantDevice.json index a35d1962c..23beabd5c 100644 --- a/test/unit/examples/contextRequests/createTimeinstantDevice.json +++ b/test/unit/examples/contextRequests/createTimeinstantDevice.json @@ -8,7 +8,7 @@ { "name": "TimeInstant", "type": "ISO8601", - "value": " " + "value": null } ] } diff --git a/test/unit/examples/contextRequests/updateContext5.json b/test/unit/examples/contextRequests/updateContext5.json index da96ec560..0adfb3e16 100644 --- a/test/unit/examples/contextRequests/updateContext5.json +++ b/test/unit/examples/contextRequests/updateContext5.json @@ -6,14 +6,14 @@ "attributes": [{ "name": "state", "type": "Boolean", - "value": " " + "value": null }, { "name": "dimming", "type": "Percentage", - "value": " " + "value": null } ] }], "updateAction": "APPEND" -} \ No newline at end of file +} diff --git a/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json b/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json index fb532c48e..d3e7d7c2e 100644 --- a/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json +++ b/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json @@ -8,7 +8,7 @@ { "name": "temperature", "type": "centigrades", - "value": " " + "value": null } ] } diff --git a/test/unit/examples/contextRequests/updateProvisionCommands1.json b/test/unit/examples/contextRequests/updateProvisionCommands1.json index 182eb211f..4c1ef9281 100644 --- a/test/unit/examples/contextRequests/updateProvisionCommands1.json +++ b/test/unit/examples/contextRequests/updateProvisionCommands1.json @@ -8,7 +8,7 @@ { "name": "temperature", "type": "centigrades", - "value": " " + "value": null }, { "name": "move_status", diff --git a/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json b/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json index d924d298b..e455c60e7 100644 --- a/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json +++ b/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json @@ -8,7 +8,7 @@ { "name": "newAttribute", "type": "Integer", - "value": " " + "value": null }, { "name": "cellID", diff --git a/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json b/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json index dde579a2d..078c5849f 100644 --- a/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json +++ b/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json @@ -8,7 +8,7 @@ { "name": "newAttribute", "type": "Integer", - "value": " " + "value": null } ] } diff --git a/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json b/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json index 3b3f63b63..308978d0a 100644 --- a/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json +++ b/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json @@ -6,7 +6,7 @@ { "name": "location", "type": "geo:point", - "value": " " + "value": null } ], "id": "TheFirstLight", diff --git a/test/unit/examples/contextResponses/createTimeinstantSuccess.json b/test/unit/examples/contextResponses/createTimeinstantSuccess.json index cfe61d00d..e96978522 100644 --- a/test/unit/examples/contextResponses/createTimeinstantSuccess.json +++ b/test/unit/examples/contextResponses/createTimeinstantSuccess.json @@ -6,7 +6,7 @@ { "name": "TimeInstant", "type": "ISO8601", - "value": " " + "value": null } ], "id": "eii01201ttt", @@ -19,4 +19,4 @@ } } ] -} \ No newline at end of file +} diff --git a/test/unit/examples/contextResponses/updateProvisionCommands1Success.json b/test/unit/examples/contextResponses/updateProvisionCommands1Success.json index 1d5b5297c..a0b240b3b 100644 --- a/test/unit/examples/contextResponses/updateProvisionCommands1Success.json +++ b/test/unit/examples/contextResponses/updateProvisionCommands1Success.json @@ -6,7 +6,7 @@ { "name": "temperature", "type": "centigrades", - "value": " " + "value": null }, { "name": "move_status", diff --git a/test/unit/ngsiv2/examples/contextRequests/createAutoprovisionDevice.json b/test/unit/ngsiv2/examples/contextRequests/createAutoprovisionDevice.json index 49fc4f4ed..072b3dcbe 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createAutoprovisionDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/createAutoprovisionDevice.json @@ -3,6 +3,6 @@ "type": "sensor", "TimeInstant": { "type": "ISO8601", - "value": " " + "value": null } } diff --git a/test/unit/ngsiv2/examples/contextRequests/createExplicitAttrsDevice.json b/test/unit/ngsiv2/examples/contextRequests/createExplicitAttrsDevice.json index 49fc4f4ed..072b3dcbe 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createExplicitAttrsDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/createExplicitAttrsDevice.json @@ -3,6 +3,6 @@ "type": "sensor", "TimeInstant": { "type": "ISO8601", - "value": " " + "value": null } } diff --git a/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json b/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json index 2e85142d1..2307cdcfe 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json @@ -3,6 +3,6 @@ "type": "MicroLights", "attr_name": { "type": "string", - "value": " " + "value": null } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDevice.json b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDevice.json index c027d5f3e..c00dfd7df 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDevice.json @@ -3,7 +3,7 @@ "type": "TheLightType", "attr_name": { "type": "string", - "value": " " + "value": null }, "hardcodedAttr": { "type": "hardcodedType", @@ -17,4 +17,4 @@ "type": "commandResult", "value": " " } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json index 1c9849dbf..03be61df8 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json +++ b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json @@ -3,7 +3,7 @@ "type":"TheLightType", "attr_name":{ "type": "string", - "value": " " + "value": null }, "hardcodedAttr": { "type": "hardcodedType", @@ -17,4 +17,4 @@ "type": "commandResult", "value": " " } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json index 5cf84eb21..49dd1a6df 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +++ b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json @@ -3,11 +3,11 @@ "type": "TheLightType", "attr_name": { "type": "string", - "value": " " + "value": null }, "status": { "type": "Boolean", - "value": " " + "value": null }, "hardcodedAttr": { "type": "hardcodedType", @@ -33,4 +33,4 @@ "type": "commandResult", "value": " " } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json index 1b891f96f..a46cf9245 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +++ b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json @@ -3,11 +3,11 @@ "type": "SensorMachine", "attr_name": { "type": "string", - "value": " " + "value": null }, "status": { "type": "Boolean", - "value": " " + "value": null }, "hardcodedAttr": { "type": "hardcodedType", @@ -33,4 +33,4 @@ "type": "commandResult", "value": " " } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json index 228e2faeb..6d91e8e25 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json +++ b/test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json @@ -3,10 +3,10 @@ "type": "Light", "state": { "type": "Boolean", - "value": " " + "value": null }, "dimming": { "type": "Percentage", - "value": " " + "value": null } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice.json b/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice.json index 24c216610..7f862e6b3 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice.json @@ -3,7 +3,7 @@ "type": "MicroLights", "attr_name": { "type": "string", - "value": " " + "value": null }, "bootstrapServer": { "type": "Address", diff --git a/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice2.json b/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice2.json index 27ca9795e..36ff489fd 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice2.json +++ b/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice2.json @@ -3,7 +3,7 @@ "type": "MicroLights", "attr_name": { "type": "string", - "value": " " + "value": null }, "hardcodedAttr": { "type": "hardcodedType", diff --git a/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice3.json b/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice3.json index 98f978653..dfa658ca6 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice3.json +++ b/test/unit/ngsiv2/examples/contextRequests/createStaticAttributesProvisionDevice3.json @@ -3,7 +3,7 @@ "type": "MicroLights", "attr_name": { "type": "string", - "value": " " + "value": null }, "bootstrapServer": { "type": "Address", diff --git a/test/unit/ngsiv2/examples/contextRequests/createTimeInstantMinimumDevice.json b/test/unit/ngsiv2/examples/contextRequests/createTimeInstantMinimumDevice.json index 2e85142d1..2307cdcfe 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createTimeInstantMinimumDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/createTimeInstantMinimumDevice.json @@ -3,6 +3,6 @@ "type": "MicroLights", "attr_name": { "type": "string", - "value": " " + "value": null } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json b/test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json index a472b0980..fcb50354d 100644 --- a/test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json @@ -3,6 +3,6 @@ "type": "sensor", "TimeInstant": { "type": "ISO8601", - "value": " " + "value": null } } diff --git a/test/unit/ngsiv2/examples/contextRequests/updateProvisionActiveAttributes1.json b/test/unit/ngsiv2/examples/contextRequests/updateProvisionActiveAttributes1.json index ff38069ec..77df45b5c 100644 --- a/test/unit/ngsiv2/examples/contextRequests/updateProvisionActiveAttributes1.json +++ b/test/unit/ngsiv2/examples/contextRequests/updateProvisionActiveAttributes1.json @@ -1,6 +1,6 @@ { "temperature": { "type": "centigrades", - "value": " " + "value": null } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/updateProvisionCommands1.json b/test/unit/ngsiv2/examples/contextRequests/updateProvisionCommands1.json index 477b86a20..107676f02 100644 --- a/test/unit/ngsiv2/examples/contextRequests/updateProvisionCommands1.json +++ b/test/unit/ngsiv2/examples/contextRequests/updateProvisionCommands1.json @@ -1,7 +1,7 @@ { "temperature": { "type": "centigrades", - "value": " " + "value": null }, "move_status": { "type": "commandStatus", @@ -11,4 +11,4 @@ "type": "commandResult", "value": " " } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/updateProvisionDeviceStatic.json b/test/unit/ngsiv2/examples/contextRequests/updateProvisionDeviceStatic.json index 1ad1738f5..d20ecdca9 100644 --- a/test/unit/ngsiv2/examples/contextRequests/updateProvisionDeviceStatic.json +++ b/test/unit/ngsiv2/examples/contextRequests/updateProvisionDeviceStatic.json @@ -1,7 +1,7 @@ { "newAttribute": { "type": "Integer", - "value": " " + "value": null }, "cellID": { "type": "Integer", @@ -21,4 +21,4 @@ ] } } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/examples/contextRequests/updateProvisionMinimumDevice.json b/test/unit/ngsiv2/examples/contextRequests/updateProvisionMinimumDevice.json index 5c76ba612..9b3c6f9f1 100644 --- a/test/unit/ngsiv2/examples/contextRequests/updateProvisionMinimumDevice.json +++ b/test/unit/ngsiv2/examples/contextRequests/updateProvisionMinimumDevice.json @@ -1,6 +1,6 @@ { "newAttribute": { "type": "Integer", - "value": " " + "value": null } -} \ No newline at end of file +} diff --git a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js index de3c128b0..6ac99a194 100644 --- a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js @@ -342,7 +342,7 @@ describe('NGSI-v2 - Polling commands', function () { .post( '/v2/entities/Robot:r2d2/attrs?type=Robot', utils.readExampleFile( - './test/unit//ngsiv2/examples/contextRequests/updateContextCommandExpired.json' + './test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json' ) ) .reply(204); From ddf0428b73e62ecf662fa21a39fe09bc08103745 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 2 Dec 2020 08:51:11 +0100 Subject: [PATCH 2/7] Update constants.js --- lib/constants.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 8a68f6774..f5541a25d 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -90,8 +90,6 @@ module.exports = { MONGO_ALARM: 'MONGO-ALARM', ORION_ALARM: 'ORION-ALARM', IOTAM_ALARM: 'IOTAM-ALARM', - ATTRIBUTE_DEFAULT, - DATETIME_DEFAULT, getInitialValueForType }; From f044f3fb0d67d7c016a986369b165bb670d0988a Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 2 Dec 2020 09:47:53 +0100 Subject: [PATCH 3/7] Update constants.js --- lib/constants.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index f5541a25d..dd38aa93b 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -25,7 +25,7 @@ const LOCATION_DEFAULT = '0, 0'; const DATETIME_DEFAULT = '1970-01-01T00:00:00.000Z'; -const ATTRIBUTE_DEFAULT = ' '; +const ATTRIBUTE_DEFAULT = null; /** * Provides a default value for DateTime, GeoProperty and Property Attributes. @@ -79,17 +79,12 @@ module.exports = { DEFAULT_MONGODB_RETRIES: 5, DEFAULT_MONGODB_RETRY_TIME: 5, - ATTRIBUTE_DEFAULT: null, - - LOCATION_TYPE: 'geo:point', - LOCATION_DEFAULT: '0, 0', - DATETIME_TYPE: 'DateTime', - DATETIME_DEFAULT: '1970-01-01T00:00:00.000Z', - - MONGO_ALARM: 'MONGO-ALARM', ORION_ALARM: 'ORION-ALARM', IOTAM_ALARM: 'IOTAM-ALARM', + + ATTRIBUTE_DEFAULT, + DATETIME_DEFAULT, getInitialValueForType }; From 2de34bca19dee4cc93de2ea1216200df83acafe3 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 2 Dec 2020 11:14:44 +0100 Subject: [PATCH 4/7] update examples --- .../contextRequests/createMinimumProvisionedDevice.json | 2 +- .../examples/contextRequests/createProvisionedDevice.json | 2 +- .../contextRequests/createProvisionedDeviceMultientity.json | 2 +- .../createProvisionedDeviceWithGroupAndStatic.json | 2 +- .../createProvisionedDeviceWithGroupAndStatic2.json | 2 +- .../createProvisionedDeviceWithGroupAndStatic3.json | 2 +- .../contextRequests/createTimeInstantMinimumDevice.json | 2 +- .../contextRequests/updateProvisionActiveAttributes1.json | 2 +- .../examples/contextRequests/updateProvisionCommands1.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json b/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json index 376c3f0c7..34d51fd7d 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": " " + "value": null }, "id": "urn:ngsi-ld:MicroLights:FirstMicroLight", "type": "MicroLights" diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json index 8f6dab919..61181f3ea 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": " " + "value": null }, "commandAttr_info": { "type": "Property", diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json index 8f6dab919..61181f3ea 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": " " + "value": null }, "commandAttr_info": { "type": "Property", diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json index dc380d561..60bcf315d 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": " " + "value": null }, "bootstrapServer": { "type": "Property", diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json index 9ed0cf6ea..cbc6c8b03 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": " " + "value": null }, "bootstrapServer": { "type": "Property", diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json index 8e73199c8..426792164 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json @@ -5,7 +5,7 @@ "type": "Property", "value": { "@type": "Percentage", - "@value": " " + "@value": null } }, "id": "urn:ngsi-ld:Light:light1", diff --git a/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json b/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json index 376c3f0c7..34d51fd7d 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": " " + "value": null }, "id": "urn:ngsi-ld:MicroLights:FirstMicroLight", "type": "MicroLights" diff --git a/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json b/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json index 14d416828..3da7d7301 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json +++ b/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json @@ -6,7 +6,7 @@ "type": "Property", "value": { "@type": "centigrades", - "@value": " " + "@value": null } }, "type": "Light" diff --git a/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json b/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json index 029eba449..301cc4847 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json +++ b/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json @@ -20,7 +20,7 @@ "type": "Property", "value": { "@type": "centigrades", - "@value": " " + "@value": null } }, "type": "Light" From 54ec0b9fb0b3901c6e11f6eddac6c1f7006b2e76 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Mon, 14 Dec 2020 10:45:18 +0100 Subject: [PATCH 5/7] Update test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- .../contextRequests/createMinimumProvisionedDevice.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json b/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json index 34d51fd7d..cb81d45ba 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": null + "value": { "@type": "Intangible", "@value": null } }, "id": "urn:ngsi-ld:MicroLights:FirstMicroLight", "type": "MicroLights" From c39922521883d874498b711532c5de810ef13865 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Mon, 14 Dec 2020 11:41:48 +0100 Subject: [PATCH 6/7] fix null value --- .../contextRequests/createMinimumProvisionedDevice.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json b/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json index cb81d45ba..34d51fd7d 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json @@ -3,7 +3,7 @@ "@context": "http://context.json-ld", "attr_name": { "type": "Property", - "value": { "@type": "Intangible", "@value": null } + "value": null }, "id": "urn:ngsi-ld:MicroLights:FirstMicroLight", "type": "MicroLights" From 4da1d61156a51697543c3449ee6b3b9af05aacef Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Mon, 14 Dec 2020 15:24:07 +0100 Subject: [PATCH 7/7] Fixing requests --- ...teProvisionedDeviceWithGroupAndStatic.json | 108 +++++++++--------- ...eProvisionedDeviceWithGroupAndStatic2.json | 108 +++++++++--------- ...eProvisionedDeviceWithGroupAndStatic3.json | 30 ++--- 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json index 60bcf315d..52bb14d39 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json @@ -1,57 +1,57 @@ [ - { - "@context": "http://context.json-ld", - "attr_name": { - "type": "Property", - "value": null - }, - "bootstrapServer": { - "type": "Property", - "value": { - "@type": "Address", - "@value": "127.0.0.1" - } - }, - "commandAttr_info": { - "type": "Property", - "value": { - "@type": "commandResult", - "@value": " " - } - }, - "commandAttr_status": { - "type": "Property", - "value": { - "@type": "commandStatus", - "@value": "UNKNOWN" - } - }, - "hardcodedAttr": { - "type": "Property", - "value": { - "@type": "hardcodedType", - "@value": "hardcodedValue" - } - }, - "id": "urn:ngsi-ld:TheLightType:TheFirstLight", - "status": { - "type": "Property", - "value": true - }, - "type": "TheLightType", - "wheel1_info": { - "type": "Property", - "value": { - "@type": "commandResult", - "@value": " " - } - }, - "wheel1_status": { - "type": "Property", - "value": { - "@type": "commandStatus", - "@value": "UNKNOWN" - } - } + { + "@context": "http://context.json-ld", + "id": "urn:ngsi-ld:TheLightType:TheFirstLight", + "type": "TheLightType", + "attr_name": { + "type": "Property", + "value": null + }, + "status": { + "type": "Property", + "value": false + }, + "hardcodedAttr": { + "type": "Property", + "value": { + "@type": "hardcodedType", + "@value": "hardcodedValue" + } + }, + "bootstrapServer": { + "type": "Property", + "value": { + "@type": "Address", + "@value": "127.0.0.1" + } + }, + "commandAttr_status": { + "type": "Property", + "value": { + "@type": "commandStatus", + "@value": "UNKNOWN" + } + }, + "commandAttr_info": { + "type": "Property", + "value": { + "@type": "commandResult", + "@value": " " + } + }, + "wheel1_status": { + "type": "Property", + "value": { + "@type": "commandStatus", + "@value": "UNKNOWN" + } + }, + "wheel1_info": { + "type": "Property", + "value": { + "@type": "commandResult", + "@value": " " + } } + } ] diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json index cbc6c8b03..797f5e728 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json @@ -1,57 +1,57 @@ [ - { - "@context": "http://context.json-ld", - "attr_name": { - "type": "Property", - "value": null - }, - "bootstrapServer": { - "type": "Property", - "value": { - "@type": "Address", - "@value": "127.0.0.1" - } - }, - "commandAttr_info": { - "type": "Property", - "value": { - "@type": "commandResult", - "@value": " " - } - }, - "commandAttr_status": { - "type": "Property", - "value": { - "@type": "commandStatus", - "@value": "UNKNOWN" - } - }, - "hardcodedAttr": { - "type": "Property", - "value": { - "@type": "hardcodedType", - "@value": "hardcodedValue" - } - }, - "id": "urn:ngsi-ld:SensorMachine:TheFirstLight", - "status": { - "type": "Property", - "value": true - }, - "type": "SensorMachine", - "wheel1_info": { - "type": "Property", - "value": { - "@type": "commandResult", - "@value": " " - } - }, - "wheel1_status": { - "type": "Property", - "value": { - "@type": "commandStatus", - "@value": "UNKNOWN" - } - } + { + "@context": "http://context.json-ld", + "id": "urn:ngsi-ld:SensorMachine:TheFirstLight", + "type": "SensorMachine", + "attr_name": { + "type": "Property", + "value": null + }, + "status": { + "type": "Property", + "value": false + }, + "hardcodedAttr": { + "type": "Property", + "value": { + "@type": "hardcodedType", + "@value": "hardcodedValue" + } + }, + "bootstrapServer": { + "type": "Property", + "value": { + "@type": "Address", + "@value": "127.0.0.1" + } + }, + "commandAttr_status": { + "type": "Property", + "value": { + "@type": "commandStatus", + "@value": "UNKNOWN" + } + }, + "commandAttr_info": { + "type": "Property", + "value": { + "@type": "commandResult", + "@value": " " + } + }, + "wheel1_status": { + "type": "Property", + "value": { + "@type": "commandStatus", + "@value": "UNKNOWN" + } + }, + "wheel1_info": { + "type": "Property", + "value": { + "@type": "commandResult", + "@value": " " + } } + } ] diff --git a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json index 426792164..c200aac5d 100644 --- a/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json +++ b/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json @@ -1,18 +1,18 @@ [ - { - "@context": "http://context.json-ld", - "dimming": { - "type": "Property", - "value": { - "@type": "Percentage", - "@value": null - } - }, - "id": "urn:ngsi-ld:Light:light1", - "state": { - "type": "Property", - "value": true - }, - "type": "Light" + { + "@context": "http://context.json-ld", + "id": "urn:ngsi-ld:Light:light1", + "type": "Light", + "state": { + "type": "Property", + "value": false + }, + "dimming": { + "type": "Property", + "value": { + "@type": "Percentage", + "@value": null + } } + } ]