• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

telefonicaid / iotagent-node-lib / 18165933486

01 Oct 2025 02:42PM UTC coverage: 79.318% (-0.001%) from 79.319%
18165933486

Pull #1734

github

web-flow
Merge 04824d46d into fd0c311cb
Pull Request #1734: allow use commands by simple subscriptions/notifications

2038 of 2743 branches covered (74.3%)

Branch coverage included in aggregate %.

89 of 110 new or added lines in 10 files covered. (80.91%)

10 existing lines in 1 file now uncovered.

3914 of 4761 relevant lines covered (82.21%)

281.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/lib/services/ngsi/subscription-NGSI-mixed.js
1
/*
2
 * Copyright 2020 Telefonica Investigación y Desarrollo, S.A.U
3
 *
4
 * This file is part of fiware-iotagent-lib
5
 *
6
 * fiware-iotagent-lib is free software: you can redistribute it and/or
7
 * modify it under the terms of the GNU Affero General Public License as
8
 * published by the Free Software Foundation, either version 3 of the License,
9
 * or (at your option) any later version.
10
 *
11
 * fiware-iotagent-lib is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 * See the GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public
17
 * License along with fiware-iotagent-lib.
18
 * If not, see http://www.gnu.org/licenses/.
19
 *
20
 * For those usages not covered by the GNU Affero General Public License
21
 * please contact with::daniel.moranjimenez@telefonica.com
22
 *
23
 * Modified by: Jason Fox - FIWARE Foundation
24
 */
25

26
const config = require('../../commonConfig');
1✔
27
const subscriptionHandlerLD = require('./subscription-NGSI-LD');
1✔
28
const subscriptionHandlerV2 = require('./subscription-NGSI-v2');
1✔
29

30
/**
31
 * Makes a subscription for the given device's entity using NGSI-LD, triggered by the given attributes.
32
 * The contents of the notification can be selected using the "content" array (that can be left blank
33
 * to notify the complete entity).
34
 *
35
 * @param {Object} device       Object containing all the information about a particular device.
36
 * @param {Object} triggers     Array with the names of the attributes that would trigger the subscription
37
 * @param {Object} content      Array with the names of the attributes to retrieve in the notification.
38
 */
39
function subscribeNgsiMixed(device, triggers, content, attrsFormat, callback) {
40
    if (config.checkNgsiLD(device)) {
×
NEW
41
        subscriptionHandlerLD.subscribe(device, triggers, content, attrsFormat, callback);
×
42
    } else {
NEW
43
        subscriptionHandlerV2.subscribe(device, triggers, content, attrsFormat, callback);
×
44
    }
45
}
46

47
/**
48
 * Remove the subscription with the given ID from the Context Broker and from the device repository using NGSI-LD.
49
 *
50
 * @param {Object} device       Object containing all the information about a particular device.
51
 * @param {String} id           ID of the subscription to remove.
52
 */
53
function unsubscribeNgsiMixed(device, id, callback) {
54
    if (config.checkNgsiLD(device)) {
×
55
        subscriptionHandlerLD.unsubscribe(device, id, callback);
×
56
    } else {
57
        subscriptionHandlerV2.unsubscribe(device, id, callback);
×
58
    }
59
}
60

61
exports.subscribe = subscribeNgsiMixed;
1✔
62
exports.unsubscribe = unsubscribeNgsiMixed;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc