@itentialopensource/adapter-nokia_altiplano 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/BROKER.md +6 -2
  2. package/CALLS.md +144 -0
  3. package/CHANGELOG.md +24 -8
  4. package/CONTRIBUTING.md +1 -160
  5. package/ENHANCE.md +2 -2
  6. package/README.md +32 -23
  7. package/adapter.js +159 -330
  8. package/adapterBase.js +555 -852
  9. package/changelogs/changelog.md +72 -0
  10. package/metadata.json +47 -0
  11. package/package.json +25 -25
  12. package/pronghorn.json +485 -146
  13. package/propertiesSchema.json +478 -37
  14. package/refs?service=git-upload-pack +0 -0
  15. package/report/adapter-openapi.json +1546 -0
  16. package/report/adapter-openapi.yaml +1392 -0
  17. package/report/adapterInfo.json +10 -0
  18. package/report/updateReport1652620670443.json +120 -0
  19. package/report/updateReport1691507619656.json +120 -0
  20. package/report/updateReport1692202622632.json +120 -0
  21. package/report/updateReport1694462147618.json +120 -0
  22. package/report/updateReport1698421046815.json +120 -0
  23. package/sampleProperties.json +77 -9
  24. package/test/integration/adapterTestBasicGet.js +3 -5
  25. package/test/integration/adapterTestConnectivity.js +91 -42
  26. package/test/integration/adapterTestIntegration.js +154 -110
  27. package/test/unit/adapterBaseTestUnit.js +388 -313
  28. package/test/unit/adapterTestUnit.js +366 -224
  29. package/utils/adapterInfo.js +1 -1
  30. package/utils/addAuth.js +1 -1
  31. package/utils/artifactize.js +1 -1
  32. package/utils/checkMigrate.js +1 -1
  33. package/utils/entitiesToDB.js +12 -57
  34. package/utils/findPath.js +1 -1
  35. package/utils/methodDocumentor.js +273 -0
  36. package/utils/modify.js +13 -15
  37. package/utils/packModificationScript.js +1 -1
  38. package/utils/pre-commit.sh +2 -0
  39. package/utils/taskMover.js +309 -0
  40. package/utils/tbScript.js +123 -53
  41. package/utils/tbUtils.js +84 -59
  42. package/utils/testRunner.js +17 -17
  43. package/utils/troubleshootingAdapter.js +9 -6
  44. package/workflows/README.md +0 -3
@@ -4,36 +4,48 @@
4
4
  /* global describe it log pronghornProps */
5
5
  /* eslint global-require: warn */
6
6
  /* eslint no-unused-vars: warn */
7
+ /* eslint import/no-dynamic-require:warn */
7
8
 
8
9
  // include required items for testing & logging
9
10
  const assert = require('assert');
10
- const fs = require('fs-extra');
11
- const mocha = require('mocha');
12
11
  const path = require('path');
13
12
  const util = require('util');
14
- const winston = require('winston');
15
13
  const execute = require('child_process').execSync;
14
+ const fs = require('fs-extra');
15
+ const mocha = require('mocha');
16
+ const winston = require('winston');
16
17
  const { expect } = require('chai');
17
18
  const { use } = require('chai');
18
19
  const td = require('testdouble');
20
+ const Ajv = require('ajv');
19
21
 
22
+ const ajv = new Ajv({ strictSchema: false, allErrors: true, allowUnionTypes: true });
20
23
  const anything = td.matchers.anything();
21
-
22
- // stub and attemptTimeout are used throughout the code so set them here
23
24
  let logLevel = 'none';
24
- const stub = true;
25
25
  const isRapidFail = false;
26
- const attemptTimeout = 600000;
26
+
27
+ // read in the properties from the sampleProperties files
28
+ let adaptdir = __dirname;
29
+ if (adaptdir.endsWith('/test/integration')) {
30
+ adaptdir = adaptdir.substring(0, adaptdir.length - 17);
31
+ } else if (adaptdir.endsWith('/test/unit')) {
32
+ adaptdir = adaptdir.substring(0, adaptdir.length - 10);
33
+ }
34
+ const samProps = require(`${adaptdir}/sampleProperties.json`).properties;
27
35
 
28
36
  // these variables can be changed to run in integrated mode so easier to set them here
29
37
  // always check these in with bogus data!!!
