Skip to content
Open
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
57 changes: 57 additions & 0 deletions test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,19 @@ const iotAgentConfig = {
expression: 'v == undefined'
}
]
},
testContextVars: {
type: 'testNullExplicit',
explicitAttrs: true,
commands: [],
lazy: [],
active: [
{
name: 'a',
type: 'Number',
expression: 'a+":"+service+subservice+id+type'
}
]
}
},
service: 'smartgondor',
Expand Down Expand Up @@ -2418,6 +2431,50 @@ describe('Java expression language (JEXL) based transformations plugin', functio
});
});
});

describe('When using context values as part of expressions (service, subservice, dev ID)', function () {
const values = [
{
name: 'a',
type: 'Text',
value: 'Text123'
}
];

beforeEach(function () {
nock.cleanAll();

contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', 'gardens')
.post('/v2/entities?options=upsert', function (body) {
// Pending to define the expected bod, so far the output is:
// {
// id: 'testContext',
// type: 'testNullExplicit',
// a: {
// type: 'Number',
// value: 'Text123:undefinedundefinedundefinedtestNullExplicit'
// }
// }
console.log(body);
return true;
})
.reply(204);
});

afterEach(function (done) {
done();
});

it('should calculate values using device JEXL context', function (done) {
iotAgentLib.update('testContext', 'testContextVars', '', values, function (error) {
should.not.exist(error);
contextBrokerMock.done();
done();
});
});
});
});

describe('Java expression language (JEXL) based transformations plugin - Timestamps', function () {
Expand Down