@@ -450,6 +450,72 @@ describe('IoT Agent Lazy Devices', function() {
450
450
} ) ;
451
451
} ) ;
452
452
453
+ describe ( 'When a query arrives to the IoT Agent with an empty attributes array' , function ( ) {
454
+ var options = {
455
+ url : 'http://localhost:' + iotAgentConfig . server . port + '/v1/queryContext' ,
456
+ method : 'POST' ,
457
+ json : {
458
+ entities : [
459
+ {
460
+ type : 'Light' ,
461
+ isPattern : 'false' ,
462
+ id : 'light1'
463
+ }
464
+ ] ,
465
+ attributes : [ ]
466
+ }
467
+ } ,
468
+ sensorData = [
469
+ {
470
+ id : 'light1' ,
471
+ isPattern : false ,
472
+ type : 'Light' ,
473
+ attributes : [
474
+ {
475
+ name : 'temperature' ,
476
+ type : 'centigrades' ,
477
+ value : 19
478
+ }
479
+ ]
480
+ }
481
+ ] ;
482
+
483
+ beforeEach ( function ( done ) {
484
+ nock . cleanAll ( ) ;
485
+
486
+ contextBrokerMock = nock ( 'http://10.11.128.16:1026' )
487
+ . matchHeader ( 'fiware-service' , 'smartGondor' )
488
+ . matchHeader ( 'fiware-servicepath' , 'gardens' )
489
+ . post ( '/NGSI9/registerContext' ,
490
+ utils . readExampleFile ( './test/unit/contextAvailabilityRequests/registerIoTAgent1.json' ) )
491
+ . reply ( 200 ,
492
+ utils . readExampleFile ( './test/unit/contextAvailabilityResponses/registerIoTAgent1Success.json' ) ) ;
493
+
494
+ async . series ( [
495
+ apply ( iotAgentLib . activate , iotAgentConfig ) ,
496
+ apply ( iotAgentLib . register , device1 )
497
+ ] , done ) ;
498
+ } ) ;
499
+
500
+ it ( 'should return the information of all the attributes' , function ( done ) {
501
+ var expectedResponse = utils
502
+ . readExampleFile ( './test/unit/contextProviderResponses/queryInformationResponseEmptyAttributes.json' ) ;
503
+
504
+ iotAgentLib . setDataQueryHandler ( function ( id , type , attributes , callback ) {
505
+ should . exist ( attributes ) ;
506
+ attributes . length . should . equal ( 1 ) ;
507
+ attributes [ 0 ] . should . equal ( 'temperature' ) ;
508
+ callback ( null , sensorData [ 0 ] ) ;
509
+ } ) ;
510
+
511
+ request ( options , function ( error , response , body ) {
512
+ should . not . exist ( error ) ;
513
+ body . should . eql ( expectedResponse ) ;
514
+ done ( ) ;
515
+ } ) ;
516
+ } ) ;
517
+ } ) ;
518
+
453
519
describe ( 'When a context query arrives to the IoT Agent for a type with static attributes' , function ( ) {
454
520
var options = {
455
521
url : 'http://localhost:' + iotAgentConfig . server . port + '/v1/queryContext' ,
0 commit comments