From c048e0fa919680d665f8b0924bd5bacd974ddade Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Fri, 1 Feb 2019 15:32:46 +0100 Subject: [PATCH] Re-running prettier with no trailing comma. --- config.js | 24 ++--- lib/constants.js | 2 +- lib/db.js | 10 +- lib/middleware/logRequest.js | 2 +- lib/models/actions.js | 4 +- lib/models/actionsStore.js | 2 +- lib/models/emailAction.js | 2 +- lib/models/entitiesStore.js | 6 +- lib/models/executionsStore.js | 10 +- lib/models/keystone.js | 18 ++-- lib/models/noSignal.js | 4 +- lib/models/notices.js | 8 +- lib/models/postAction.js | 4 +- lib/models/rules.js | 28 +++--- lib/models/rulesStore.js | 14 +-- lib/models/smppAction.js | 8 +- lib/models/smsAction.js | 6 +- lib/models/twitterAction.js | 2 +- lib/models/updateAction.js | 20 ++-- lib/models/visualRules.js | 14 +-- lib/perseo.js | 8 +- lib/refreshCore.js | 2 +- lib/routes/rulesController.js | 4 +- lib/routes/versionController.js | 4 +- lib/routes/visualRulesController.js | 4 +- test/component/actions_elapsed_test.js | 2 +- test/component/actions_test.js | 26 +++--- test/component/auth_test.js | 4 +- test/component/config.js | 2 +- test/component/error_in_axn.js | 2 +- test/component/nsr_test.js | 20 ++-- test/component/rules_test.js | 22 ++--- test/component/visualrules_test.js | 24 ++--- test/unit/axn_param_utest.js | 78 ++++++++-------- test/unit/metrics_servicetime_avg.js | 2 +- test/unit/notice_location.js | 2 +- test/unit/notice_timestamp.js | 38 ++++---- test/unit/notices_Do.js | 38 ++++---- test/unit/notices_processCBNotice.js | 48 +++++----- test/unit/notices_processCBv2Notice.js | 118 +++++++++++------------ test/unit/nsr_utest.js | 8 +- test/unit/updateAction.js | 124 ++++++++++++------------- test/unit/visualrules_utest.js | 2 +- test/utils/testEnvironment.js | 4 +- 44 files changed, 387 insertions(+), 387 deletions(-) diff --git a/config.js b/config.js index 569d2cb2..60615e01 100644 --- a/config.js +++ b/config.js @@ -44,7 +44,7 @@ config.endpoint = { checkPath: '/check', versionPath: '/version', logPath: '/admin/log', - metricsPath: '/admin/metrics', + metricsPath: '/admin/metrics' }; /** @@ -64,7 +64,7 @@ config.mongo = { // The URI to use for the database connection. It supports replica set URIs. // mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] // I.e.: 'mongodb://user:pass@host1:27017,host2:27018,host3:27019/cep?replicaSet=myrep' - url: 'mongodb://localhost:27017/cep', + url: 'mongodb://localhost:27017/cep' }; /** @@ -74,7 +74,7 @@ config.orionDb = { url: 'mongodb://localhost:27017/orion', collection: 'entities', prefix: 'orion', - batchSize: 500, + batchSize: 500 }; /** @@ -86,7 +86,7 @@ config.orionDb = { config.perseoCore = { rulesURL: 'http://localhost:8080/perseo-core/rules', noticesURL: 'http://localhost:8080/perseo-core/events', - interval: 60e3 * 5, + interval: 60e3 * 5 }; /** * NEXT EPL core options (with HA) @@ -117,8 +117,8 @@ config.smtp = { */ tls: { // keep rejectUnauthorized to false when secure is also false - rejectUnauthorized: false, - }, + rejectUnauthorized: false + } }; /** @@ -128,7 +128,7 @@ config.sms = { URL: 'http://sms-endpoint/smsoutbound', API_KEY: '', API_SECRET: '', - from: 'tel:22012;phone-context=+34', + from: 'tel:22012;phone-context=+34' }; /** @@ -140,14 +140,14 @@ config.smpp = { systemid: '', password: '', from: '346666666', - enabled: false, + enabled: false }; /** * Orion (Context Broker) endpoint options */ config.orion = { - URL: 'http://orion-endpoint:1026/NGSI10/updateContext', + URL: 'http://orion-endpoint:1026/NGSI10/updateContext' }; /** @@ -157,7 +157,7 @@ config.authentication = { host: 'keystone', port: '5001', user: 'user', - password: 'password', + password: 'password' }; /** @@ -166,7 +166,7 @@ config.authentication = { */ config.collections = { rules: 'rules', - executions: 'executions', + executions: 'executions' }; /** @@ -200,7 +200,7 @@ config.checkDB = { delay: 5e3, reconnectTries: 1e3, reconnectInterval: 5e3, - bufferMaxEntries: 5, + bufferMaxEntries: 5 }; /** diff --git a/lib/constants.js b/lib/constants.js index cbae47ba..8116c013 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -32,5 +32,5 @@ module.exports = { CORRELATOR_HEADER: 'fiware-correlator', AUTH_HEADER: 'X-Auth-Token', REALIP_HEADER: 'X-Real-IP', - COMPONENT_NAME: 'perseo-fe', + COMPONENT_NAME: 'perseo-fe' }; diff --git a/lib/db.js b/lib/db.js index 2ea2725f..6cf64d13 100644 --- a/lib/db.js +++ b/lib/db.js @@ -53,13 +53,13 @@ function getDbAux(url, component, callback) { { db: { bufferMaxEntries: config.checkDB.bufferMaxEntries, - domainsEnabled: true, + domainsEnabled: true }, server: { reconnectTries: config.checkDB.reconnectTries, reconnectInterval: config.checkDB.reconnectInterval, - domainsEnabled: true, - }, + domainsEnabled: true + } }, function(err, db) { if (err) { @@ -124,9 +124,9 @@ function setUp(cbSU) { ensureIndex.bind(null, rulesCollection, { name: 1, subservice: 1, - service: 1, + service: 1 }), - ensureIndexTTL.bind(null, executionsCollection, { lastTime: 1 }, config.executionsTTL), + ensureIndexTTL.bind(null, executionsCollection, { lastTime: 1 }, config.executionsTTL) ], cbSU ); diff --git a/lib/middleware/logRequest.js b/lib/middleware/logRequest.js index a02cd671..632d5e25 100644 --- a/lib/middleware/logRequest.js +++ b/lib/middleware/logRequest.js @@ -39,7 +39,7 @@ exports.middleware = function() { headers: req.headers, body: req.body, subservice: req.subservice, - service: req.service, + service: req.service }); next(); }; diff --git a/lib/models/actions.js b/lib/models/actions.js index d68bfc9c..0c92762f 100644 --- a/lib/models/actions.js +++ b/lib/models/actions.js @@ -127,7 +127,7 @@ function conditionalExec(task, lastTime, callbackW) { return callbackS(localError, null); } }, - executionsStore.Update.bind(null, task), + executionsStore.Update.bind(null, task) ], callbackW ); @@ -255,7 +255,7 @@ function DoAction(event, callback) { queue.push({ action: actions[i], event: event, - context: event.fiwarePerseoContext, + context: event.fiwarePerseoContext }); } }); diff --git a/lib/models/actionsStore.js b/lib/models/actionsStore.js index 5f372acf..6ae7ddfd 100644 --- a/lib/models/actionsStore.js +++ b/lib/models/actionsStore.js @@ -43,7 +43,7 @@ module.exports = { } return callback(null, data.action); }); - }, + } }; /** * Constructors for possible errors from this module diff --git a/lib/models/emailAction.js b/lib/models/emailAction.js index 73102597..061459b9 100644 --- a/lib/models/emailAction.js +++ b/lib/models/emailAction.js @@ -38,7 +38,7 @@ function buildMailOptions(action, event) { from: myutils.expandVar(action.parameters.from, event), to: myutils.expandVar(action.parameters.to, event), subject: myutils.expandVar(action.parameters.subject || '', event), - text: myutils.expandVar(action.template, event), + text: myutils.expandVar(action.template, event) }; } diff --git a/lib/models/entitiesStore.js b/lib/models/entitiesStore.js index 975594fb..2ad5c96c 100644 --- a/lib/models/entitiesStore.js +++ b/lib/models/entitiesStore.js @@ -41,7 +41,7 @@ function findSilentEntities(service, subservice, ruleData, func, callback) { db = orionServiceDb(service); criterion['attrs.' + ruleData.attribute + '.modDate'] = { - $lt: Date.now() / 1000 - ruleData.reportInterval, + $lt: Date.now() / 1000 - ruleData.reportInterval }; criterion['_id.servicePath'] = subservice; if (ruleData.id) { @@ -76,7 +76,7 @@ function findSilentEntities(service, subservice, ruleData, func, callback) { func(one); count++; }); - }, + } ], function(err, result) { logger.debug(context, 'findSilentEntities %s', myutils.firstChars(result)); @@ -86,5 +86,5 @@ function findSilentEntities(service, subservice, ruleData, func, callback) { } module.exports = { - FindSilentEntities: findSilentEntities, + FindSilentEntities: findSilentEntities }; diff --git a/lib/models/executionsStore.js b/lib/models/executionsStore.js index 9395307b..8dd9fdd2 100644 --- a/lib/models/executionsStore.js +++ b/lib/models/executionsStore.js @@ -45,7 +45,7 @@ module.exports = { col.findOne( { $query: { name: ruleName, subservice: subservice, service: service, id: id, index: index }, - $orderby: { lastTime: -1 }, + $orderby: { lastTime: -1 } }, function(err, data) { myutils.logErrorIf(err); @@ -77,7 +77,7 @@ module.exports = { service: service, id: id, notice: noticeId, - index: index, + index: index }, function(err, data) { myutils.logErrorIf(err); @@ -108,13 +108,13 @@ module.exports = { service: service, id: id, notice: noticeId, - index: index, + index: index }, { $currentDate: { lastTime: true } }, { upsert: true }, cb ); - }, + } ], function(err, result) { myutils.logErrorIf(err); @@ -122,5 +122,5 @@ module.exports = { return callback(err, result); } ); - }, + } }; diff --git a/lib/models/keystone.js b/lib/models/keystone.js index 8659d779..85f37fc3 100644 --- a/lib/models/keystone.js +++ b/lib/models/keystone.js @@ -40,20 +40,20 @@ function getToken(trust, callback) { password: { user: { domain: { - name: 'admin_domain', + name: 'admin_domain' }, name: config.authentication.user, - password: config.authentication.password, - }, - }, + password: config.authentication.password + } + } }, scope: { 'OS-TRUST:trust': { - id: trust, - }, - }, - }, - }, + id: trust + } + } + } + } }; logger.debug('retrieving token from Keystone using trust [%s]', trust); diff --git a/lib/models/noSignal.js b/lib/models/noSignal.js index 2cf87abf..b03e217b 100644 --- a/lib/models/noSignal.js +++ b/lib/models/noSignal.js @@ -68,7 +68,7 @@ function alertFunc(nsLineRule, entity) { ruleName: nsLineRule[NAME], reportInterval: nsLineRule[REPORT_INTERVAL], id: entity._id.id, - type: entity._id.type, + type: entity._id.type }; // Search for modDate of the entity's attribute @@ -110,7 +110,7 @@ function checkNoSignal(period) { id: nsrule[ID], idRegexp: nsrule[ID_REGEXP], type: nsrule[TYPE], - reportInterval: nsrule[REPORT_INTERVAL], + reportInterval: nsrule[REPORT_INTERVAL] }, alertFunc.bind({}, nsrule), function(err, data) { diff --git a/lib/models/notices.js b/lib/models/notices.js index 732bda91..e589b98e 100644 --- a/lib/models/notices.js +++ b/lib/models/notices.js @@ -71,7 +71,7 @@ function parseLocation(locStr) { lat: lat, lon: lon, x: utmResult.coord.x, - y: utmResult.coord.y, + y: utmResult.coord.y }; } @@ -101,7 +101,7 @@ function parseDate(isoStr) { hourUTC: date.getUTCHours(), minuteUTC: date.getUTCMinutes(), secondUTC: date.getUTCSeconds(), - millisecondUTC: date.getUTCMilliseconds(), + millisecondUTC: date.getUTCMilliseconds() }; } } @@ -385,7 +385,7 @@ function DoNotice(orionN, callback) { { url: config.perseoCore.noticesURL, json: notice, - headers: h, + headers: h }, function(err, data) { if (err) { @@ -402,7 +402,7 @@ function DoNotice(orionN, callback) { { url: config.nextCore.noticesURL, json: notice, - headers: h, + headers: h }, myutils.logErrorIf ); diff --git a/lib/models/postAction.js b/lib/models/postAction.js index 86a71408..1ed71058 100644 --- a/lib/models/postAction.js +++ b/lib/models/postAction.js @@ -31,7 +31,7 @@ function buildPostOptions(action, event) { method: action.parameters.method || 'post', url: myutils.expandVar(action.parameters.url, event), qs: myutils.expandObject(action.parameters.qs, event), - headers: myutils.expandObject(action.parameters.headers, event), + headers: myutils.expandObject(action.parameters.headers, event) }; if (action.parameters.json) { @@ -50,7 +50,7 @@ function doIt(action, event, callback) { requestOptions = { url: options.url, qs: options.qs, - headers: options.headers, + headers: options.headers }; if (options.json) { requestOptions.json = true; diff --git a/lib/models/rules.js b/lib/models/rules.js index 2f6edef3..0a6f4ee7 100644 --- a/lib/models/rules.js +++ b/lib/models/rules.js @@ -73,11 +73,11 @@ function postR2core(rule, callback) { if (rule.text) { var eplRule = { name: myutils.ruleUniqueName(rule), - text: myutils.ruleWithContext(rule), + text: myutils.ruleWithContext(rule) }, context = { name: myutils.contextName(rule), - text: myutils.contextEPL(rule), + text: myutils.contextEPL(rule) }; async.series( @@ -90,12 +90,12 @@ function postR2core(rule, callback) { [ myutils.requestHelperWOMetrics.bind(null, 'post', { url: config.nextCore.rulesURL, - json: context, + json: context }), myutils.requestHelperWOMetrics.bind(null, 'post', { url: config.nextCore.rulesURL, - json: eplRule, - }), + json: eplRule + }) ], function(/*error*/) { cb(null); // Do not propagate error @@ -104,7 +104,7 @@ function postR2core(rule, callback) { } else { cb(null); } - }, + } ], callback ); @@ -131,7 +131,7 @@ function delR2core(rule, callback) { } else { cb(null); } - }, + } ], callback ); @@ -143,11 +143,11 @@ function putR2core(rules, callback) { if (rule.text) { rulesAndContexts.push({ name: myutils.contextName(rule), - text: myutils.contextEPL(rule), + text: myutils.contextEPL(rule) }); rulesAndContexts.push({ name: myutils.ruleUniqueName(rule), - text: myutils.ruleWithContext(rule), + text: myutils.ruleWithContext(rule) }); } }); @@ -213,7 +213,7 @@ module.exports = { noSignal.AddNSRule(rule.service, rule.subservice, rule.name, rule.nosignal); } cb(null); - }, + } ], callback ); @@ -226,7 +226,7 @@ module.exports = { function(cb) { noSignal.DeleteNSRule(rule.service, rule.subservice, rule.name); cb(null); - }, + } ], callback ); @@ -239,7 +239,7 @@ module.exports = { noSignal.RefreshAllRules(rules); cb(null, rules); }, - putR2core, + putR2core ], callback ); @@ -271,11 +271,11 @@ module.exports = { } cb(null); }, - rulesStore.Update.bind(null, id, rule), + rulesStore.Update.bind(null, id, rule) ], callback ); - }, + } }; /** * Constructors for possible errors from this module diff --git a/lib/models/rulesStore.js b/lib/models/rulesStore.js index 8b9b8cf0..b73fdf54 100644 --- a/lib/models/rulesStore.js +++ b/lib/models/rulesStore.js @@ -89,7 +89,7 @@ function search(rule, callback) { db.collection.bind(db, rulesCollectionName, { strict: true }), function(col, cb) { col.findOne({ name: rule.name, subservice: rule.subservice, service: rule.service }, cb); - }, + } ], callback ); @@ -117,7 +117,7 @@ function findAll(service, subservice, callback) { } cb(err, rules); }); - }, + } ], function(err, result) { myutils.logErrorIf(err); @@ -156,7 +156,7 @@ module.exports = { db.collection.bind(db, rulesCollectionName, { strict: true }), function(col, cb) { col.remove({ name: rule.name, subservice: rule.subservice, service: rule.service }, cb); - }, + } ], function(err, result) { myutils.logErrorIf(err); @@ -173,7 +173,7 @@ module.exports = { db.collection.bind(db, rulesCollectionName, { strict: true }), function(col, cb) { col.save(r, cb); - }, + } ], function(err, result) { myutils.logErrorIf(err); @@ -194,7 +194,7 @@ module.exports = { r, { upsert: false, - returnOriginal: false, + returnOriginal: false }, function(err, result) { if (result && result.lastErrorObject && result.lastErrorObject.updatedExisting === false) { @@ -204,7 +204,7 @@ module.exports = { return cb(err, r); } ); - }, + } ], function(err, result) { myutils.logErrorIf(err); @@ -212,7 +212,7 @@ module.exports = { return callback(err, result); } ); - }, + } }; /** * Constructors for possible errors from this module diff --git a/lib/models/smppAction.js b/lib/models/smppAction.js index d203b7ab..54330914 100644 --- a/lib/models/smppAction.js +++ b/lib/models/smppAction.js @@ -32,7 +32,7 @@ var logger = require('logops'), function buildSMSOptions(action, event) { return { text: myutils.expandVar(action.template, event), - to: myutils.expandVar(action.parameters.to, event), + to: myutils.expandVar(action.parameters.to, event) }; } @@ -70,7 +70,7 @@ function doIt(action, event, callback) { { source_addr: from, destination_addr: to, - short_message: text, + short_message: text }, function(pdu) { if (pdu.command_status === 0) { @@ -91,7 +91,7 @@ function doIt(action, event, callback) { logger.debug('smpp session host: %s, port: %s', config.smpp.host, config.smpp.port); session = new smpp.Session({ host: config.smpp.host, - port: config.smpp.port, + port: config.smpp.port }); // We will track connection state for re-connecting @@ -108,7 +108,7 @@ function doIt(action, event, callback) { session.bind_transceiver( { system_id: config.smpp.systemid, - password: config.smpp.password, + password: config.smpp.password }, function(pdu) { if (pdu.command_status === 0) { diff --git a/lib/models/smsAction.js b/lib/models/smsAction.js index 815f77bb..caeabf3b 100644 --- a/lib/models/smsAction.js +++ b/lib/models/smsAction.js @@ -32,7 +32,7 @@ var util = require('util'), function buildSMSOptions(action, event) { return { text: myutils.expandVar(action.template, event), - to: myutils.expandVar(action.parameters.to, event), + to: myutils.expandVar(action.parameters.to, event) }; } function doIt(action, event, callback) { @@ -52,8 +52,8 @@ function doIt(action, event, callback) { headers: { 'User-Agent': 'request', API_KEY: config.sms.API_KEY, - API_SECRET: config.sms.API_SECRET, - }, + API_SECRET: config.sms.API_SECRET + } }, function(err, data) { myutils.logErrorIf(err, util.format('%s -> %s', config.sms.URL, msg.to)); diff --git a/lib/models/twitterAction.js b/lib/models/twitterAction.js index dbebbd36..3ab4306d 100644 --- a/lib/models/twitterAction.js +++ b/lib/models/twitterAction.js @@ -40,7 +40,7 @@ function doIt(action, event, callback) { consumer_key: action.parameters.consumer_key, consumer_secret: action.parameters.consumer_secret, access_token_key: action.parameters.access_token_key, - access_token_secret: action.parameters.access_token_secret, + access_token_secret: action.parameters.access_token_secret /*jshint +W106 */ }, client; diff --git a/lib/models/updateAction.js b/lib/models/updateAction.js index fbf5a514..b6880ae9 100644 --- a/lib/models/updateAction.js +++ b/lib/models/updateAction.js @@ -89,12 +89,12 @@ function buildUpdateOptions(action, event) { action.parameters.attributes.push({ name: action.parameters.name, value: action.parameters.value, - type: action.parameters.attrType, + type: action.parameters.attrType }); } options = { id: myutils.expandVar(action.parameters.id, event), - isPattern: myutils.expandVar(action.parameters.isPattern, event), + isPattern: myutils.expandVar(action.parameters.isPattern, event) }; if (action.parameters.actionType) { options.actionType = myutils.expandVar(action.parameters.actionType, event); @@ -103,7 +103,7 @@ function buildUpdateOptions(action, event) { for (var i = 0; i < action.parameters.attributes.length; i++) { attr = { name: myutils.expandVar(action.parameters.attributes[i].name, event), - value: myutils.expandVar(action.parameters.attributes[i].value, event), + value: myutils.expandVar(action.parameters.attributes[i].value, event) }; //The portal does not provide 'type' for attribute, "plain" rules could @@ -132,10 +132,10 @@ function doRequest(action, event, token, callback) { { isPattern: options.isPattern, id: options.id, - attributes: options.attributes, - }, + attributes: options.attributes + } ], - updateAction: 'APPEND', + updateAction: 'APPEND' }; if (options.actionType !== undefined) { updateOrion.updateAction = options.actionType; @@ -146,7 +146,7 @@ function doRequest(action, event, token, callback) { } headers = { - Accept: 'application/json', + Accept: 'application/json' }; if (token !== null) { headers[constants.AUTH_HEADER] = token; @@ -162,7 +162,7 @@ function doRequest(action, event, token, callback) { url: new URL('v1/updateContext', config.orion.URL), body: updateOrion, json: true, - headers: headers, + headers: headers }, function(err, data) { if (err) { @@ -284,7 +284,7 @@ function processOptionParams(action, event) { var key = myutils.expandVar(attr.name, event); changes[key] = { value: theValue, - type: theType, + type: theType }; if (attr.metadata !== undefined) { changes[key].metadata = theMeta; @@ -308,7 +308,7 @@ function processOptionParams(action, event) { function doRequestV2(action, event, callback) { var options = { service: event.service, - servicepath: event.subservice, + servicepath: event.subservice }; // TODO NGSIv2 update action with trust token (similar to doItWithToken for NGSIv1) diff --git a/lib/models/visualRules.js b/lib/models/visualRules.js index 2900acfb..2c38d205 100644 --- a/lib/models/visualRules.js +++ b/lib/models/visualRules.js @@ -33,7 +33,7 @@ var util = require('util'), DIFFERENT_TO: ' != ', GREATER_OR_EQUAL_THAN: ' >= ', MINOR_OR_EQUAL_THAN: ' <= ', - MATCH: ' regexp ', + MATCH: ' regexp ' }, errors = {}; @@ -172,7 +172,7 @@ function vr2rule(cardRule) { noSignal = { checkInterval: card.timeData.interval, attribute: card.sensorData.measureName, - reportInterval: card.conditionList[0].parameterValue, + reportInterval: card.conditionList[0].parameterValue }; break; default: @@ -188,7 +188,7 @@ function vr2rule(cardRule) { action.parameters = { to: plain['mail.to'], from: plain['mail.from'], - subject: plain['mail.subject'], + subject: plain['mail.subject'] }; break; case 'SendSmsMibAction': @@ -196,14 +196,14 @@ function vr2rule(cardRule) { action.type = 'sms'; action.template = plain['sms.message']; action.parameters = { - to: plain['sms.to'], + to: plain['sms.to'] }; break; case 'updateAttribute': action.type = 'update'; action.parameters = { name: card.actionData.userParams.name, - value: card.actionData.userParams.value, + value: card.actionData.userParams.value }; if (card.actionData.userParams.actionType) { action.parameters.actionType = card.actionData.userParams.actionType; @@ -245,7 +245,7 @@ function vr2rule(cardRule) { name: r.name, conditions: conditions.join(' AND '), service: r.service, - subservice: r.subservice, + subservice: r.subservice }); } } catch (ex) { @@ -310,7 +310,7 @@ module.exports = { } callback(err, data[0].VR); }); - }, + } }; /** * Constructors for possible errors from this module diff --git a/lib/perseo.js b/lib/perseo.js index 26b96b91..f9173715 100644 --- a/lib/perseo.js +++ b/lib/perseo.js @@ -84,7 +84,7 @@ function start(callbackStart) { buf.length ); } - }, + } }) ); app.use(logRequestMiddleware.middleware()); @@ -107,7 +107,7 @@ function start(callbackStart) { function(db0, cbwf) { appContext.SetDB(db0); cbwf(null); - }, + } ], callback ); @@ -121,7 +121,7 @@ function start(callbackStart) { function(dbO, cbwf) { appContext.SetOrionDB(dbO); cbwf(null); - }, + } ], callback ); @@ -145,7 +145,7 @@ function start(callbackStart) { logger.info(context, 'listening on port %d', server.address().port); return callback(null, server); }); - }, + } ], function(err) { myutils.logErrorIf(err, context); diff --git a/lib/refreshCore.js b/lib/refreshCore.js index 167bc5e8..714978f2 100644 --- a/lib/refreshCore.js +++ b/lib/refreshCore.js @@ -36,7 +36,7 @@ var config = require('../config'), trans: 'n/a', corr: 'n/a', srv: 'n/a', - subsrv: 'n/a', + subsrv: 'n/a' }; function refreshCore() { diff --git a/lib/routes/rulesController.js b/lib/routes/rulesController.js index 04e2bd19..82a5d0ef 100644 --- a/lib/routes/rulesController.js +++ b/lib/routes/rulesController.js @@ -36,7 +36,7 @@ function GetRules(req, resp) { var rule = { name: req.params.id, subservice: req.subservice, - service: req.service, + service: req.service }; rules.Find(rule, function(err, data) { myutils.respond(resp, err, data); @@ -60,7 +60,7 @@ function DelRules(req, resp) { var rule = { name: req.params.id, subservice: req.subservice, - service: req.service, + service: req.service }; metrics.IncMetrics(req.service, req.subservice, metrics.ruleDelete); rules.Remove(rule, function(err, data) { diff --git a/lib/routes/versionController.js b/lib/routes/versionController.js index f97256f9..2e794e0a 100644 --- a/lib/routes/versionController.js +++ b/lib/routes/versionController.js @@ -30,14 +30,14 @@ var config = require('../../config'), versionObj = { name: packageObj.name, description: packageObj.description, - version: packageObj.version, + version: packageObj.version }, logLevels = { DEBUG: 'DEBUG', INFO: 'INFO', WARN: 'WARN', ERROR: 'ERROR', - FATAL: 'FATAL', + FATAL: 'FATAL' }, errors = {}, currentLevel = config.logLevel; diff --git a/lib/routes/visualRulesController.js b/lib/routes/visualRulesController.js index 89d823a7..538be6af 100644 --- a/lib/routes/visualRulesController.js +++ b/lib/routes/visualRulesController.js @@ -44,7 +44,7 @@ function GetVR(req, resp) { var rule = { name: req.params.id, subservice: req.subservice, - service: req.service, + service: req.service }; visualRules.Find(rule, function(err, data) { if (!err && data) { @@ -82,7 +82,7 @@ function DelVR(req, resp) { var rule = { name: req.params.id, subservice: req.subservice, - service: req.service, + service: req.service }; metrics.IncMetrics(req.service, req.subservice, metrics.ruleDelete); diff --git a/test/component/actions_elapsed_test.js b/test/component/actions_elapsed_test.js index 0f485681..91047b8d 100644 --- a/test/component/actions_elapsed_test.js +++ b/test/component/actions_elapsed_test.js @@ -87,7 +87,7 @@ describe('Actions elapsed', function() { function(callback) { executedActions.should.be.equal(1); return callback(null); - }, + } ], done ); diff --git a/test/component/actions_test.js b/test/component/actions_test.js index 4a389e72..31a5fd19 100644 --- a/test/component/actions_test.js +++ b/test/component/actions_test.js @@ -79,7 +79,7 @@ describe('Actions', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], done ); @@ -104,7 +104,7 @@ describe('Actions', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], done ); @@ -135,7 +135,7 @@ describe('Actions', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], done ); @@ -165,7 +165,7 @@ describe('Actions', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], done ); @@ -237,9 +237,9 @@ describe('Actions', function() { service: action.ev.service, subservice: action.ev.subservice, ruleName: rule.name, - id: action.ev.id, + id: action.ev.id }, - action: { index: 0 }, + action: { index: 0 } }, function(error, time) { @@ -250,7 +250,7 @@ describe('Actions', function() { return callback(); } ); - }, + } ], done ); @@ -286,9 +286,9 @@ describe('Actions', function() { service: action.ev.service, subservice: action.ev.subservice, ruleName: rule.name, - id: action.ev.id, + id: action.ev.id }, - action: { index: 0 }, + action: { index: 0 } }, function(error, time) { should.not.exist(error); @@ -314,9 +314,9 @@ describe('Actions', function() { service: action.ev.service, subservice: action.ev.subservice, ruleName: rule.name, - id: action.ev.id, + id: action.ev.id }, - action: { index: 0 }, + action: { index: 0 } }, function(error, time) { should.not.exist(error); @@ -324,7 +324,7 @@ describe('Actions', function() { return callback(); } ); - }, + } ], done ); @@ -385,7 +385,7 @@ describe('Actions', function() { data.should.have.property('statusCode', 500); callback(); }); - }, + } ], done ); diff --git a/test/component/auth_test.js b/test/component/auth_test.js index 112f3d6c..1ee97993 100644 --- a/test/component/auth_test.js +++ b/test/component/auth_test.js @@ -71,7 +71,7 @@ describe('Auth', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], function(error) { if (error) { @@ -107,7 +107,7 @@ describe('Auth', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], function(error) { if (error) { diff --git a/test/component/config.js b/test/component/config.js index 5bcf3404..a9c63482 100644 --- a/test/component/config.js +++ b/test/component/config.js @@ -93,7 +93,7 @@ describe('Config', function() { describe('#With next core for notices and rules', function() { utilsT.getConfig().nextCore = { noticesURL: 'http://averyfarwayhost:1234', - rulesURL: 'http://averyfarwayhost:1234', + rulesURL: 'http://averyfarwayhost:1234' }; it('should return OK when posting a rule', postRuleOK); it('should return OK when posting a notice', postNoticeOK); diff --git a/test/component/error_in_axn.js b/test/component/error_in_axn.js index 7cdd0842..75816516 100644 --- a/test/component/error_in_axn.js +++ b/test/component/error_in_axn.js @@ -91,7 +91,7 @@ describe('Actions', function() { should.equal(array.length(), 0); return callback(); }, 100); - }, + } ], callbackES ); diff --git a/test/component/nsr_test.js b/test/component/nsr_test.js index 8470fac5..e1bdc551 100644 --- a/test/component/nsr_test.js +++ b/test/component/nsr_test.js @@ -42,21 +42,21 @@ describe('Entity', function() { _id: { id: 'eA', servicePath: DEFAULT_SUBSERVICE, type: 'type e1' }, attrs: { at: { value: 1, modDate: 0 }, - other: { value: 'this is a value', modDate: 0 }, - }, + other: { value: 'this is a value', modDate: 0 } + } }, { _id: { id: 'eB', servicePath: DEFAULT_SUBSERVICE, type: '' }, attrs: { - at: { value: 2, modDate: Date.now() / 1000 - 30 * 60 }, - }, + at: { value: 2, modDate: Date.now() / 1000 - 30 * 60 } + } }, { _id: { id: 'eC', servicePath: DEFAULT_SUBSERVICE }, attrs: { - at: { value: 3, modDate: -1 }, - }, - }, + at: { value: 3, modDate: -1 } + } + } ], checkInterval = 1, rule = utilsT.loadExample('./test/data/no_signal/generic_nonsignal.json'); @@ -94,9 +94,9 @@ describe('Entity', function() { service: DEFAULT_SERVICE, subservice: DEFAULT_SUBSERVICE, ruleName: rule.name, - id: entity._id.id, + id: entity._id.id }, - action: { index: 0 }, + action: { index: 0 } }, function(error, time) { should.not.exist(error); @@ -108,7 +108,7 @@ describe('Entity', function() { }, cb ); - }, + } ], function(err, results) { // asserts diff --git a/test/component/rules_test.js b/test/component/rules_test.js index bdcde9cb..41272cfb 100644 --- a/test/component/rules_test.js +++ b/test/component/rules_test.js @@ -94,7 +94,7 @@ describe('Rules', function() { data.body.data.should.have.property('text', rule.text); return callback(); }); - }, + } ], done ); @@ -125,7 +125,7 @@ describe('Rules', function() { return callback(); }); - }, + } ], done ); @@ -157,7 +157,7 @@ describe('Rules', function() { return callback(); }); - }, + } ], done ); @@ -188,7 +188,7 @@ describe('Rules', function() { return callback(); }); - }, + } ], done ); @@ -316,7 +316,7 @@ describe('Rules', function() { data.should.have.property('statusCode', 400); return callback(null); }); - }, + } ], done ); @@ -341,7 +341,7 @@ describe('Rules', function() { callback0(); } ); - }, + } ], function(error) { should.not.exist(error); @@ -375,7 +375,7 @@ describe('Rules', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], done ); @@ -409,7 +409,7 @@ describe('Rules', function() { callback0(); } ); - }, + } ], function(error) { should.not.exist(error); @@ -443,7 +443,7 @@ describe('Rules', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], done ); @@ -468,7 +468,7 @@ describe('Rules', function() { callback0(); } ); - }, + } ], function(error) { should.not.exist(error); @@ -495,7 +495,7 @@ describe('Rules', function() { data.should.have.property('statusCode', 500); return callback(null); }); - }, + } ], function(error) { should.not.exist(error); diff --git a/test/component/visualrules_test.js b/test/component/visualrules_test.js index e2fca59b..544be510 100644 --- a/test/component/visualrules_test.js +++ b/test/component/visualrules_test.js @@ -111,7 +111,7 @@ describe('VisualRules', function() { callback0(); } ); - }, + } ], function(error) { should.not.exist(error); @@ -145,7 +145,7 @@ describe('VisualRules', function() { data.should.have.property('statusCode', 204); return callback(); }); - }, + } ], done ); @@ -179,7 +179,7 @@ describe('VisualRules', function() { callback0(); } ); - }, + } ], function(error) { should.not.exist(error); @@ -217,7 +217,7 @@ describe('VisualRules', function() { should.deepEqual(data.body.data, rule); return callback(); }); - }, + } ], done ); @@ -242,7 +242,7 @@ describe('VisualRules', function() { callback0(); } ); - }, + } ], function(error) { should.not.exist(error); @@ -280,7 +280,7 @@ describe('VisualRules', function() { should.deepEqual(data.body.data[0], rule); return callback(); }); - }, + } ], done ); @@ -295,7 +295,7 @@ describe('VisualRules', function() { data.should.have.property('statusCode', 500); return callback(null); }); - }, + } ], function(error) { should.not.exist(error); @@ -331,7 +331,7 @@ describe('VisualRules', function() { data.should.have.property('statusCode', 200); return callback(); }); - }, + } ], done ); @@ -354,7 +354,7 @@ describe('VisualRules', function() { data.should.have.property('statusCode', 400); return callback(); }); - }, + } ], done ); @@ -377,7 +377,7 @@ describe('VisualRules', function() { data.should.have.property('statusCode', 400); return callback(); }); - }, + } ], done ); @@ -412,7 +412,7 @@ describe('VisualRules', function() { callback0(); } ); - }, + } ], function(error) { should.not.exist(error); @@ -454,7 +454,7 @@ describe('VisualRules', function() { data.body.data.cards[0].id.should.be.equal(originalID); return callback(); }); - }, + } ], done ); diff --git a/test/unit/axn_param_utest.js b/test/unit/axn_param_utest.js index 4ca2eeda..cb2b9d50 100644 --- a/test/unit/axn_param_utest.js +++ b/test/unit/axn_param_utest.js @@ -38,9 +38,9 @@ describe('AxnParams', function() { parameters: { from: ' x = ${x}', to: 'y is ${y} ', - subject: '${z} ${z} ${z}', + subject: '${z} ${z} ${z}' }, - template: 'this is "${t}"', + template: 'this is "${t}"' }, options = emailAction.buildMailOptions(action, event); @@ -55,9 +55,9 @@ describe('AxnParams', function() { parameters: { from: ' x = 1', to: 'y is y ', - subject: '{z} $z $ { z }', + subject: '{z} $z $ { z }' }, - template: 'this is "$"', + template: 'this is "$"' }, options = emailAction.buildMailOptions(action, event); @@ -74,9 +74,9 @@ describe('AxnParams', function() { parameters: { url: 'http://${x}/${y}/${z}', qs: { '${x}': 'Y${y}Y' }, - headers: { 'X-${x}': '-${z}-', 'X-${y}': '+${z}+' }, + headers: { 'X-${x}': '-${z}-', 'X-${y}': '+${z}+' } }, - template: 'this is "${t}"', + template: 'this is "${t}"' }, options = postAction.buildPostOptions(action, event); @@ -94,8 +94,8 @@ describe('AxnParams', function() { parameters: { url: 'http://${x}/${y}/${z}', qs: { '${x}': 'Y${y}Y' }, - headers: { 'X-${x}': '-${z}-', 'X-${y}': '+${z}+' }, - }, + headers: { 'X-${x}': '-${z}-', 'X-${y}': '+${z}+' } + } }, options = postAction.buildPostOptions(action, event); @@ -110,9 +110,9 @@ describe('AxnParams', function() { parameters: { url: 'http://localhost:8080/path/entity', headers: { 'Content-type': 'application/json', 'X-Something': 'in the way she moves' }, - qs: { George: 'Harrison', Paul: 'McCartney', John: 'Lennon', Ringo: '*' }, + qs: { George: 'Harrison', Paul: 'McCartney', John: 'Lennon', Ringo: '*' } }, - template: 'this is "$"', + template: 'this is "$"' }, options = postAction.buildPostOptions(action, event); @@ -131,9 +131,9 @@ describe('AxnParams', function() { var event = { x: 1, y: 'abc', z: '***', t: 'some text' }, action = { parameters: { - to: 'http://${x}/${y}/${z}', + to: 'http://${x}/${y}/${z}' }, - template: 'this is "${t}"', + template: 'this is "${t}"' }, options = smsAction.buildSMSOptions(action, event); @@ -144,10 +144,10 @@ describe('AxnParams', function() { var event = { x: 1, y: 'abc', z: '***', t: 'some text' }, action = { parameters: { - to: 'http://localhost:8080/path/entity', + to: 'http://localhost:8080/path/entity' }, /*jshint quotmark: double */ - template: "this is '$'", + template: "this is '$'" /*jshint quotmark: single */ }, options = smsAction.buildSMSOptions(action, event); @@ -163,7 +163,7 @@ describe('AxnParams', function() { var event = { t: 'some text' }, action = { /*jshint quotmark: double */ - template: "this is '${t}'", + template: "this is '${t}'" /*jshint quotmark: single */ }, options = twitterAction.buildTwitterOptions(action, event); @@ -175,7 +175,7 @@ describe('AxnParams', function() { var event = { x: 1, y: 'abc', z: '***', t: 'some text' }, action = { /*jshint quotmark: double */ - template: "this is '$'", + template: "this is '$'" /*jshint quotmark: single */ }, options = twitterAction.buildTwitterOptions(action, event); @@ -194,8 +194,8 @@ describe('AxnParams', function() { name: '${c}', value: '${d}', isPattern: '${e}', - attrType: '${f}', - }, + attrType: '${f}' + } }, options = updateAction.buildUpdateOptions(action, event); @@ -212,8 +212,8 @@ describe('AxnParams', function() { parameters: { name: 'NAME', value: 'VALUE', - attrType: 'ATTRTYPE', - }, + attrType: 'ATTRTYPE' + } }, options = updateAction.buildUpdateOptions(action, event); @@ -237,8 +237,8 @@ describe('AxnParams', function() { parameters: { name: 'NAME', value: 'VALUE', - attrType: '${x}', - }, + attrType: '${x}' + } }, options = updateAction.buildUpdateOptions(action, event); @@ -262,7 +262,7 @@ describe('AxnParams', function() { f1: 'ATTRTYPE1', c2: 'NAME2', d2: 'VALUE2', - f2: 'ATTRTYPE2', + f2: 'ATTRTYPE2' }, action = { parameters: { @@ -273,20 +273,20 @@ describe('AxnParams', function() { { name: '${c}', value: '${d}', - type: '${f}', + type: '${f}' }, { name: '${c1}', value: '${d1}', - type: '${f1}', + type: '${f1}' }, { name: '${c2}', value: '${d2}', - type: '${f2}', - }, - ], - }, + type: '${f2}' + } + ] + } }, options = updateAction.buildUpdateOptions(action, event); @@ -314,20 +314,20 @@ describe('AxnParams', function() { { name: 'NAME', value: 'VALUE', - type: 'ATTRTYPE', + type: 'ATTRTYPE' }, { name: 'NAME1', value: 'VALUE1', - type: 'ATTRTYPE1', + type: 'ATTRTYPE1' }, { name: 'NAME2', value: 'VALUE2', - type: 'ATTRTYPE2', - }, - ], - }, + type: 'ATTRTYPE2' + } + ] + } }, options = updateAction.buildUpdateOptions(action, event); @@ -362,10 +362,10 @@ describe('AxnParams', function() { { name: 'NAME', value: 'VALUE', - type: '${x}', - }, - ], - }, + type: '${x}' + } + ] + } }, options = updateAction.buildUpdateOptions(action, event); diff --git a/test/unit/metrics_servicetime_avg.js b/test/unit/metrics_servicetime_avg.js index c0bd0d6c..cb176e21 100644 --- a/test/unit/metrics_servicetime_avg.js +++ b/test/unit/metrics_servicetime_avg.js @@ -62,7 +62,7 @@ describe('Metrics', function() { 98.26397101860493, 42.91834740433842, 94.48413769714534, - 7.29342435952276, + 7.29342435952276 ], average = 0, decorated; diff --git a/test/unit/notice_location.js b/test/unit/notice_location.js index e13b6d29..6190601a 100644 --- a/test/unit/notice_location.js +++ b/test/unit/notice_location.js @@ -35,7 +35,7 @@ describe('Notices', function() { [40.4165, -3.70256], [-33.45694, -70.64827], [-75.10194, 123.39528], - [53.386944, -2.919444], + [53.386944, -2.919444] ]; // Be careful with precision errors diff --git a/test/unit/notice_timestamp.js b/test/unit/notice_timestamp.js index bc5ae0d9..bb7c978e 100644 --- a/test/unit/notice_timestamp.js +++ b/test/unit/notice_timestamp.js @@ -40,16 +40,16 @@ function basicNotice() { { name: 'position', type: 'geo:point', - value: '40.418889, -3.691944', - }, - ], + value: '40.418889, -3.691944' + } + ] }, statusCode: { code: '200', - reasonPhrase: 'OK', - }, - }, - ], + reasonPhrase: 'OK' + } + } + ] }; } describe('Notices', function() { @@ -77,7 +77,7 @@ describe('Notices', function() { bn.contextResponses[0].contextElement.attributes.push({ name: 'birthDate', type: 'DateTime', - value: iso8601, + value: iso8601 }); processed = notices.ProcessCBNotice('s', 'sp', bn, 0); should.exist(processed); @@ -96,7 +96,7 @@ describe('Notices', function() { bn.contextResponses[0].contextElement.attributes.push({ name: 'birthDate', type: 'urn:x-ogc:def:trs:IDAS:1.0:ISO8601', - value: iso8601, + value: iso8601 }); processed = notices.ProcessCBNotice('s', 'sp', bn, 0); should.exist(processed); @@ -114,7 +114,7 @@ describe('Notices', function() { processed; bn.contextResponses[0].contextElement.attributes.push({ name: 'TimeInstant', - value: iso8601, + value: iso8601 }); processed = notices.ProcessCBNotice('s', 'sp', bn, 0); should.exist(processed); @@ -140,9 +140,9 @@ describe('Notices', function() { { name: 'when', type: 'DateTime', - value: iso8601, - }, - ], + value: iso8601 + } + ] }); processed = notices.ProcessCBNotice('s', 'sp', bn, 0); should.exist(processed); @@ -166,9 +166,9 @@ describe('Notices', function() { { name: 'when', type: 'urn:x-ogc:def:trs:IDAS:1.0:ISO8601', - value: iso8601, - }, - ], + value: iso8601 + } + ] }); processed = notices.ProcessCBNotice('s', 'sp', bn, 0); should.exist(processed); @@ -190,9 +190,9 @@ describe('Notices', function() { metadatas: [ { name: 'TimeInstant', - value: iso8601, - }, - ], + value: iso8601 + } + ] }); processed = notices.ProcessCBNotice('s', 'sp', bn, 0); should.exist(processed); diff --git a/test/unit/notices_Do.js b/test/unit/notices_Do.js index 1455dd5c..90c48695 100644 --- a/test/unit/notices_Do.js +++ b/test/unit/notices_Do.js @@ -47,14 +47,14 @@ var noticeExampleV1 = JSON.stringify({ { name: 'Attr1', type: 'Number', - value: '123', - }, - ], - }, - }, + value: '123' + } + ] + } + } ], subservice: '/test/notices/unit', - service: 'utest', + service: 'utest' }); var noticeExampleV2 = JSON.stringify({ @@ -66,12 +66,12 @@ var noticeExampleV2 = JSON.stringify({ Attr1: { type: 'Number', value: 122, - metadata: {}, - }, - }, + metadata: {} + } + } ], subservice: '/test/notices/unitv2', - service: 'utestv2', + service: 'utestv2' }); // Core mocks @@ -79,7 +79,7 @@ var coreNotice1 = { id: 'ent1', type: 'Room', service: 'utest', - subservice: '/test/notices/unit', + subservice: '/test/notices/unit' }; describe('Notices Do', function() { @@ -105,7 +105,7 @@ describe('Notices Do', function() { 'myutils.requestHelperWOMetrics': requestWOMetricsMock, 'config.perseoCore.noticesURL': 'http://mokedurl.org', 'alarm.release': alarmReleaseMock, - 'alarm.POST_EVENT': postEvent, + 'alarm.POST_EVENT': postEvent })(function() { var callback = function(e, request) { should.exist(request); @@ -120,7 +120,7 @@ describe('Notices Do', function() { requestWOMetricsMock.should.have.been.calledWith('post', { url: 'http://mokedurl.org', json: coreNotice1, - headers: h, + headers: h }); requestWOMetricsMock.should.be.calledOnce; alarmReleaseMock.should.have.been.calledWith(postEvent); @@ -171,7 +171,7 @@ describe('Notices Do', function() { 'config.perseoCore.noticesURL': 'http://mokedurl.org', 'alarm.release': alarmReleaseMock, 'alarm.POST_EVENT': postEvent, - processCBv2Notice: processCBv2NoticeMock, + processCBv2Notice: processCBv2NoticeMock })(function() { var callback = function(e, request) { should.exist(request); @@ -186,7 +186,7 @@ describe('Notices Do', function() { requestWOMetricsMock.should.have.been.calledWith('post', { url: 'http://mokedurl.org', json: coreNotice1, - headers: h, + headers: h }); requestWOMetricsMock.should.be.calledOnce; alarmReleaseMock.should.have.been.calledWith(postEvent); @@ -211,7 +211,7 @@ describe('Notices Do', function() { 'myutils.logErrorIf': logErrorMock, 'alarm.POST_EVENT': postEvent, 'config.perseoCore.noticesURL': 'http://mokedurl.org', - 'alarm.release': alarmReleaseMock, + 'alarm.release': alarmReleaseMock })(function() { var callback = function(e, request) { should.not.exists(request); @@ -248,7 +248,7 @@ describe('Notices Do', function() { 'alarm.POST_EVENT': postEvent, processCBv2Notice: processCBv2NoticeMock, 'config.nextCore': { noticesURL: 'http://nextCoreMockURL' }, - 'myutils.logErrorIf': logErrorMock, + 'myutils.logErrorIf': logErrorMock })(function() { var callback = function(e, request) { should.exist(e); @@ -263,12 +263,12 @@ describe('Notices Do', function() { expect(requestWOMetricsMock).to.have.been.calledWith('post', { url: 'http://mokedurl.org', json: coreNotice1, - headers: h, + headers: h }); expect(requestWOMetricsMock).to.have.been.calledWith('post', { url: 'http://nextCoreMockURL', json: coreNotice1, - headers: h, + headers: h }); alarmRaiseMock.should.have.been.calledWith(postEvent); alarmRaiseMock.should.be.calledOnce; diff --git a/test/unit/notices_processCBNotice.js b/test/unit/notices_processCBNotice.js index 48e0ac5a..7db89f88 100644 --- a/test/unit/notices_processCBNotice.js +++ b/test/unit/notices_processCBNotice.js @@ -56,14 +56,14 @@ var noticeExampleV1 = JSON.stringify({ { name: attrKey, type: attrType, - value: attrValue, - }, - ], - }, - }, + value: attrValue + } + ] + } + } ], subservice: subservice, - service: service, + service: service }); var processCBNotice = notices.__get__('processCBNotice'); @@ -100,7 +100,7 @@ describe('Notices NGSIv1', function() { it('should accept simple notice using Number type', function(done) { notices.__with__({ 'uuid.v1': uuidMock, - 'Date.now': dateNowMock, + 'Date.now': dateNowMock })(function() { var noticeResult = processCBNotice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -122,13 +122,13 @@ describe('Notices NGSIv1', function() { lat: lat, lon: long, x: x, - y: y, + y: y }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseLocation: parseLocationMock, + parseLocation: parseLocationMock })(function() { noticeExample.contextResponses[0].contextElement.attributes[0].type = locType; noticeExample.contextResponses[0].contextElement.attributes[0].value = locValue; @@ -161,13 +161,13 @@ describe('Notices NGSIv1', function() { year: 2018, hour: 11, minute: 31, - second: 26, + second: 26 }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseDate: parseDateMock, + parseDate: parseDateMock })(function() { noticeExample.contextResponses[0].contextElement.attributes[0].type = dateType; noticeExample.contextResponses[0].contextElement.attributes[0].value = dateValue; @@ -199,13 +199,13 @@ describe('Notices NGSIv1', function() { var metaAtVal = 'mockedValue1234'; notices.__with__({ 'uuid.v1': uuidMock, - 'Date.now': dateNowMock, + 'Date.now': dateNowMock })(function() { noticeExample.contextResponses[0].contextElement.attributes[0].metadatas = [ { name: at, - value: metaAtVal, - }, + value: metaAtVal + } ]; var noticeResult = processCBNotice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -233,20 +233,20 @@ describe('Notices NGSIv1', function() { year: 2018, hour: 11, minute: 31, - second: 26, + second: 26 }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseDate: parseDateMock, + parseDate: parseDateMock })(function() { noticeExample.contextResponses[0].contextElement.attributes[0].metadatas = [ { name: at, value: dateValue, - type: dateType, - }, + type: dateType + } ]; var noticeResult = processCBNotice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -303,20 +303,20 @@ describe('Notices NGSIv1', function() { lat: lat, lon: long, x: x, - y: y, + y: y }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseLocation: parseLocationMock, + parseLocation: parseLocationMock })(function() { noticeExample.contextResponses[0].contextElement.attributes[0].metadatas = [ { name: at, value: locValue, - type: locType, - }, + type: locType + } ]; var noticeResult = processCBNotice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -350,7 +350,7 @@ describe('Notices NGSIv1', function() { 'uuid.v1': uuidMock, 'Date.now': dateNowMock, parseLocation: parseLocationMock, - 'myutils.logErrorIf': logErrorMock, + 'myutils.logErrorIf': logErrorMock })(function() { noticeExample.contextResponses[0].contextElement.attributes[0].type = locType; noticeExample.contextResponses[0].contextElement.attributes[0].value = locValue; @@ -376,7 +376,7 @@ describe('Notices NGSIv1', function() { notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseLocation: parseLocationMock, + parseLocation: parseLocationMock })(function() { noticeExample.contextResponses[0].contextElement.attributes[0].type = locType; noticeExample.contextResponses[0].contextElement.attributes[0].value = locValue; diff --git a/test/unit/notices_processCBv2Notice.js b/test/unit/notices_processCBv2Notice.js index 2efaf900..4839a2f6 100644 --- a/test/unit/notices_processCBv2Notice.js +++ b/test/unit/notices_processCBv2Notice.js @@ -47,16 +47,16 @@ var noticeExampleV2 = { data: [ { id: id, - type: type, - }, + type: type + } ], subservice: subservice, - service: service, + service: service }; var attrKey = 'Attr1'; noticeExampleV2.data[0][attrKey] = { type: attrType, - value: attrValue, + value: attrValue }; noticeExampleV2 = JSON.stringify(noticeExampleV2); @@ -94,7 +94,7 @@ describe('Notices NGSIv2', function() { it('should accept simple notice using Number type', function(done) { notices.__with__({ 'uuid.v1': uuidMock, - 'Date.now': dateNowMock, + 'Date.now': dateNowMock })(function() { var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -114,14 +114,14 @@ describe('Notices NGSIv2', function() { var parseDateMock = sinon.spy(function() { return { a: 123, - b: 456, + b: 456 }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseDate: parseDateMock, + parseDate: parseDateMock })(function() { noticeExample.data[0][attrKey].type = dateType; noticeExample.data[0][attrKey].value = dateValue; @@ -148,14 +148,14 @@ describe('Notices NGSIv2', function() { lat: lat, lon: long, x: x, - y: y, + y: y }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseLocation: parseLocationMock, + parseLocation: parseLocationMock })(function() { noticeExample.data[0][attrKey].type = locType; noticeExample.data[0][attrKey].value = locValue; @@ -183,11 +183,11 @@ describe('Notices NGSIv2', function() { var metavalue = 'attMetaEXtraValue'; notices.__with__({ 'uuid.v1': uuidMock, - 'Date.now': dateNowMock, + 'Date.now': dateNowMock })(function() { var meta = (noticeExample.data[0].Attr1.metadata = {}); meta[at] = { - value: metavalue, + value: metavalue }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -212,18 +212,18 @@ describe('Notices NGSIv2', function() { lat: lat, lon: long, x: x, - y: y, + y: y }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseLocation: parseLocationMock, + parseLocation: parseLocationMock })(function() { var meta = (noticeExample.data[0].Attr1.metadata = {}); meta[at] = { value: locValue, - type: locType, + type: locType }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -254,19 +254,19 @@ describe('Notices NGSIv2', function() { day: 3, month: 6, year: 2018, - hour: 11, + hour: 11 // ... }; }); notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseDate: parseDateMock, + parseDate: parseDateMock })(function() { var meta = (noticeExample.data[0].Attr1.metadata = {}); meta[at] = { value: dateValue, - type: dateType, + type: dateType }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); expect(noticeResult.noticeId).to.equal(mockedUid); @@ -300,13 +300,13 @@ describe('Notices NGSIv2', function() { notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseDate: parseDateMock, + parseDate: parseDateMock })(function() { // Set Invalid DateType metadata attribute var meta = (noticeExample.data[0].Attr1.metadata = {}); meta[at] = { value: invalidMetaDate, - type: dateType, + type: dateType }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); noticeResult.should.be.instanceof(notices.errors.InvalidDateTime); @@ -330,12 +330,12 @@ describe('Notices NGSIv2', function() { notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseDate: parseDateMock, + parseDate: parseDateMock })(function() { // Set Invalid DateType attribute noticeExample.data[0].Attr1 = { value: invalidAttDate, - type: dateType, + type: dateType }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); noticeResult.should.be.instanceof(notices.errors.InvalidDateTime); @@ -359,12 +359,12 @@ describe('Notices NGSIv2', function() { notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseLocation: parseLocationMock, + parseLocation: parseLocationMock })(function() { // Set Invalid location attribute noticeExample.data[0].Attr1 = { value: invalidLoc, - type: locType, + type: locType }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); noticeResult.should.be.instanceof(notices.errors.InvalidLocation); @@ -389,13 +389,13 @@ describe('Notices NGSIv2', function() { notices.__with__({ 'uuid.v1': uuidMock, 'Date.now': dateNowMock, - parseLocation: parseLocationMock, + parseLocation: parseLocationMock })(function() { // Set Invalid location metadata attribute var meta = (noticeExample.data[0].Attr1.metadata = {}); meta[at] = { value: invalidLoc, - type: locType, + type: locType }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); noticeResult.should.be.instanceof(notices.errors.InvalidLocation); @@ -420,13 +420,13 @@ describe('Notices NGSIv2', function() { 'uuid.v1': uuidMock, 'Date.now': dateNowMock, parseLocation: parseLocationMock, - 'myutils.logErrorIf': logErrorMock, + 'myutils.logErrorIf': logErrorMock })(function() { // Set location metadata attribute var meta = (noticeExample.data[0].Attr1.metadata = {}); meta[at] = { value: locValue, - type: locType, + type: locType }; var noticeResult = processCBv2Notice(service, subservice, noticeExample, 0); noticeResult.should.be.instanceof(notices.errors.InvalidV2Notice); @@ -479,10 +479,10 @@ describe('Notices NGSIv2', function() { metadata: { metaAttr1: { type: 'geo:point', - value: '47.55555, -ll3.333x-333', - }, - }, - }, + value: '47.55555, -ll3.333x-333' + } + } + } }, { id: 'sensor-2', @@ -493,10 +493,10 @@ describe('Notices NGSIv2', function() { metadata: { metaAttr1: { type: 'geo:point', - value: '47.55555, -ll3.333x-333', - }, - }, - }, + value: '47.55555, -ll3.333x-333' + } + } + } }, { id: 'sensor-3', @@ -507,10 +507,10 @@ describe('Notices NGSIv2', function() { metadata: { metaAttr1: { type: 'geo:point', - value: '47.55555, -333.333333', - }, - }, - }, + value: '47.55555, -333.333333' + } + } + } }, { id: 'sensor-4', @@ -518,8 +518,8 @@ describe('Notices NGSIv2', function() { Attr1: { type: 'geo:point', value: '470.418889, -3.691944', - metadata: {}, - }, + metadata: {} + } }, { id: 'sensor-5', @@ -530,10 +530,10 @@ describe('Notices NGSIv2', function() { metadata: { metaAttr1: { type: 'geo:point', - value: 'x4x7x.5555x5-, -3.33333', - }, - }, - }, + value: 'x4x7x.5555x5-, -3.33333' + } + } + } }, { id: 'sensor-6', @@ -544,11 +544,11 @@ describe('Notices NGSIv2', function() { metadata: { metaAttr1: { type: 'geo:point', - value: '47.55555, 3.33333', - }, - }, - }, - }, + value: '47.55555, 3.33333' + } + } + } + } ]; noticeExample.subservice = '/test/notices/unit,/test/notices/unit,/test/notices/unit,' + @@ -577,10 +577,10 @@ describe('Notices NGSIv2', function() { metadata: { metaAttr1: { value: '2018-96-03T09:31:26.296Z', - type: 'DateTime', - }, - }, - }, + type: 'DateTime' + } + } + } }, { id: 'sensor-2', @@ -591,11 +591,11 @@ describe('Notices NGSIv2', function() { metadata: { metaAttr1: { value: '2018-06-03T09:31:26.296Z', - type: 'DateTime', - }, - }, - }, - }, + type: 'DateTime' + } + } + } + } ]; noticeExample.subservice = '/test/notices/unit,/test/notices/unit'; notices.Do(noticeExample, callback); diff --git a/test/unit/nsr_utest.js b/test/unit/nsr_utest.js index d0ea2498..a7a86a7a 100644 --- a/test/unit/nsr_utest.js +++ b/test/unit/nsr_utest.js @@ -33,8 +33,8 @@ describe('noSignal', function() { type: 'sms', template: '${device.asset.UserProps.threshold.major} message', parameters: { - to: '12345678', - }, + to: '12345678' + } }, subservice: '/', service: 'unknownt', @@ -44,8 +44,8 @@ describe('noSignal', function() { reportInterval: 900, id: null, idRegexp: '^.*', - type: null, - }, + type: null + } }; describe('#addNSRule()', function() { it('should reject to add a rule with invalid check interval', function() { diff --git a/test/unit/updateAction.js b/test/unit/updateAction.js index e64fde43..06f901fd 100644 --- a/test/unit/updateAction.js +++ b/test/unit/updateAction.js @@ -35,7 +35,7 @@ chai.Should(); chai.use(sinonChai); var metaExample = { - timestamp: '2018-12-05T12:34:32.00Z', + timestamp: '2018-12-05T12:34:32.00Z' }; var action1 = { type: 'update', @@ -45,131 +45,131 @@ var action1 = { { name: 'streetLightID', type: 'Text', - value: '${id}', + value: '${id}' }, { name: 'textNumberLit', type: 'Text', - value: 666, + value: 666 }, { name: 'textBoolLit', type: 'Text', - value: false, + value: false }, { name: 'textObjLit', type: 'Text', - value: { a: 1, b: 2 }, + value: { a: 1, b: 2 } }, { name: 'streetLightID', type: 'Text', - value: '${id}', + value: '${id}' }, { name: 'illuminanceLevel', type: 'Number', - value: '${lastLightIllumNumber}', + value: '${lastLightIllumNumber}' }, { name: 'illuminanceLevel2', type: 'Number', - value: '${lastLightIllumStringNumber}', + value: '${lastLightIllumStringNumber}' }, { name: 'illuminanceLevel3', type: 'Number', - value: 12.5, + value: 12.5 }, { name: 'lastchange', type: 'DateTime', - value: '${stringDate}', + value: '${stringDate}' }, { name: 'lastchange2', type: 'DateTime', - value: '${stringDateMs}', + value: '${stringDateMs}' }, { name: 'lastchange3', type: 'DateTime', - value: '${numberDateMs}', + value: '${numberDateMs}' }, { name: 'isBool1', type: 'Boolean', value: '${isconnected}', - metadata: metaExample, + metadata: metaExample }, { name: 'isBool2', type: 'Boolean', - value: 'TRUE', + value: 'TRUE' }, { name: 'isBool3', type: 'Boolean', - value: 'true', + value: 'true' }, { name: 'isBool4', type: 'Boolean', - value: 'False', + value: 'False' }, { name: 'isBool5', type: 'Boolean', - value: 'other', + value: 'other' }, { name: 'isBool6', type: 'Boolean', - value: true, + value: true }, { name: 'isBool7', type: 'Boolean', - value: false, + value: false }, { name: 'district', type: 'Text', - value: '${areaServed}', + value: '${areaServed}' }, { name: 'status', type: 'Text', - value: '${laststatus}', + value: '${laststatus}' }, { name: 'address', type: 'Address', - value: '${streetAddress}, ${addressLocality}', + value: '${streetAddress}, ${addressLocality}' }, { name: 'powerState', type: 'Text', - value: '${powerState}', + value: '${powerState}' }, { name: 'refNone', type: '${refNoneType}', - value: 'futureNull', + value: 'futureNull' }, { name: 'refNone2', type: '${refNoneType}', - value: '123', + value: '123' }, { name: 'refNone3', type: '${refNoneType}', - value: null, - }, - ], - }, + value: null + } + ] + } }; var event1 = { ruleName: 'switch_on', @@ -196,108 +196,108 @@ var event1 = { trans: 'f8636710-5fc6-4070-9b1e-8d414fc6522a', corr: 'd5f0a9cc-0258-11e9-b678-0242ac160003; perseocep=15', srv: 'dev_test', - subsrv: '/', - }, + subsrv: '/' + } }; var expectedChanges = { address: { value: 'Vasagatan 1, Stockholm', - type: 'Address', + type: 'Address' }, status: { value: 'allright', - type: 'Text', + type: 'Text' }, textBoolLit: { value: 'false', - type: 'Text', + type: 'Text' }, textNumberLit: { value: '666', - type: 'Text', + type: 'Text' }, textObjLit: { value: '[object Object]', - type: 'Text', + type: 'Text' }, refNone: { value: null, - type: 'None', + type: 'None' }, refNone2: { value: null, - type: 'None', + type: 'None' }, refNone3: { value: null, - type: 'None', + type: 'None' }, isBool1: { value: true, type: 'Boolean', - metadata: metaExample, + metadata: metaExample }, isBool2: { value: true, - type: 'Boolean', + type: 'Boolean' }, isBool3: { value: true, - type: 'Boolean', + type: 'Boolean' }, isBool4: { value: false, - type: 'Boolean', + type: 'Boolean' }, isBool5: { value: false, - type: 'Boolean', + type: 'Boolean' }, isBool6: { value: true, - type: 'Boolean', + type: 'Boolean' }, isBool7: { value: false, - type: 'Boolean', + type: 'Boolean' }, powerState: { value: 'on', - type: 'Text', + type: 'Text' }, illuminanceLevel: { value: 80, - type: 'Number', + type: 'Number' }, illuminanceLevel2: { value: 69, - type: 'Number', + type: 'Number' }, illuminanceLevel3: { value: 12.5, - type: 'Number', + type: 'Number' }, streetLightID: { value: 'AmbientLightSensor:1', - type: 'Text', + type: 'Text' }, district: { value: 'Stockholm center', - type: 'Text', + type: 'Text' }, lastchange: { value: '2018-12-05T11:31:39.000Z', - type: 'DateTime', + type: 'DateTime' }, lastchange2: { value: '2019-01-30T10:11:00.657Z', - type: 'DateTime', + type: 'DateTime' }, lastchange3: { value: '2019-01-30T10:13:49.832Z', - type: 'DateTime', - }, + type: 'DateTime' + } }; describe('doIt', function() { @@ -321,12 +321,12 @@ describe('doIt', function() { var NGSIConnectionMock = sinon.spy(function() { return { v2: { createEntity: createEntityMock }, - close: NGSICloseMock, + close: NGSICloseMock }; }); updateAction.__with__({ - 'NGSI.Connection': NGSIConnectionMock, + 'NGSI.Connection': NGSIConnectionMock })(function() { var callback = function(e, request) { should.exist(request); @@ -360,12 +360,12 @@ describe('doIt', function() { var NGSIConnectionMock = sinon.spy(function() { return { v2: { createEntity: createEntityMock }, - close: NGSICloseMock, + close: NGSICloseMock }; }); updateAction.__with__({ - 'NGSI.Connection': NGSIConnectionMock, + 'NGSI.Connection': NGSIConnectionMock })(function() { var callback = function(e, request) { should.exist(request); @@ -400,12 +400,12 @@ describe('doIt', function() { var NGSIConnectionMock = sinon.spy(function() { return { v2: { createEntity: createEntityMock }, - close: NGSICloseMock, + close: NGSICloseMock }; }); updateAction.__with__({ - 'NGSI.Connection': NGSIConnectionMock, + 'NGSI.Connection': NGSIConnectionMock })(function() { var callback = function(e, request) { should.not.exist(request); diff --git a/test/unit/visualrules_utest.js b/test/unit/visualrules_utest.js index 3632ed0f..f1d1ba48 100644 --- a/test/unit/visualrules_utest.js +++ b/test/unit/visualrules_utest.js @@ -49,7 +49,7 @@ describe('VisualRules', function() { 'DIFFERENT_TO', 'GREATER_OR_EQUAL_THAN', 'MINOR_OR_EQUAL_THAN', - 'MATCH', + 'MATCH' ]; cases.forEach(function(c) { var errOp = visualRules.errorOperator(c); diff --git a/test/utils/testEnvironment.js b/test/utils/testEnvironment.js index f484a927..ab43fdf2 100644 --- a/test/utils/testEnvironment.js +++ b/test/utils/testEnvironment.js @@ -75,7 +75,7 @@ function commonBeforeEach(done) { } callback(err); }); - }, + } ], done ); @@ -122,7 +122,7 @@ function commonAfterEach(done) { } callback(err); }); - }, + } ], done );