@itentialopensource/adapter-meraki 1.0.4 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -305,92 +305,73 @@ describe('[unit] Adapter Base Test', () => {
305
305
  }).timeout(attemptTimeout);
306
306
  });
307
307
 
308
- describe('#getAllFunctions', () => {
309
- it('should have a getAllFunctions function', (done) => {
308
+ describe('#connect', () => {
309
+ it('should have a connect function', (done) => {
310
310
  try {
311
- assert.equal(true, typeof a.getAllFunctions === 'function');
311
+ assert.equal(true, typeof a.connect === 'function');
312
312
  done();
313
313
  } catch (error) {
314
314
  log.error(`Test Failure: ${error}`);
315
315
  done(error);
316
316
  }
317
317
  });
318
- it('should return a list of functions', (done) => {
319
- const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
320
- 'entityInList', 'getAllCapabilities', 'getAllFunctions', 'getConfig', 'getDevice', 'getDevicesFiltered', 'hasDevices', 'hasEntities',
321
- 'healthCheck', 'iapFindAdapterPath', 'iapGetAdapterQueue', 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount', 'iapMakeBrokerCall',
322
- 'iapMoveAdapterEntitiesToDB', 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapSuspendAdapter',
323
- 'iapTroubleshootAdapter', 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'isAlive', 'refreshProperties', 'addListener',
324
- 'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
325
- 'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
318
+ it('should get connected - no healthcheck', (done) => {
326
319
  try {
327
- const expectedFunctions = a.getAllFunctions();
320
+ a.healthcheckType = 'none';
321
+ a.connect();
322
+
328
323
  try {
329
- assert.equal(JSON.stringify(expectedFunctions), JSON.stringify(returnedFunctions));
324
+ assert.equal(true, a.alive);
330
325
  done();
331
- } catch (err) {
332
- log.error(`Test Failure: ${err}`);
333
- done(err);
326
+ } catch (error) {
327
+ log.error(`Test Failure: ${error}`);
328
+ done(error);
334
329
  }
335
330
  } catch (error) {
336
331
  log.error(`Adapter Exception: ${error}`);
337
332
  done(error);
338
333
  }
339
- }).timeout(attemptTimeout);
340
- });
341
-
342
- describe('#iapGetAdapterWorkflowFunctions', () => {
343
- it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
344
- try {
345
- assert.equal(true, typeof a.iapGetAdapterWorkflowFunctions === 'function');
346
- done();
347
- } catch (error) {
348
- log.error(`Test Failure: ${error}`);
349
- done(error);
350
- }
351
334
  });
352
- it('should retrieve workflow functions', (done) => {
335
+ it('should get connected - startup healthcheck', (done) => {
353
336
  try {
354
- const expectedFunctions = a.iapGetAdapterWorkflowFunctions([]);
337
+ a.healthcheckType = 'startup';
338
+ a.connect();
339
+
355
340
  try {
356
- assert.equal(0, expectedFunctions.length);
341
+ assert.equal(true, a.alive);
357
342
  done();
358
- } catch (err) {
359
- log.error(`Test Failure: ${err}`);
360
- done(err);
343
+ } catch (error) {
344
+ log.error(`Test Failure: ${error}`);
345
+ done(error);
361
346
  }
362
347
  } catch (error) {
363
348
  log.error(`Adapter Exception: ${error}`);
364
349
  done(error);
365
350
  }
366
- }).timeout(attemptTimeout);
351
+ });
367
352
  });
368
353
 
369
- describe('#checkProperties', () => {
370
- it('should have a checkProperties function', (done) => {
354
+ describe('#healthCheck', () => {
355
+ it('should have a healthCheck function', (done) => {
371
356
  try {
372
- assert.equal(true, typeof a.checkProperties === 'function');
357
+ assert.equal(true, typeof a.healthCheck === 'function');
373
358
  done();
374
359
  } catch (error) {
375
360
  log.error(`Test Failure: ${error}`);
376
361
  done(error);
377
362
  }
378
363
  });
379
- it('the sample properties should be good - if failure change the log level', (done) => {
364
+ it('should be healthy', (done) => {
380
365
  try {
381
- const samplePropsJson = require('../../sampleProperties.json');
382
- const clean = a.checkProperties(samplePropsJson.properties);
383
- try {
384
- assert.notEqual(0, Object.keys(clean));
385
- assert.equal(undefined, clean.exception);
386
- assert.notEqual(undefined, clean.host);
387
- assert.notEqual(null, clean.host);
388
- assert.notEqual('', clean.host);
389
- done();
390
- } catch (err) {
391
- log.error(`Test Failure: ${err}`);
392
- done(err);
393
- }
366
+ a.healthCheck(null, (data) => {
367
+ try {
368
+ assert.equal(true, a.healthy);
369
+ done();
370
+ } catch (err) {
371
+ log.error(`Test Failure: ${err}`);
372
+ done(err);
373
+ }
374
+ });
394
375
  } catch (error) {
395
376
  log.error(`Adapter Exception: ${error}`);
396
377
  done(error);
@@ -398,24 +379,28 @@ describe('[unit] Adapter Base Test', () => {
398
379
  }).timeout(attemptTimeout);
399
380
  });
400
381
 
401
- describe('#checkActionFiles', () => {
402
- it('should have a checkActionFiles function', (done) => {
382
+ describe('#getAllFunctions', () => {
383
+ it('should have a getAllFunctions function', (done) => {
403
384
  try {
404
- assert.equal(true, typeof a.checkActionFiles === 'function');
385
+ assert.equal(true, typeof a.getAllFunctions === 'function');
405
386
  done();
406
387
  } catch (error) {
407
388
  log.error(`Test Failure: ${error}`);
408
389
  done(error);
409
390
  }
410
391
  });
411
- it('the action files should be good - if failure change the log level as most issues are warnings', (done) => {
392
+ it('should return a list of functions', (done) => {
393
+ const returnedFunctions = ['checkActionFiles', 'checkProperties', 'connect', 'encryptProperty', 'genericAdapterRequest', 'genericAdapterRequestNoBasePath',
394
+ 'getAllFunctions', 'getConfig', 'getConfigAuth', 'getDevice', 'getDeviceAuth', 'getDevicesFiltered', 'getDevicesFilteredAuth', 'hasEntities', 'hasEntitiesAuth',
395
+ 'healthCheck', 'iapActivateTasks', 'iapDeactivateTasks', 'iapExpandedGenericAdapterRequest', 'iapFindAdapterPath', 'iapGetAdapterInventory', 'iapGetAdapterQueue',
396
+ 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount', 'iapGetDeviceCountAuth', 'iapMoveAdapterEntitiesToDB', 'iapPopulateEntityCache', 'iapRetrieveEntitiesCache',
397
+ 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapRunAdapterLint', 'iapRunAdapterTests', 'iapSuspendAdapter', 'iapTroubleshootAdapter',
398
+ 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'isAlive', 'isAliveAuth', 'refreshProperties', 'addListener', 'emit', 'eventNames', 'getMaxListeners',
399
+ 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener', 'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
412
400
  try {
413
- const clean = a.checkActionFiles();
401
+ const expectedFunctions = a.getAllFunctions();
414
402
  try {
415
- for (let c = 0; c < clean.length; c += 1) {
416
- log.error(clean[c]);
417
- }
418
- assert.equal(0, clean.length);
403
+ assert.equal(JSON.stringify(expectedFunctions), JSON.stringify(returnedFunctions));
419
404
  done();
420
405
  } catch (err) {
421
406
  log.error(`Test Failure: ${err}`);
@@ -428,19 +413,19 @@ describe('[unit] Adapter Base Test', () => {
428
413
  }).timeout(attemptTimeout);
429
414
  });
430
415
 
431
- describe('#iapGetAdapterQueue', () => {
432
- it('should have a iapGetAdapterQueue function', (done) => {
416
+ describe('#iapGetAdapterWorkflowFunctions', () => {
417
+ it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
433
418
  try {
434
- assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
419
+ assert.equal(true, typeof a.iapGetAdapterWorkflowFunctions === 'function');
435
420
  done();
436
421
  } catch (error) {
437
422
  log.error(`Test Failure: ${error}`);
438
423
  done(error);
439
424
  }
440
425
  });
441
- it('should get information for all of the requests currently in the queue', (done) => {
426
+ it('should retrieve workflow functions', (done) => {
442
427
  try {
443
- const expectedFunctions = a.iapGetAdapterQueue();
428
+ const expectedFunctions = a.iapGetAdapterWorkflowFunctions([]);
444
429
  try {
445
430
  assert.equal(0, expectedFunctions.length);
446
431
  done();
@@ -455,73 +440,61 @@ describe('[unit] Adapter Base Test', () => {
455
440
  }).timeout(attemptTimeout);
456
441
  });
457
442
 
458
- describe('#connect', () => {
459
- it('should have a connect function', (done) => {
443
+ describe('#checkActionFiles', () => {
444
+ it('should have a checkActionFiles function', (done) => {
460
445
  try {
461
- assert.equal(true, typeof a.connect === 'function');
446
+ assert.equal(true, typeof a.checkActionFiles === 'function');
462
447
  done();
463
448
  } catch (error) {
464
449
  log.error(`Test Failure: ${error}`);
465
450
  done(error);
466
451
  }
467
452
  });
468
- it('should get connected - no healthcheck', (done) => {
469
- try {
470
- a.healthcheckType = 'none';
471
- a.connect();
472
-
473
- try {
474
- assert.equal(true, a.alive);
475
- done();
476
- } catch (error) {
477
- log.error(`Test Failure: ${error}`);
478
- done(error);
479
- }
480
- } catch (error) {
481
- log.error(`Adapter Exception: ${error}`);
482
- done(error);
483
- }
484
- });
485
- it('should get connected - startup healthcheck', (done) => {
453
+ it('the action files should be good - if failure change the log level as most issues are warnings', (done) => {
486
454
  try {
487
- a.healthcheckType = 'startup';
488
- a.connect();
489
-
455
+ const clean = a.checkActionFiles();
490
456
  try {
491
- assert.equal(true, a.alive);
457
+ for (let c = 0; c < clean.length; c += 1) {
458
+ log.error(clean[c]);
459
+ }
460
+ assert.equal(0, clean.length);
492
461
  done();
493
- } catch (error) {
494
- log.error(`Test Failure: ${error}`);
495
- done(error);
462
+ } catch (err) {
463
+ log.error(`Test Failure: ${err}`);
464
+ done(err);
496
465
  }
497
466
  } catch (error) {
498
467
  log.error(`Adapter Exception: ${error}`);
499
468
  done(error);
500
469
  }
501
- });
470
+ }).timeout(attemptTimeout);
502
471
  });
503
472
 
504
- describe('#healthCheck', () => {
505
- it('should have a healthCheck function', (done) => {
473
+ describe('#checkProperties', () => {
474
+ it('should have a checkProperties function', (done) => {
506
475
  try {
507
- assert.equal(true, typeof a.healthCheck === 'function');
476
+ assert.equal(true, typeof a.checkProperties === 'function');
508
477
  done();
509
478
  } catch (error) {
510
479
  log.error(`Test Failure: ${error}`);
511
480
  done(error);
512
481
  }
513
482
  });
514
- it('should be healthy', (done) => {
483
+ it('the sample properties should be good - if failure change the log level', (done) => {
515
484
  try {
516
- a.healthCheck(null, (data) => {
517
- try {
518
- assert.equal(true, a.healthy);
519
- done();
520
- } catch (err) {
521
- log.error(`Test Failure: ${err}`);
522
- done(err);
523
- }
524
- });
485
+ const samplePropsJson = require('../../sampleProperties.json');
486
+ const clean = a.checkProperties(samplePropsJson.properties);
487
+ try {
488
+ assert.notEqual(0, Object.keys(clean));
489
+ assert.equal(undefined, clean.exception);
490
+ assert.notEqual(undefined, clean.host);
491
+ assert.notEqual(null, clean.host);
492
+ assert.notEqual('', clean.host);
493
+ done();
494
+ } catch (err) {
495
+ log.error(`Test Failure: ${err}`);
496
+ done(err);
497
+ }
525
498
  } catch (error) {
526
499
  log.error(`Adapter Exception: ${error}`);
527
500
  done(error);
@@ -583,33 +556,21 @@ describe('[unit] Adapter Base Test', () => {
583
556
  }).timeout(attemptTimeout);
584
557
  });
585
558
 
586
- const entityType = 'mockType';
587
- const entities = {
588
- response: [
589
- {
590
- name: 'Godric Gryffindor'
591
- }, {
592
- name: 'Salazar Slytherin'
593
- }
594
- ]
595
- };
596
- const key = 'name';
597
- describe('#addEntityCache', () => {
598
- it('should have a addEntityCache function', (done) => {
559
+ describe('#iapUpdateAdapterConfiguration', () => {
560
+ it('should have a iapUpdateAdapterConfiguration function', (done) => {
599
561
  try {
600
- assert.equal(true, typeof a.addEntityCache === 'function');
562
+ assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
601
563
  done();
602
564
  } catch (error) {
603
565
  log.error(`Test Failure: ${error}`);
604
566
  done(error);
605
567
  }
606
568
  });
607
- it('should take the entities and add them to the cache', (done) => {
608
- // Run the promise and verify the results match what we were expecting.
569
+ it('should return no updated if no changes are provided', (done) => {
609
570
  try {
610
- a.addEntityCache(entityType, entities, key, (data, error) => {
571
+ a.iapUpdateAdapterConfiguration(null, null, null, null, null, null, (data, error) => {
611
572
  try {
612
- assert.equal(true, data);
573
+ assert.equal('No configuration updates to make', data.response);
613
574
  done();
614
575
  } catch (err) {
615
576
  log.error(`Test Failure: ${err}`);
@@ -621,87 +582,12 @@ describe('[unit] Adapter Base Test', () => {
621
582
  done(error);
622
583
  }
623
584
  }).timeout(attemptTimeout);
624
- });
625
-
626
- const cache = [
627
- 'Godric Gryffindor',
628
- 'Salazar Slytherin'
629
- ];
630
- describe('#entityInList', () => {
631
- it('should have a entityInList function', (done) => {
632
- try {
633
- assert.equal(true, typeof a.entityInList === 'function');
634
- done();
635
- } catch (error) {
636
- log.error(`Test Failure: ${error}`);
637
- done(error);
638
- }
639
- });
640
- it('should return true if the entity is in the list of entities for this adapter', (done) => {
641
- try {
642
- const entityExist = a.entityInList('Godric Gryffindor', cache);
643
- try {
644
- assert.equal(true, entityExist[0]);
645
- done();
646
- } catch (err) {
647
- log.error(`Test Failure: ${err}`);
648
- done(err);
649
- }
650
- } catch (error) {
651
- log.error(`Adapter Exception: ${error}`);
652
- done(error);
653
- }
654
- }).timeout(attemptTimeout);
655
- it('should return false if the entity is not in the list of entities for this adapter', (done) => {
656
- try {
657
- const entityExist = a.entityInList('XXXX', cache);
658
- try {
659
- assert.equal(false, entityExist[0]);
660
- done();
661
- } catch (err) {
662
- log.error(`Test Failure: ${err}`);
663
- done(err);
664
- }
665
- } catch (error) {
666
- log.error(`Adapter Exception: ${error}`);
667
- done(error);
668
- }
669
- }).timeout(attemptTimeout);
670
- it('should return status of each item if an array is passed', (done) => {
671
- try {
672
- const entityExist = a.entityInList(['Godric Gryffindor', 'XXXX'], cache);
673
- try {
674
- assert.equal(true, entityExist[0]);
675
- assert.equal(false, entityExist[1]);
676
- done();
677
- } catch (err) {
678
- log.error(`Test Failure: ${err}`);
679
- done(err);
680
- }
681
- } catch (error) {
682
- log.error(`Adapter Exception: ${error}`);
683
- done(error);
684
- }
685
- }).timeout(attemptTimeout);
686
- });
687
-
688
- describe('#capabilityResults', () => {
689
- it('should have a capabilityResults function', (done) => {
690
- try {
691
- assert.equal(true, typeof a.capabilityResults === 'function');
692
- done();
693
- } catch (error) {
694
- log.error(`Test Failure: ${error}`);
695
- done(error);
696
- }
697
- });
698
- it('should throw an error if needupdate is passed into the function', (done) => {
585
+ it('should throw an error if missing configuration file', (done) => {
699
586
  try {
700
- const results = ['needupdate'];
701
- a.capabilityResults(results, (data, error) => {
587
+ a.iapUpdateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, null, (data, error) => {
702
588
  try {
703
- const displayE = 'Could not load entity: unknown, into cache';
704
- runErrorAsserts(data, error, 'AD.320', 'Test-Base-adapterBase-capabilityResults', displayE);
589
+ const displayE = 'configFile is required';
590
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
705
591
  done();
706
592
  } catch (err) {
707
593
  log.error(`Test Failure: ${err}`);
@@ -713,13 +599,12 @@ describe('[unit] Adapter Base Test', () => {
713
599
  done(error);
714
600
  }
715
601
  }).timeout(attemptTimeout);
716
- it('should throw an error if error is passed into the function', (done) => {
602
+ it('if not package.json, entity is required', (done) => {
717
603
  try {
718
- const results = ['error'];
719
- a.capabilityResults(results, (data, error) => {
604
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, null, (data, error) => {
720
605
  try {
721
- const displayE = 'Could not verify entity in cache';
722
- runErrorAsserts(data, error, 'AD.321', 'Test-Base-adapterBase-capabilityResults', displayE);
606
+ const displayE = 'Unsupported Configuration Change or Missing Entity';
607
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
723
608
  done();
724
609
  } catch (err) {
725
610
  log.error(`Test Failure: ${err}`);
@@ -731,12 +616,12 @@ describe('[unit] Adapter Base Test', () => {
731
616
  done(error);
732
617
  }
733
618
  }).timeout(attemptTimeout);
734
- it('should return null if nothing passed in', (done) => {
619
+ it('if not package.json, type is required', (done) => {
735
620
  try {
736
- const results = null;
737
- a.capabilityResults(results, (data, error) => {
621
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, null, (data, error) => {
738
622
  try {
739
- assert.equal(null, data);
623
+ const displayE = 'type is required';
624
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
740
625
  done();
741
626
  } catch (err) {
742
627
  log.error(`Test Failure: ${err}`);
@@ -748,12 +633,12 @@ describe('[unit] Adapter Base Test', () => {
748
633
  done(error);
749
634
  }
750
635
  }).timeout(attemptTimeout);
751
- it('should return true if results is not an array and is "found"', (done) => {
636
+ it('if not package.json, entity must be valid', (done) => {
752
637
  try {
753
- const results = 'found';
754
- a.capabilityResults(results, (data, error) => {
638
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, null, (data, error) => {
755
639
  try {
756
- assert.equal(true, data[0]);
640
+ const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
641
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
757
642
  done();
758
643
  } catch (err) {
759
644
  log.error(`Test Failure: ${err}`);
@@ -765,12 +650,25 @@ describe('[unit] Adapter Base Test', () => {
765
650
  done(error);
766
651
  }
767
652
  }).timeout(attemptTimeout);
768
- it('should return false if results is not an array and is not "found"', (done) => {
653
+ });
654
+
655
+ describe('#iapSuspendAdapter', () => {
656
+ it('should have a iapSuspendAdapter function', (done) => {
657
+ try {
658
+ assert.equal(true, typeof a.iapSuspendAdapter === 'function');
659
+ done();
660
+ } catch (error) {
661
+ log.error(`Test Failure: ${error}`);
662
+ done(error);
663
+ }
664
+ });
665
+ it('should successfully suspend the adapter', (done) => {
769
666
  try {
770
- const results = 'notfound';
771
- a.capabilityResults(results, (data, error) => {
667
+ a.iapSuspendAdapter('nopause', (data, error) => {
772
668
  try {
773
- assert.equal(false, data[0]);
669
+ assert.notEqual(null, data);
670
+ assert.notEqual(null, data.suspended);
671
+ assert.equal(true, data.suspended);
774
672
  done();
775
673
  } catch (err) {
776
674
  log.error(`Test Failure: ${err}`);
@@ -782,14 +680,25 @@ describe('[unit] Adapter Base Test', () => {
782
680
  done(error);
783
681
  }
784
682
  }).timeout(attemptTimeout);
785
- it('should process an incoming array and return an array of values', (done) => {
683
+ });
684
+
685
+ describe('#iapUnsuspendAdapter', () => {
686
+ it('should have a iapUnsuspendAdapter function', (done) => {
687
+ try {
688
+ assert.equal(true, typeof a.iapUnsuspendAdapter === 'function');
689
+ done();
690
+ } catch (error) {
691
+ log.error(`Test Failure: ${error}`);
692
+ done(error);
693
+ }
694
+ });
695
+ it('should successfully unsuspend the adapter', (done) => {
786
696
  try {
787
- const results = ['found', 'notFound', 'found'];
788
- a.capabilityResults(results, (data, error) => {
697
+ a.iapUnsuspendAdapter((data, error) => {
789
698
  try {
790
- assert.equal(true, data[0]);
791
- assert.equal(false, data[1]);
792
- assert.equal(true, data[2]);
699
+ assert.notEqual(null, data);
700
+ assert.notEqual(null, data.suspend);
701
+ assert.equal(false, data.suspend);
793
702
  done();
794
703
  } catch (err) {
795
704
  log.error(`Test Failure: ${err}`);
@@ -803,41 +712,21 @@ describe('[unit] Adapter Base Test', () => {
803
712
  }).timeout(attemptTimeout);
804
713
  });
805
714
 
806
- describe('#getAllCapabilities', () => {
807
- it('should have a getAllCapabilities function', (done) => {
715
+ describe('#iapGetAdapterQueue', () => {
716
+ it('should have a iapGetAdapterQueue function', (done) => {
808
717
  try {
809
- assert.equal(true, typeof a.getAllCapabilities === 'function');
718
+ assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
810
719
  done();
811
720
  } catch (error) {
812
721
  log.error(`Test Failure: ${error}`);
813
722
  done(error);
814
723
  }
815
724
  });
816
- it('should have capabilities returned', (done) => {
725
+ it('should get information for all of the requests currently in the queue', (done) => {
817
726
  try {
818
- const expectedCapabilities = a.getAllCapabilities();
727
+ const expectedFunctions = a.iapGetAdapterQueue();
819
728
  try {
820
- assert.notEqual(0, expectedCapabilities.length);
821
- assert.equal('.generic', expectedCapabilities[0].entity);
822
- assert.equal(10, expectedCapabilities[0].actions.length);
823
- assert.equal('getGenerics', expectedCapabilities[0].actions[0]);
824
- assert.equal('createGeneric', expectedCapabilities[0].actions[1]);
825
- assert.equal('updateGeneric', expectedCapabilities[0].actions[2]);
826
- assert.equal('patchGeneric', expectedCapabilities[0].actions[3]);
827
- assert.equal('deleteGeneric', expectedCapabilities[0].actions[4]);
828
- assert.equal('getGenericsNoBase', expectedCapabilities[0].actions[5]);
829
- assert.equal('createGenericNoBase', expectedCapabilities[0].actions[6]);
830
- assert.equal('updateGenericNoBase', expectedCapabilities[0].actions[7]);
831
- assert.equal('patchGenericNoBase', expectedCapabilities[0].actions[8]);
832
- assert.equal('deleteGenericNoBase', expectedCapabilities[0].actions[9]);
833
- assert.equal('.system', expectedCapabilities[1].entity);
834
- assert.equal(2, expectedCapabilities[1].actions.length);
835
- assert.equal('getToken', expectedCapabilities[1].actions[0]);
836
- assert.equal('healthcheck', expectedCapabilities[1].actions[1]);
837
- for (let e = 1; e < expectedCapabilities.length; e += 1) {
838
- assert.notEqual('', expectedCapabilities[e].entity);
839
- assert.notEqual(null, expectedCapabilities[e].actions);
840
- }
729
+ assert.equal(0, expectedFunctions.length);
841
730
  done();
842
731
  } catch (err) {
843
732
  log.error(`Test Failure: ${err}`);
@@ -850,21 +739,23 @@ describe('[unit] Adapter Base Test', () => {
850
739
  }).timeout(attemptTimeout);
851
740
  });
852
741
 
853
- describe('#iapUpdateAdapterConfiguration', () => {
854
- it('should have a iapUpdateAdapterConfiguration function', (done) => {
742
+ describe('#iapFindAdapterPath', () => {
743
+ it('should have a iapFindAdapterPath function', (done) => {
855
744
  try {
856
- assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
745
+ assert.equal(true, typeof a.iapFindAdapterPath === 'function');
857
746
  done();
858
747
  } catch (error) {
859
748
  log.error(`Test Failure: ${error}`);
860
749
  done(error);
861
750
  }
862
751
  });
863
- it('should return no updated if no changes are provided', (done) => {
752
+ it('should fail - missing path', (done) => {
864
753
  try {
865
- a.iapUpdateAdapterConfiguration(null, null, null, null, null, null, (data, error) => {
754
+ a.iapFindAdapterPath(null, (data, error) => {
866
755
  try {
867
- assert.equal('No configuration updates to make', data.response);
756
+ assert.notEqual(null, error);
757
+ assert.notEqual(null, error.message);
758
+ assert.equal('NO PATH PROVIDED!', error.message);
868
759
  done();
869
760
  } catch (err) {
870
761
  log.error(`Test Failure: ${err}`);
@@ -876,74 +767,258 @@ describe('[unit] Adapter Base Test', () => {
876
767
  done(error);
877
768
  }
878
769
  }).timeout(attemptTimeout);
879
- it('should throw an error if missing configuration file', (done) => {
770
+ });
771
+
772
+ describe('#iapTroubleshootAdapter', () => {
773
+ it('should have a iapTroubleshootAdapter function', (done) => {
880
774
  try {
881
- a.iapUpdateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, null, (data, error) => {
882
- try {
883
- const displayE = 'configFile is required';
884
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
885
- done();
886
- } catch (err) {
887
- log.error(`Test Failure: ${err}`);
888
- done(err);
889
- }
890
- });
775
+ assert.equal(true, typeof a.iapTroubleshootAdapter === 'function');
776
+ done();
891
777
  } catch (error) {
892
- log.error(`Adapter Exception: ${error}`);
778
+ log.error(`Test Failure: ${error}`);
893
779
  done(error);
894
780
  }
895
- }).timeout(attemptTimeout);
896
- it('if not package.json, entity is required', (done) => {
781
+ });
782
+ });
783
+
784
+ describe('#iapRunAdapterHealthcheck', () => {
785
+ it('should have a iapRunAdapterHealthcheck function', (done) => {
897
786
  try {
898
- a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, null, (data, error) => {
899
- try {
900
- const displayE = 'Unsupported Configuration Change or Missing Entity';
901
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
902
- done();
903
- } catch (err) {
904
- log.error(`Test Failure: ${err}`);
905
- done(err);
906
- }
907
- });
787
+ assert.equal(true, typeof a.iapRunAdapterHealthcheck === 'function');
788
+ done();
908
789
  } catch (error) {
909
- log.error(`Adapter Exception: ${error}`);
790
+ log.error(`Test Failure: ${error}`);
910
791
  done(error);
911
792
  }
912
- }).timeout(attemptTimeout);
913
- it('if not package.json, type is required', (done) => {
793
+ });
794
+ });
795
+
796
+ describe('#iapRunAdapterConnectivity', () => {
797
+ it('should have a iapRunAdapterConnectivity function', (done) => {
914
798
  try {
915
- a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, null, (data, error) => {
916
- try {
917
- const displayE = 'type is required';
918
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
919
- done();
920
- } catch (err) {
921
- log.error(`Test Failure: ${err}`);
922
- done(err);
923
- }
924
- });
799
+ assert.equal(true, typeof a.iapRunAdapterConnectivity === 'function');
800
+ done();
925
801
  } catch (error) {
926
- log.error(`Adapter Exception: ${error}`);
802
+ log.error(`Test Failure: ${error}`);
927
803
  done(error);
928
804
  }
929
- }).timeout(attemptTimeout);
930
- it('if not package.json, entity must be valid', (done) => {
805
+ });
806
+ });
807
+
808
+ describe('#iapRunAdapterBasicGet', () => {
809
+ it('should have a iapRunAdapterBasicGet function', (done) => {
931
810
  try {
932
- a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, null, (data, error) => {
933
- try {
934
- const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
935
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
936
- done();
937
- } catch (err) {
938
- log.error(`Test Failure: ${err}`);
939
- done(err);
940
- }
941
- });
811
+ assert.equal(true, typeof a.iapRunAdapterBasicGet === 'function');
812
+ done();
942
813
  } catch (error) {
943
- log.error(`Adapter Exception: ${error}`);
814
+ log.error(`Test Failure: ${error}`);
944
815
  done(error);
945
816
  }
946
- }).timeout(attemptTimeout);
817
+ });
818
+ });
819
+
820
+ describe('#iapMoveAdapterEntitiesToDB', () => {
821
+ it('should have a iapMoveAdapterEntitiesToDB function', (done) => {
822
+ try {
823
+ assert.equal(true, typeof a.iapMoveAdapterEntitiesToDB === 'function');
824
+ done();
825
+ } catch (error) {
826
+ log.error(`Test Failure: ${error}`);
827
+ done(error);
828
+ }
829
+ });
830
+ });
831
+
832
+ describe('#iapDeactivateTasks', () => {
833
+ it('should have a iapDeactivateTasks function', (done) => {
834
+ try {
835
+ assert.equal(true, typeof a.iapDeactivateTasks === 'function');
836
+ done();
837
+ } catch (error) {
838
+ log.error(`Test Failure: ${error}`);
839
+ done(error);
840
+ }
841
+ });
842
+ });
843
+
844
+ describe('#iapActivateTasks', () => {
845
+ it('should have a iapActivateTasks function', (done) => {
846
+ try {
847
+ assert.equal(true, typeof a.iapActivateTasks === 'function');
848
+ done();
849
+ } catch (error) {
850
+ log.error(`Test Failure: ${error}`);
851
+ done(error);
852
+ }
853
+ });
854
+ });
855
+
856
+ describe('#iapPopulateEntityCache', () => {
857
+ it('should have a iapPopulateEntityCache function', (done) => {
858
+ try {
859
+ assert.equal(true, typeof a.iapPopulateEntityCache === 'function');
860
+ done();
861
+ } catch (error) {
862
+ log.error(`Test Failure: ${error}`);
863
+ done(error);
864
+ }
865
+ });
866
+ });
867
+
868
+ describe('#iapRetrieveEntitiesCache', () => {
869
+ it('should have a iapRetrieveEntitiesCache function', (done) => {
870
+ try {
871
+ assert.equal(true, typeof a.iapRetrieveEntitiesCache === 'function');
872
+ done();
873
+ } catch (error) {
874
+ log.error(`Test Failure: ${error}`);
875
+ done(error);
876
+ }
877
+ });
878
+ });
879
+
880
+ describe('#hasEntities', () => {
881
+ it('should have a hasEntities function', (done) => {
882
+ try {
883
+ assert.equal(true, typeof a.hasEntities === 'function');
884
+ done();
885
+ } catch (error) {
886
+ log.error(`Test Failure: ${error}`);
887
+ done(error);
888
+ }
889
+ });
890
+ });
891
+
892
+ describe('#getDevice', () => {
893
+ it('should have a getDevice function', (done) => {
894
+ try {
895
+ assert.equal(true, typeof a.getDevice === 'function');
896
+ done();
897
+ } catch (error) {
898
+ log.error(`Test Failure: ${error}`);
899
+ done(error);
900
+ }
901
+ });
902
+ });
903
+
904
+ describe('#getDevicesFiltered', () => {
905
+ it('should have a getDevicesFiltered function', (done) => {
906
+ try {
907
+ assert.equal(true, typeof a.getDevicesFiltered === 'function');
908
+ done();
909
+ } catch (error) {
910
+ log.error(`Test Failure: ${error}`);
911
+ done(error);
912
+ }
913
+ });
914
+ });
915
+
916
+ describe('#isAlive', () => {
917
+ it('should have a isAlive function', (done) => {
918
+ try {
919
+ assert.equal(true, typeof a.isAlive === 'function');
920
+ done();
921
+ } catch (error) {
922
+ log.error(`Test Failure: ${error}`);
923
+ done(error);
924
+ }
925
+ });
926
+ });
927
+
928
+ describe('#getConfig', () => {
929
+ it('should have a getConfig function', (done) => {
930
+ try {
931
+ assert.equal(true, typeof a.getConfig === 'function');
932
+ done();
933
+ } catch (error) {
934
+ log.error(`Test Failure: ${error}`);
935
+ done(error);
936
+ }
937
+ });
938
+ });
939
+
940
+ describe('#iapGetDeviceCount', () => {
941
+ it('should have a iapGetDeviceCount function', (done) => {
942
+ try {
943
+ assert.equal(true, typeof a.iapGetDeviceCount === 'function');
944
+ done();
945
+ } catch (error) {
946
+ log.error(`Test Failure: ${error}`);
947
+ done(error);
948
+ }
949
+ });
950
+ });
951
+
952
+ describe('#iapExpandedGenericAdapterRequest', () => {
953
+ it('should have a iapExpandedGenericAdapterRequest function', (done) => {
954
+ try {
955
+ assert.equal(true, typeof a.iapExpandedGenericAdapterRequest === 'function');
956
+ done();
957
+ } catch (error) {
958
+ log.error(`Test Failure: ${error}`);
959
+ done(error);
960
+ }
961
+ });
962
+ });
963
+
964
+ describe('#genericAdapterRequest', () => {
965
+ it('should have a genericAdapterRequest function', (done) => {
966
+ try {
967
+ assert.equal(true, typeof a.genericAdapterRequest === 'function');
968
+ done();
969
+ } catch (error) {
970
+ log.error(`Test Failure: ${error}`);
971
+ done(error);
972
+ }
973
+ });
974
+ });
975
+
976
+ describe('#genericAdapterRequestNoBasePath', () => {
977
+ it('should have a genericAdapterRequestNoBasePath function', (done) => {
978
+ try {
979
+ assert.equal(true, typeof a.genericAdapterRequestNoBasePath === 'function');
980
+ done();
981
+ } catch (error) {
982
+ log.error(`Test Failure: ${error}`);
983
+ done(error);
984
+ }
985
+ });
986
+ });
987
+
988
+ describe('#iapRunAdapterLint', () => {
989
+ it('should have a iapRunAdapterLint function', (done) => {
990
+ try {
991
+ assert.equal(true, typeof a.iapRunAdapterLint === 'function');
992
+ done();
993
+ } catch (error) {
994
+ log.error(`Test Failure: ${error}`);
995
+ done(error);
996
+ }
997
+ });
998
+ });
999
+
1000
+ describe('#iapRunAdapterTests', () => {
1001
+ it('should have a iapRunAdapterTests function', (done) => {
1002
+ try {
1003
+ assert.equal(true, typeof a.iapRunAdapterTests === 'function');
1004
+ done();
1005
+ } catch (error) {
1006
+ log.error(`Test Failure: ${error}`);
1007
+ done(error);
1008
+ }
1009
+ });
1010
+ });
1011
+
1012
+ describe('#iapGetAdapterInventory', () => {
1013
+ it('should have a iapGetAdapterInventory function', (done) => {
1014
+ try {
1015
+ assert.equal(true, typeof a.iapGetAdapterInventory === 'function');
1016
+ done();
1017
+ } catch (error) {
1018
+ log.error(`Test Failure: ${error}`);
1019
+ done(error);
1020
+ }
1021
+ });
947
1022
  });
948
1023
  });
949
1024
  });