30
- const host = 'replace.hostorip.here';
31
- const username = 'username';
32
- const password = 'password';
33
- const protocol = 'http';
34
- const port = 80;
35
- const sslenable = false;
36
- const sslinvalid = false;
38
+ samProps.stub = true;
39
+ samProps.host = 'replace.hostorip.here';
40
+ samProps.authentication.username = 'username';
41
+ samProps.authentication.password = 'password';
42
+ samProps.protocol = 'http';
43
+ samProps.port = 80;
44
+ samProps.ssl.enabled = false;
45
+ samProps.ssl.accept_invalid_cert = false;
46
+ samProps.request.attempt_timeout = 1200000;
47
+ const attemptTimeout = samProps.request.attempt_timeout;
48
+ const { stub } = samProps;
37
49
 
38
50
  // these are the adapter properties. You generally should not need to alter
39
51
  // any of these after they are initially set up
@@ -45,103 +57,7 @@ global.pronghornProps = {
45
57
  adapters: [{
46
58
  id: 'Test-nokia_altiplano',
47
59
  type: 'NokiaAltiplano',
48
- properties: {
49
- host,
50
- port,
51
- base_path: '/rest',
52
- version: '',
53
- cache_location: 'none',
54
- encode_pathvars: true,
55
- encode_queryvars: true,
56
- save_metric: false,
57
- stub,
58
- protocol,
59
- authentication: {
60
- auth_method: 'request_token',
61
- username,
62
- password,
63
- token: '',
64
- invalid_token_error: 401,
65
- token_timeout: 1800000,
66
- token_cache: 'local',
67
- auth_field: 'header.headers.Authorization',
68
- auth_field_format: '{token}',
69
- auth_logging: false,
70
- client_id: '',
71
- client_secret: '',
72
- grant_type: ''
73
- },
74
- healthcheck: {
75
- type: 'none',
76
- frequency: 60000,
77
- query_object: {}
78
- },
79
- throttle: {
80
- throttle_enabled: false,
81
- number_pronghorns: 1,
82
- sync_async: 'sync',
83
- max_in_queue: 1000,
84
- concurrent_max: 1,
85
- expire_timeout: 0,
86
- avg_runtime: 200,
87
- priorities: [
88
- {
89
- value: 0,
90
- percent: 100
91
- }
92
- ]
93
- },
94
- request: {
95
- number_redirects: 0,
96
- number_retries: 3,
97
- limit_retry_error: [0],
98
- failover_codes: [],
99
- attempt_timeout: attemptTimeout,
100
- global_request: {
101
- payload: {},
102
- uriOptions: {},
103
- addlHeaders: {},
104
- authData: {}
105
- },
106
- healthcheck_on_timeout: true,
107
- return_raw: true,
108
- archiving: false,
109
- return_request: false
110
- },
111
- proxy: {
112
- enabled: false,
113
- host: '',
114
- port: 1,
115
- protocol: 'http',
116
- username: '',
117
- password: ''
118
- },
119
- ssl: {
120
- ecdhCurve: '',
121
- enabled: sslenable,
122
- accept_invalid_cert: sslinvalid,
123
- ca_file: '',
124
- key_file: '',
125
- cert_file: '',
126
- secure_protocol: '',
127
- ciphers: ''
128
- },
129
- mongo: {
130
- host: '',
131
- port: 0,
132
- database: '',
133
- username: '',
134
- password: '',
135
- replSet: '',
136
- db_ssl: {
137
- enabled: false,
138
- accept_invalid_cert: false,
139
- ca_file: '',
140
- key_file: '',
141
- cert_file: ''
142
- }
143
- }
144
- }
60
+ properties: samProps
145
61
  }]
146
62
  }
147
63
  };
