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

[Bug?] Using device data JEXL context when executing iotAgentLib.update into tests #1523

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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 nested attributes names and skip measures', function (done) {
mapedraza marked this conversation as resolved.
Show resolved Hide resolved
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
Loading