Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attribute loss when updating entity #1667

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/services/ngsi/entities-NGSI-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation,
}
//remove measures that has been shadowed by an alias (some may be left and managed later)
//Maybe we must filter object_id if there is name == object_id
measures = measures.filter((item) => item.name !== currentAttr.object_id && item.name !== currentAttr.name);
measures = measures.filter((item) => item.name !== currentAttr.object_id);

if (
currentAttr.expression !== undefined &&
Expand Down
40 changes: 40 additions & 0 deletions test/functional/testCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,11 @@ const testCases = [
object_id: '.1.0.0.1',
name: 'psBatteryVoltage',
type: 'Number'
},
{
object_id: 'f_dt',
name: 'fireDetectionThreshold',
type: 'Number'
}
],
static_attributes: []
Expand Down Expand Up @@ -588,6 +593,41 @@ const testCases = [
value: 23.5
}
}
},
{
shouldName:
'A - WHEN sending defined measures by attribute names through http IT should send measures to Context Broker preserving value types, name mappings and metadatas',
type: 'single',
measure: {
url: 'http://localhost:' + config.http.port + '/iot/json',
method: 'POST',
qs: {
i: globalEnv.deviceId,
k: globalEnv.apikey
},
json: {
a: false,
fireDetectionThreshold: 10
}
},
expectation: {
id: globalEnv.entity_name,
type: globalEnv.entity_type,
attr_a: {
value: false,
type: 'Boolean',
metadata: {
accuracy: {
value: 0.8,
type: 'Float'
}
}
},
fireDetectionThreshold: {
type: 'Number',
value: 10
}
}
}
]
},
Expand Down
Loading