@@ -306,19 +222,24 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
306
222
  it('package.json should be validated', (done) => {
307
223
  try {
308
224
  const packageDotJson = require('../../package.json');
309
- const { PJV } = require('package-json-validator');
310
- const options = {
311
- warnings: true, // show warnings
312
- recommendations: true // show recommendations
225
+ // Define the JSON schema for package.json
226
+ const packageJsonSchema = {
227
+ type: 'object',
228
+ properties: {
229
+ name: { type: 'string' },
230
+ version: { type: 'string' }
231
+ // May need to add more properties as needed
232
+ },
233
+ required: ['name', 'version']
313
234
  };
314
- const results = PJV.validate(JSON.stringify(packageDotJson), 'npm', options);
235
+ const validate = ajv.compile(packageJsonSchema);
236
+ const isValid = validate(packageDotJson);
315
237
 
316
- if (results.valid === false) {
317
- log.error('The package.json contains the following errors: ');
318
- log.error(util.inspect(results));
319
- assert.equal(true, results.valid);
238
+ if (isValid === false) {
239
+ log.error('The package.json contains errors');
240
+ assert.equal(true, isValid);
320
241
  } else {
321
- assert.equal(true, results.valid);
242
+ assert.equal(true, isValid);
322
243
  }
323
244
 
324
245
  done();
@@ -357,7 +278,7 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
357
278
  assert.notEqual(undefined, packageDotJson.scripts);
358
279
  assert.notEqual(null, packageDotJson.scripts);
359
280
  assert.notEqual('', packageDotJson.scripts);
360
- assert.equal('node utils/setup.js && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions', packageDotJson.scripts.preinstall);
281
+ assert.equal('node utils/setup.js', packageDotJson.scripts.preinstall);
361
282
  assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js', packageDotJson.scripts.lint);
362
283
  assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet', packageDotJson.scripts['lint:errors']);
363
284
  assert.equal('mocha test/unit/adapterBaseTestUnit.js --LOG=error', packageDotJson.scripts['test:baseunit']);
@@ -394,17 +315,17 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
394
315
  assert.notEqual(undefined, packageDotJson.dependencies);
395
316
  assert.notEqual(null, packageDotJson.dependencies);
396
317
  assert.notEqual('', packageDotJson.dependencies);
397
- assert.equal('^6.12.0', packageDotJson.dependencies.ajv);
398
- assert.equal('^0.21.0', packageDotJson.dependencies.axios);
399
- assert.equal('^2.20.0', packageDotJson.dependencies.commander);
400
- assert.equal('^8.1.0', packageDotJson.dependencies['fs-extra']);
401
- assert.equal('^9.0.1', packageDotJson.dependencies.mocha);
318
+ assert.equal('^8.12.0', packageDotJson.dependencies.ajv);
319
+ assert.equal('^1.6.3', packageDotJson.dependencies.axios);
320
+ assert.equal('^11.0.0', packageDotJson.dependencies.commander);
321
+ assert.equal('^11.1.1', packageDotJson.dependencies['fs-extra']);
322
+ assert.equal('^10.2.0', packageDotJson.dependencies.mocha);
402
323
  assert.equal('^2.0.1', packageDotJson.dependencies['mocha-param']);
403
- assert.equal('^0.5.3', packageDotJson.dependencies['network-diagnostics']);
404
324
  assert.equal('^15.1.0', packageDotJson.dependencies.nyc);
325
+ assert.equal('^0.4.4', packageDotJson.dependencies.ping);
405
326
  assert.equal('^1.4.10', packageDotJson.dependencies['readline-sync']);
406
- assert.equal('^7.3.2', packageDotJson.dependencies.semver);
407
- assert.equal('^3.3.3', packageDotJson.dependencies.winston);
327
+ assert.equal('^7.5.3', packageDotJson.dependencies.semver);
328
+ assert.equal('^3.9.0', packageDotJson.dependencies.winston);
408
329
  done();
409
330
  } catch (error) {
410
331
  log.error(`Test Failure: ${error}`);
@@ -417,13 +338,12 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
417
338
  assert.notEqual(undefined, packageDotJson.devDependencies);
418
339
  assert.notEqual(null, packageDotJson.devDependencies);
419
340
  assert.notEqual('', packageDotJson.devDependencies);
420
- assert.equal('^4.3.4', packageDotJson.devDependencies.chai);
421
- assert.equal('^7.29.0', packageDotJson.devDependencies.eslint);
422
- assert.equal('^14.2.1', packageDotJson.devDependencies['eslint-config-airbnb-base']);
423
- assert.equal('^2.23.4', packageDotJson.devDependencies['eslint-plugin-import']);
424
- assert.equal('^3.0.0', packageDotJson.devDependencies['eslint-plugin-json']);
425
- assert.equal('^0.6.3', packageDotJson.devDependencies['package-json-validator']);
426
- assert.equal('^3.16.1', packageDotJson.devDependencies.testdouble);
341
+ assert.equal('^4.3.7', packageDotJson.devDependencies.chai);
342
+ assert.equal('^8.44.0', packageDotJson.devDependencies.eslint);
343
+ assert.equal('^15.0.0', packageDotJson.devDependencies['eslint-config-airbnb-base']);
344
+ assert.equal('^2.27.5', packageDotJson.devDependencies['eslint-plugin-import']);
345
+ assert.equal('^3.1.0', packageDotJson.devDependencies['eslint-plugin-json']);
346
+ assert.equal('^3.18.0', packageDotJson.devDependencies.testdouble);
427
347
  done();
428
348
  } catch (error) {
429
349
  log.error(`Test Failure: ${error}`);
@@ -467,16 +387,30 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
467
387
  assert.equal(true, Array.isArray(pronghornDotJson.methods));
468
388
  assert.notEqual(0, pronghornDotJson.methods.length);
469
389
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUpdateAdapterConfiguration'));
390
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapSuspendAdapter'));
391
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUnsuspendAdapter'));
392
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterQueue'));
470
393
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapFindAdapterPath'));
471
394
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapTroubleshootAdapter'));
472
395
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterHealthcheck'));
473
396
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterConnectivity'));
474
397
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterBasicGet'));
475
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapSuspendAdapter'));
476
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUnsuspendAdapter'));
477
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterQueue'));
398
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapMoveAdapterEntitiesToDB'));
399
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapDeactivateTasks'));
400
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapActivateTasks'));
401
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapPopulateEntityCache'));
402
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRetrieveEntitiesCache'));
403
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getDevice'));
404
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getDevicesFiltered'));
405
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'isAlive'));
406
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getConfig'));
407
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetDeviceCount'));
408
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapExpandedGenericAdapterRequest'));
478
409
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequest'));
479
410
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequestNoBasePath'));
411
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterLint'));
412
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterTests'));
413
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterInventory'));
480
414
  done();
481
415
  } catch (error) {
482
416
  log.error(`Test Failure: ${error}`);
@@ -597,6 +531,39 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
597
531
  done(error);
598
532
  }
599
533
  });
534
+ it('pronghorn.json verify input/output schema objects', (done) => {
535
+ const verifySchema = (methodName, schema) => {
536
+ try {
537
+ ajv.compile(schema);
538
+ } catch (error) {
539
+ const errorMessage = `Invalid schema found in '${methodName}' method.
540
+ Schema => ${JSON.stringify(schema)}.
541
+ Details => ${error.message}`;
542
+ throw new Error(errorMessage);
543
+ }
544
+ };
545
+
546
+ try {
547
+ const pronghornDotJson = require('../../pronghorn.json');
548
+ const { methods } = pronghornDotJson;
549
+ for (let i = 0; i < methods.length; i += 1) {
550
+ for (let j = 0; j < methods[i].input.length; j += 1) {
551
+ const inputSchema = methods[i].input[j].schema;
552
+ if (inputSchema) {
553
+ verifySchema(methods[i].name, inputSchema);
554
+ }
555
+ }
556
+ const outputSchema = methods[i].output.schema;
557
+ if (outputSchema) {
558
+ verifySchema(methods[i].name, outputSchema);
559
+ }
560
+ }
561
+ done();
562
+ } catch (error) {
563
+ log.error(`Adapter Exception: ${error}`);
564
+ done(error);
565
+ }
566
+ });
600
567
  });
601
568
 
602
569
  describe('propertiesSchema.json', () => {
@@ -632,6 +599,7 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
632
599
  assert.equal('string', propertiesDotJson.properties.host.type);
633
600
  assert.equal('integer', propertiesDotJson.properties.port.type);
634
601
  assert.equal('boolean', propertiesDotJson.properties.stub.type);
602
+ assert.equal('string', propertiesDotJson.properties.protocol.type);
635
603
  assert.notEqual(undefined, propertiesDotJson.definitions.authentication);
636
604
  assert.notEqual(null, propertiesDotJson.definitions.authentication);
637
605
  assert.notEqual('', propertiesDotJson.definitions.authentication);
@@ -665,7 +633,6 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
665
633
  assert.equal('boolean', propertiesDotJson.properties.encode_pathvars.type);
666
634
  assert.equal('boolean', propertiesDotJson.properties.encode_queryvars.type);
667
635
  assert.equal(true, Array.isArray(propertiesDotJson.properties.save_metric.type));
668
- assert.equal('string', propertiesDotJson.properties.protocol.type);
669
636
  assert.notEqual(undefined, propertiesDotJson.definitions);
670
637
  assert.notEqual(null, propertiesDotJson.definitions);
671
638
  assert.notEqual('', propertiesDotJson.definitions);
@@ -822,6 +789,7 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
822
789
  assert.notEqual(undefined, sampleDotJson.properties.host);
823
790
  assert.notEqual(undefined, sampleDotJson.properties.port);
824
791
  assert.notEqual(undefined, sampleDotJson.properties.stub);
792
+ assert.notEqual(undefined, sampleDotJson.properties.protocol);
825
793
  assert.notEqual(undefined, sampleDotJson.properties.authentication);
826
794
  assert.notEqual(null, sampleDotJson.properties.authentication);
827
795
  assert.notEqual('', sampleDotJson.properties.authentication);
@@ -849,17 +817,12 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
849
817
  assert.notEqual(undefined, sampleDotJson.properties.ssl.cert_file);
850
818
  assert.notEqual(undefined, sampleDotJson.properties.ssl.secure_protocol);
851
819
  assert.notEqual(undefined, sampleDotJson.properties.ssl.ciphers);
852
-
853
820
  assert.notEqual(undefined, sampleDotJson.properties.base_path);
854
821
  assert.notEqual(undefined, sampleDotJson.properties.version);
855
822
  assert.notEqual(undefined, sampleDotJson.properties.cache_location);
856
823
  assert.notEqual(undefined, sampleDotJson.properties.encode_pathvars);
824
+ assert.notEqual(undefined, sampleDotJson.properties.encode_queryvars);
857
825
  assert.notEqual(undefined, sampleDotJson.properties.save_metric);
858
- assert.notEqual(undefined, sampleDotJson.properties.protocol);
859
- assert.notEqual(undefined, sampleDotJson.properties.stub);
860
- assert.notEqual(undefined, sampleDotJson.properties.stub);
861
- assert.notEqual(undefined, sampleDotJson.properties.stub);
862
- assert.notEqual(undefined, sampleDotJson.properties.stub);
863
826
  assert.notEqual(undefined, sampleDotJson.properties.healthcheck);
864
827
  assert.notEqual(null, sampleDotJson.properties.healthcheck);
865
828
  assert.notEqual('', sampleDotJson.properties.healthcheck);
@@ -918,6 +881,14 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
918
881
  assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.ca_file);
919
882
  assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.key_file);
920
883
  assert.notEqual(undefined, sampleDotJson.properties.mongo.db_ssl.cert_file);
884
+ assert.notEqual(undefined, sampleDotJson.properties.devicebroker);
885
+ assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getDevice);
886
+ assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getDevicesFiltered);
887
+ assert.notEqual(undefined, sampleDotJson.properties.devicebroker.isAlive);
888
+ assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getConfig);
889
+ assert.notEqual(undefined, sampleDotJson.properties.devicebroker.getCount);
890
+ assert.notEqual(undefined, sampleDotJson.properties.cache);
891
+ assert.notEqual(undefined, sampleDotJson.properties.cache.entities);
921
892
  done();
922
893
  } catch (error) {
923
894
  log.error(`Test Failure: ${error}`);
@@ -1023,40 +994,6 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1023
994
  });
1024
995
  });
1025
996
 
1026
- describe('#iapFindAdapterPath', () => {
1027
- it('should have a iapFindAdapterPath function', (done) => {
1028
- try {
1029
- assert.equal(true, typeof a.iapFindAdapterPath === 'function');
1030
- done();
1031
- } catch (error) {
1032
- log.error(`Test Failure: ${error}`);
1033
- done(error);
1034
- }
1035
- });
1036
- it('iapFindAdapterPath should find atleast one path that matches', (done) => {
1037
- try {
1038
- a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
1039
- try {
1040
- assert.equal(undefined, error);
1041
- assert.notEqual(undefined, data);
1042
- assert.notEqual(null, data);
1043
- assert.equal(true, data.found);
1044
- assert.notEqual(undefined, data.foundIn);
1045
- assert.notEqual(null, data.foundIn);
1046
- assert.notEqual(0, data.foundIn.length);
1047
- done();
1048
- } catch (err) {
1049
- log.error(`Test Failure: ${err}`);
1050
- done(err);
1051
- }
1052
- });
1053
- } catch (error) {
1054
- log.error(`Adapter Exception: ${error}`);
1055
- done(error);
1056
- }
1057
- }).timeout(attemptTimeout);
1058
- });
1059
-
1060
997
  describe('#iapSuspendAdapter', () => {
1061
998
  it('should have a iapSuspendAdapter function', (done) => {
1062
999
  try {
@@ -1093,6 +1030,40 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1093
1030
  });
1094
1031
  });
1095
1032
 
1033
+ describe('#iapFindAdapterPath', () => {
1034
+ it('should have a iapFindAdapterPath function', (done) => {
1035
+ try {
1036
+ assert.equal(true, typeof a.iapFindAdapterPath === 'function');
1037
+ done();
1038
+ } catch (error) {
1039
+ log.error(`Test Failure: ${error}`);
1040
+ done(error);
1041
+ }
1042
+ });
1043
+ it('iapFindAdapterPath should find atleast one path that matches', (done) => {
1044
+ try {
1045
+ a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
1046
+ try {
1047
+ assert.equal(undefined, error);
1048
+ assert.notEqual(undefined, data);
1049
+ assert.notEqual(null, data);
1050
+ assert.equal(true, data.found);
1051
+ assert.notEqual(undefined, data.foundIn);
1052
+ assert.notEqual(null, data.foundIn);
1053
+ assert.notEqual(0, data.foundIn.length);
1054
+ done();
1055
+ } catch (err) {
1056
+ log.error(`Test Failure: ${err}`);
1057
+ done(err);
1058
+ }
1059
+ });
1060
+ } catch (error) {
1061
+ log.error(`Adapter Exception: ${error}`);
1062
+ done(error);
1063
+ }
1064
+ }).timeout(attemptTimeout);
1065
+ });
1066
+
1096
1067
  describe('#iapTroubleshootAdapter', () => {
1097
1068
  it('should have a iapTroubleshootAdapter function', (done) => {
1098
1069
  try {
@@ -1238,49 +1209,53 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1238
1209
  }).timeout(attemptTimeout);
1239
1210
  });
1240
1211
 
1241
- // describe('#iapHasAdapterEntity', () => {
1242
- // it('should have a iapHasAdapterEntity function', (done) => {
1243
- // try {
1244
- // assert.equal(true, typeof a.iapHasAdapterEntity === 'function');
1245
- // done();
1246
- // } catch (error) {
1247
- // log.error(`Test Failure: ${error}`);
1248
- // done(error);
1249
- // }
1250
- // });
1251
- // it('should find entity', (done) => {
1252
- // try {
1253
- // a.iapHasAdapterEntity('template_entity', // 'a9e9c33dc61122760072455df62663d2', (data) => {
1254
- // try {
1255
- // assert.equal(true, data[0]);
1256
- // done();
1257
- // } catch (err) {
1258
- // log.error(`Test Failure: ${err}`);
1259
- // done(err);
1260
- // }
1261
- // });
1262
- // } catch (error) {
1263
- // log.error(`Adapter Exception: ${error}`);
1264
- // done(error);
1265
- // }
1266
- // }).timeout(attemptTimeout);
1267
- // it('should not find entity', (done) => {
1268
- // try {
1269
- // a.iapHasAdapterEntity('template_entity', 'blah', (data) => {
1270
- // try {
1271
- // assert.equal(false, data[0]);
1272
- // done();
1273
- // } catch (err) {
1274
- // log.error(`Test Failure: ${err}`);
1275
- // done(err);
1276
- // }
1277
- // });
1278
- // } catch (error) {
1279
- // log.error(`Adapter Exception: ${error}`);
1280
- // done(error);
1281
- // }
1282
- // }).timeout(attemptTimeout);
1283
- // });
1212
+ describe('#iapDeactivateTasks', () => {
1213
+ it('should have a iapDeactivateTasks function', (done) => {
1214
+ try {
1215
+ assert.equal(true, typeof a.iapDeactivateTasks === 'function');
1216
+ done();
1217
+ } catch (error) {
1218
+ log.error(`Test Failure: ${error}`);
1219
+ done(error);
1220
+ }
1221
+ });
1222
+ });
1223
+
1224
+ describe('#iapActivateTasks', () => {
1225
+ it('should have a iapActivateTasks function', (done) => {
1226
+ try {
1227
+ assert.equal(true, typeof a.iapActivateTasks === 'function');
1228
+ done();
1229
+ } catch (error) {
1230
+ log.error(`Test Failure: ${error}`);
1231
+ done(error);
1232
+ }
1233
+ });
1234
+ });
1235
+
1236
+ describe('#iapPopulateEntityCache', () => {
1237
+ it('should have a iapPopulateEntityCache function', (done) => {
1238
+ try {
1239
+ assert.equal(true, typeof a.iapPopulateEntityCache === 'function');
1240
+ done();
1241
+ } catch (error) {
1242
+ log.error(`Test Failure: ${error}`);
1243
+ done(error);
1244
+ }
1245
+ });
1246
+ });
1247
+
1248
+ describe('#iapRetrieveEntitiesCache', () => {
1249
+ it('should have a iapRetrieveEntitiesCache function', (done) => {
1250
+ try {
1251
+ assert.equal(true, typeof a.iapRetrieveEntitiesCache === 'function');
1252
+ done();
1253
+ } catch (error) {
1254
+ log.error(`Test Failure: ${error}`);
1255
+ done(error);
1256
+ }
1257
+ });
1258
+ });
1284
1259
 
1285
1260
  describe('#hasEntities', () => {
1286
1261
  it('should have a hasEntities function', (done) => {
@@ -1354,6 +1329,173 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1354
1329
  });
1355
1330
  });
1356
1331
 
1332
+ describe('#iapExpandedGenericAdapterRequest', () => {
1333
+ it('should have a iapExpandedGenericAdapterRequest function', (done) => {
1334
+ try {
1335
+ assert.equal(true, typeof a.iapExpandedGenericAdapterRequest === 'function');
1336
+ done();
1337
+ } catch (error) {
1338
+ log.error(`Test Failure: ${error}`);
1339
+ done(error);
1340
+ }
1341
+ });
1342
+ });
1343
+
1344
+ describe('#genericAdapterRequest', () => {
1345
+ it('should have a genericAdapterRequest function', (done) => {
1346
+ try {
1347
+ assert.equal(true, typeof a.genericAdapterRequest === 'function');
1348
+ done();
1349
+ } catch (error) {
1350
+ log.error(`Test Failure: ${error}`);
1351
+ done(error);
1352
+ }
1353
+ });
1354
+ });
1355
+
1356
+ describe('#genericAdapterRequestNoBasePath', () => {
1357
+ it('should have a genericAdapterRequestNoBasePath function', (done) => {
1358
+ try {
1359
+ assert.equal(true, typeof a.genericAdapterRequestNoBasePath === 'function');
1360
+ done();
1361
+ } catch (error) {
1362
+ log.error(`Test Failure: ${error}`);
1363
+ done(error);
1364
+ }
1365
+ });
1366
+ });
1367
+
1368
+ describe('#iapRunAdapterLint', () => {
1369
+ it('should have a iapRunAdapterLint function', (done) => {
1370
+ try {
1371
+ assert.equal(true, typeof a.iapRunAdapterLint === 'function');
1372
+ done();
1373
+ } catch (error) {
1374
+ log.error(`Test Failure: ${error}`);
1375
+ done(error);
1376
+ }
1377
+ });
1378
+ it('retrieve the lint results', (done) => {
1379
+ try {
1380
+ a.iapRunAdapterLint((data, error) => {
1381
+ try {
1382
+ assert.equal(undefined, error);
1383
+ assert.notEqual(undefined, data);
1384
+ assert.notEqual(null, data);
1385
+ assert.notEqual(undefined, data.status);
1386
+ assert.notEqual(null, data.status);
1387
+ assert.equal('SUCCESS', data.status);
1388
+ done();
1389
+ } catch (err) {
1390
+ log.error(`Test Failure: ${err}`);
1391
+ done(err);
1392
+ }
1393
+ });
1394
+ } catch (error) {
1395
+ log.error(`Adapter Exception: ${error}`);
1396
+ done(error);
1397
+ }
1398
+ }).timeout(attemptTimeout);
1399
+ });
1400
+
1401
+ describe('#iapRunAdapterTests', () => {
1402
+ it('should have a iapRunAdapterTests function', (done) => {
1403
+ try {
1404
+ assert.equal(true, typeof a.iapRunAdapterTests === 'function');
1405
+ done();
1406
+ } catch (error) {
1407
+ log.error(`Test Failure: ${error}`);
1408
+ done(error);
1409
+ }
1410
+ });
1411
+ });
1412
+
1413
+ describe('#iapGetAdapterInventory', () => {
1414
+ it('should have a iapGetAdapterInventory function', (done) => {
1415
+ try {
1416
+ assert.equal(true, typeof a.iapGetAdapterInventory === 'function');
1417
+ done();
1418
+ } catch (error) {
1419
+ log.error(`Test Failure: ${error}`);
1420
+ done(error);
1421
+ }
1422
+ });
1423
+ it('retrieve the inventory', (done) => {
1424
+ try {
1425
+ a.iapGetAdapterInventory((data, error) => {
1426
+ try {
1427
+ assert.equal(undefined, error);
1428
+ assert.notEqual(undefined, data);
1429
+ assert.notEqual(null, data);
1430
+ done();
1431
+ } catch (err) {
1432
+ log.error(`Test Failure: ${err}`);
1433
+ done(err);
1434
+ }
1435
+ });
1436
+ } catch (error) {
1437
+ log.error(`Adapter Exception: ${error}`);
1438
+ done(error);
1439
+ }
1440
+ }).timeout(attemptTimeout);
1441
+ });
1442
+ describe('metadata.json', () => {
1443
+ it('should have a metadata.json', (done) => {
1444
+ try {
1445
+ fs.exists('metadata.json', (val) => {
1446
+ assert.equal(true, val);
1447
+ done();
1448
+ });
1449
+ } catch (error) {
1450
+ log.error(`Test Failure: ${error}`);
1451
+ done(error);
1452
+ }
1453
+ });
1454
+ it('metadata.json is customized', (done) => {
1455
+ try {
1456
+ const metadataDotJson = require('../../metadata.json');
1457
+ assert.equal('adapter-nokia_altiplano', metadataDotJson.name);
1458
+ assert.notEqual(undefined, metadataDotJson.webName);
1459
+ assert.notEqual(null, metadataDotJson.webName);
1460
+ assert.notEqual('', metadataDotJson.webName);
1461
+ assert.equal('Adapter', metadataDotJson.type);
1462
+ done();
1463
+ } catch (error) {
1464
+ log.error(`Test Failure: ${error}`);
1465
+ done(error);
1466
+ }
1467
+ });
1468
+ it('metadata.json contains accurate documentation', (done) => {
1469
+ try {
1470
+ const metadataDotJson = require('../../metadata.json');
1471
+ assert.notEqual(undefined, metadataDotJson.documentation);
1472
+ assert.equal('https://www.npmjs.com/package/@itentialopensource/adapter-nokia_altiplano', metadataDotJson.documentation.npmLink);
1473
+ assert.equal('https://docs.itential.com/opensource/docs/troubleshooting-an-adapter', metadataDotJson.documentation.faqLink);
1474
+ assert.equal('https://gitlab.com/itentialopensource/adapters/contributing-guide', metadataDotJson.documentation.contributeLink);
1475
+ assert.equal('https://itential.atlassian.net/servicedesk/customer/portals', metadataDotJson.documentation.issueLink);
1476
+ done();
1477
+ } catch (error) {
1478
+ log.error(`Test Failure: ${error}`);
1479
+ done(error);
1480
+ }
1481
+ });
1482
+ it('metadata.json has related items', (done) => {
1483
+ try {
1484
+ const metadataDotJson = require('../../metadata.json');
1485
+ assert.notEqual(undefined, metadataDotJson.relatedItems);
1486
+ assert.notEqual(undefined, metadataDotJson.relatedItems.adapters);
1487
+ assert.notEqual(undefined, metadataDotJson.relatedItems.integrations);
1488
+ assert.notEqual(undefined, metadataDotJson.relatedItems.ecosystemApplications);
1489
+ assert.notEqual(undefined, metadataDotJson.relatedItems.workflowProjects);
1490
+ assert.notEqual(undefined, metadataDotJson.relatedItems.transformationProjects);
1491
+ assert.notEqual(undefined, metadataDotJson.relatedItems.exampleProjects);
1492
+ done();
1493
+ } catch (error) {
1494
+ log.error(`Test Failure: ${error}`);
1495
+ done(error);
1496
+ }
1497
+ });
1498
+ });
1357
1499
  /*
1358
1500
  -----------------------------------------------------------------------
1359
1501
  -----------------------------------------------------------------------