@itentialopensource/adapter-nokia_altiplano 0.2.0 → 0.5.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.
@@ -271,10 +271,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
271
271
  });
272
272
 
273
273
  let wffunctions = [];
274
- describe('#getWorkflowFunctions', () => {
274
+ describe('#iapGetAdapterWorkflowFunctions', () => {
275
275
  it('should retrieve workflow functions', (done) => {
276
276
  try {
277
- wffunctions = a.getWorkflowFunctions([]);
277
+ wffunctions = a.iapGetAdapterWorkflowFunctions([]);
278
278
 
279
279
  try {
280
280
  assert.notEqual(0, wffunctions.length);
@@ -465,15 +465,15 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
465
465
  assert.notEqual('', pronghornDotJson.methods);
466
466
  assert.equal(true, Array.isArray(pronghornDotJson.methods));
467
467
  assert.notEqual(0, pronghornDotJson.methods.length);
468
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'updateAdapterConfiguration'));
469
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'findPath'));
470
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'troubleshoot'));
471
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'runHealthcheck'));
472
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'runConnectivity'));
473
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'runBasicGet'));
474
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'suspend'));
475
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'unsuspend'));
476
- assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'getQueue'));
468
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUpdateAdapterConfiguration'));
469
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapFindAdapterPath'));
470
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapTroubleshootAdapter'));
471
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterHealthcheck'));
472
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterConnectivity'));
473
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapRunAdapterBasicGet'));
474
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapSuspendAdapter'));
475
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUnsuspendAdapter'));
476
+ assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterQueue'));
477
477
  assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequest'));
478
478
  done();
479
479
  } catch (error) {
@@ -724,6 +724,12 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
724
724
  assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.ca_file.type);
725
725
  assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.key_file.type);
726
726
  assert.equal('string', propertiesDotJson.definitions.mongo.properties.db_ssl.properties.cert_file.type);
727
+ assert.notEqual('', propertiesDotJson.definitions.devicebroker);
728
+ assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getDevice.type);
729
+ assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getDevicesFiltered.type);
730
+ assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.isAlive.type);
731
+ assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getConfig.type);
732
+ assert.equal('array', propertiesDotJson.definitions.devicebroker.properties.getCount.type);
727
733
  done();
728
734
  } catch (error) {
729
735
  log.error(`Test Failure: ${error}`);
@@ -1002,10 +1008,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1002
1008
  });
1003
1009
  });
1004
1010
 
1005
- describe('#updateAdapterConfiguration', () => {
1006
- it('should have a updateAdapterConfiguration function', (done) => {
1011
+ describe('#iapUpdateAdapterConfiguration', () => {
1012
+ it('should have a iapUpdateAdapterConfiguration function', (done) => {
1007
1013
  try {
1008
- assert.equal(true, typeof a.updateAdapterConfiguration === 'function');
1014
+ assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
1009
1015
  done();
1010
1016
  } catch (error) {
1011
1017
  log.error(`Test Failure: ${error}`);
@@ -1014,19 +1020,19 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1014
1020
  });
1015
1021
  });
1016
1022
 
1017
- describe('#findPath', () => {
1018
- it('should have a findPath function', (done) => {
1023
+ describe('#iapFindAdapterPath', () => {
1024
+ it('should have a iapFindAdapterPath function', (done) => {
1019
1025
  try {
1020
- assert.equal(true, typeof a.findPath === 'function');
1026
+ assert.equal(true, typeof a.iapFindAdapterPath === 'function');
1021
1027
  done();
1022
1028
  } catch (error) {
1023
1029
  log.error(`Test Failure: ${error}`);
1024
1030
  done(error);
1025
1031
  }
1026
1032
  });
1027
- it('findPath should find atleast one path that matches', (done) => {
1033
+ it('iapFindAdapterPath should find atleast one path that matches', (done) => {
1028
1034
  try {
1029
- a.findPath('{base_path}/{version}', (data, error) => {
1035
+ a.iapFindAdapterPath('{base_path}/{version}', (data, error) => {
1030
1036
  try {
1031
1037
  assert.equal(undefined, error);
1032
1038
  assert.notEqual(undefined, data);
@@ -1048,10 +1054,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1048
1054
  }).timeout(attemptTimeout);
1049
1055
  });
1050
1056
 
1051
- describe('#suspend', () => {
1052
- it('should have a suspend function', (done) => {
1057
+ describe('#iapSuspendAdapter', () => {
1058
+ it('should have a iapSuspendAdapter function', (done) => {
1053
1059
  try {
1054
- assert.equal(true, typeof a.suspend === 'function');
1060
+ assert.equal(true, typeof a.iapSuspendAdapter === 'function');
1055
1061
  done();
1056
1062
  } catch (error) {
1057
1063
  log.error(`Test Failure: ${error}`);
@@ -1060,10 +1066,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1060
1066
  });
1061
1067
  });
1062
1068
 
1063
- describe('#unsuspend', () => {
1064
- it('should have a unsuspend function', (done) => {
1069
+ describe('#iapUnsuspendAdapter', () => {
1070
+ it('should have a iapUnsuspendAdapter function', (done) => {
1065
1071
  try {
1066
- assert.equal(true, typeof a.unsuspend === 'function');
1072
+ assert.equal(true, typeof a.iapUnsuspendAdapter === 'function');
1067
1073
  done();
1068
1074
  } catch (error) {
1069
1075
  log.error(`Test Failure: ${error}`);
@@ -1072,10 +1078,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1072
1078
  });
1073
1079
  });
1074
1080
 
1075
- describe('#getQueue', () => {
1076
- it('should have a getQueue function', (done) => {
1081
+ describe('#iapGetAdapterQueue', () => {
1082
+ it('should have a iapGetAdapterQueue function', (done) => {
1077
1083
  try {
1078
- assert.equal(true, typeof a.getQueue === 'function');
1084
+ assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
1079
1085
  done();
1080
1086
  } catch (error) {
1081
1087
  log.error(`Test Failure: ${error}`);
@@ -1084,10 +1090,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1084
1090
  });
1085
1091
  });
1086
1092
 
1087
- describe('#troubleshoot', () => {
1088
- it('should have a troubleshoot function', (done) => {
1093
+ describe('#iapTroubleshootAdapter', () => {
1094
+ it('should have a iapTroubleshootAdapter function', (done) => {
1089
1095
  try {
1090
- assert.equal(true, typeof a.troubleshoot === 'function');
1096
+ assert.equal(true, typeof a.iapTroubleshootAdapter === 'function');
1091
1097
  done();
1092
1098
  } catch (error) {
1093
1099
  log.error(`Test Failure: ${error}`);
@@ -1096,10 +1102,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1096
1102
  });
1097
1103
  });
1098
1104
 
1099
- describe('#runHealthcheck', () => {
1100
- it('should have a runHealthcheck function', (done) => {
1105
+ describe('#iapRunAdapterHealthcheck', () => {
1106
+ it('should have a iapRunAdapterHealthcheck function', (done) => {
1101
1107
  try {
1102
- assert.equal(true, typeof a.runHealthcheck === 'function');
1108
+ assert.equal(true, typeof a.iapRunAdapterHealthcheck === 'function');
1103
1109
  done();
1104
1110
  } catch (error) {
1105
1111
  log.error(`Test Failure: ${error}`);
@@ -1108,10 +1114,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1108
1114
  });
1109
1115
  });
1110
1116
 
1111
- describe('#runConnectivity', () => {
1112
- it('should have a runConnectivity function', (done) => {
1117
+ describe('#iapRunAdapterConnectivity', () => {
1118
+ it('should have a iapRunAdapterConnectivity function', (done) => {
1113
1119
  try {
1114
- assert.equal(true, typeof a.runConnectivity === 'function');
1120
+ assert.equal(true, typeof a.iapRunAdapterConnectivity === 'function');
1115
1121
  done();
1116
1122
  } catch (error) {
1117
1123
  log.error(`Test Failure: ${error}`);
@@ -1120,10 +1126,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1120
1126
  });
1121
1127
  });
1122
1128
 
1123
- describe('#runBasicGet', () => {
1124
- it('should have a runBasicGet function', (done) => {
1129
+ describe('#iapRunAdapterBasicGet', () => {
1130
+ it('should have a iapRunAdapterBasicGet function', (done) => {
1125
1131
  try {
1126
- assert.equal(true, typeof a.runBasicGet === 'function');
1132
+ assert.equal(true, typeof a.iapRunAdapterBasicGet === 'function');
1127
1133
  done();
1128
1134
  } catch (error) {
1129
1135
  log.error(`Test Failure: ${error}`);
@@ -1132,10 +1138,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1132
1138
  });
1133
1139
  });
1134
1140
 
1135
- describe('#moveEntitiesToDB', () => {
1136
- it('should have a moveEntitiesToDB function', (done) => {
1141
+ describe('#iapMoveAdapterEntitiesToDB', () => {
1142
+ it('should have a iapMoveAdapterEntitiesToDB function', (done) => {
1137
1143
  try {
1138
- assert.equal(true, typeof a.moveEntitiesToDB === 'function');
1144
+ assert.equal(true, typeof a.iapMoveAdapterEntitiesToDB === 'function');
1139
1145
  done();
1140
1146
  } catch (error) {
1141
1147
  log.error(`Test Failure: ${error}`);
@@ -1229,10 +1235,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1229
1235
  }).timeout(attemptTimeout);
1230
1236
  });
1231
1237
 
1232
- // describe('#hasEntity', () => {
1233
- // it('should have a hasEntity function', (done) => {
1238
+ // describe('#iapHasAdapterEntity', () => {
1239
+ // it('should have a iapHasAdapterEntity function', (done) => {
1234
1240
  // try {
1235
- // assert.equal(true, typeof a.hasEntity === 'function');
1241
+ // assert.equal(true, typeof a.iapHasAdapterEntity === 'function');
1236
1242
  // done();
1237
1243
  // } catch (error) {
1238
1244
  // log.error(`Test Failure: ${error}`);
@@ -1241,7 +1247,7 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1241
1247
  // });
1242
1248
  // it('should find entity', (done) => {
1243
1249
  // try {
1244
- // a.hasEntity('template_entity', // 'a9e9c33dc61122760072455df62663d2', (data) => {
1250
+ // a.iapHasAdapterEntity('template_entity', // 'a9e9c33dc61122760072455df62663d2', (data) => {
1245
1251
  // try {
1246
1252
  // assert.equal(true, data[0]);
1247
1253
  // done();
@@ -1257,7 +1263,7 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1257
1263
  // }).timeout(attemptTimeout);
1258
1264
  // it('should not find entity', (done) => {
1259
1265
  // try {
1260
- // a.hasEntity('template_entity', 'blah', (data) => {
1266
+ // a.iapHasAdapterEntity('template_entity', 'blah', (data) => {
1261
1267
  // try {
1262
1268
  // assert.equal(false, data[0]);
1263
1269
  // done();
@@ -1345,10 +1351,10 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1345
1351
  });
1346
1352
  });
1347
1353
 
1348
- describe('#getCount', () => {
1349
- it('should have a getCount function', (done) => {
1354
+ describe('#iapGetDeviceCount', () => {
1355
+ it('should have a iapGetDeviceCount function', (done) => {
1350
1356
  try {
1351
- assert.equal(true, typeof a.getCount === 'function');
1357
+ assert.equal(true, typeof a.iapGetDeviceCount === 'function');
1352
1358
  done();
1353
1359
  } catch (error) {
1354
1360
  log.error(`Test Failure: ${error}`);
@@ -1494,6 +1500,35 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1494
1500
  }).timeout(attemptTimeout);
1495
1501
  });
1496
1502
 
1503
+ describe('#createOntWithQuery - errors', () => {
1504
+ it('should have a createOntWithQuery function', (done) => {
1505
+ try {
1506
+ assert.equal(true, typeof a.createOntWithQuery === 'function');
1507
+ done();
1508
+ } catch (error) {
1509
+ log.error(`Test Failure: ${error}`);
1510
+ done(error);
1511
+ }
1512
+ }).timeout(attemptTimeout);
1513
+ it('should error if - missing body', (done) => {
1514
+ try {
1515
+ a.createOntWithQuery(null, null, (data, error) => {
1516
+ try {
1517
+ const displayE = 'body is required';
1518
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-createOntWithQuery', displayE);
1519
+ done();
1520
+ } catch (err) {
1521
+ log.error(`Test Failure: ${err}`);
1522
+ done(err);
1523
+ }
1524
+ });
1525
+ } catch (error) {
1526
+ log.error(`Adapter Exception: ${error}`);
1527
+ done(error);
1528
+ }
1529
+ }).timeout(attemptTimeout);
1530
+ });
1531
+
1497
1532
  describe('#getOnt - errors', () => {
1498
1533
  it('should have a getOnt function', (done) => {
1499
1534
  try {
@@ -1817,5 +1852,356 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
1817
1852
  }
1818
1853
  }).timeout(attemptTimeout);
1819
1854
  });
1855
+
1856
+ describe('#getIbnIntent - errors', () => {
1857
+ it('should have a getIbnIntent function', (done) => {
1858
+ try {
1859
+ assert.equal(true, typeof a.getIbnIntent === 'function');
1860
+ done();
1861
+ } catch (error) {
1862
+ log.error(`Test Failure: ${error}`);
1863
+ done(error);
1864
+ }
1865
+ }).timeout(attemptTimeout);
1866
+ it('should error if - missing intent', (done) => {
1867
+ try {
1868
+ a.getIbnIntent(null, (data, error) => {
1869
+ try {
1870
+ const displayE = 'intent is required';
1871
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getIbnIntent', displayE);
1872
+ done();
1873
+ } catch (err) {
1874
+ log.error(`Test Failure: ${err}`);
1875
+ done(err);
1876
+ }
1877
+ });
1878
+ } catch (error) {
1879
+ log.error(`Adapter Exception: ${error}`);
1880
+ done(error);
1881
+ }
1882
+ }).timeout(attemptTimeout);
1883
+ });
1884
+
1885
+ describe('#modifyIbnIntent - errors', () => {
1886
+ it('should have a modifyIbnIntent function', (done) => {
1887
+ try {
1888
+ assert.equal(true, typeof a.modifyIbnIntent === 'function');
1889
+ done();
1890
+ } catch (error) {
1891
+ log.error(`Test Failure: ${error}`);
1892
+ done(error);
1893
+ }
1894
+ }).timeout(attemptTimeout);
1895
+ it('should error if - missing intent', (done) => {
1896
+ try {
1897
+ a.modifyIbnIntent(null, null, (data, error) => {
1898
+ try {
1899
+ const displayE = 'intent is required';
1900
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-modifyIbnIntent', displayE);
1901
+ done();
1902
+ } catch (err) {
1903
+ log.error(`Test Failure: ${err}`);
1904
+ done(err);
1905
+ }
1906
+ });
1907
+ } catch (error) {
1908
+ log.error(`Adapter Exception: ${error}`);
1909
+ done(error);
1910
+ }
1911
+ }).timeout(attemptTimeout);
1912
+ it('should error if - missing body', (done) => {
1913
+ try {
1914
+ a.modifyIbnIntent('fakeparam', null, (data, error) => {
1915
+ try {
1916
+ const displayE = 'body is required';
1917
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-modifyIbnIntent', displayE);
1918
+ done();
1919
+ } catch (err) {
1920
+ log.error(`Test Failure: ${err}`);
1921
+ done(err);
1922
+ }
1923
+ });
1924
+ } catch (error) {
1925
+ log.error(`Adapter Exception: ${error}`);
1926
+ done(error);
1927
+ }
1928
+ }).timeout(attemptTimeout);
1929
+ });
1930
+
1931
+ describe('#deleteIbnIntent - errors', () => {
1932
+ it('should have a deleteIbnIntent function', (done) => {
1933
+ try {
1934
+ assert.equal(true, typeof a.deleteIbnIntent === 'function');
1935
+ done();
1936
+ } catch (error) {
1937
+ log.error(`Test Failure: ${error}`);
1938
+ done(error);
1939
+ }
1940
+ }).timeout(attemptTimeout);
1941
+ it('should error if - missing intent', (done) => {
1942
+ try {
1943
+ a.deleteIbnIntent(null, (data, error) => {
1944
+ try {
1945
+ const displayE = 'intent is required';
1946
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-deleteIbnIntent', displayE);
1947
+ done();
1948
+ } catch (err) {
1949
+ log.error(`Test Failure: ${err}`);
1950
+ done(err);
1951
+ }
1952
+ });
1953
+ } catch (error) {
1954
+ log.error(`Adapter Exception: ${error}`);
1955
+ done(error);
1956
+ }
1957
+ }).timeout(attemptTimeout);
1958
+ });
1959
+
1960
+ describe('#synchronizeIbnIntent - errors', () => {
1961
+ it('should have a synchronizeIbnIntent function', (done) => {
1962
+ try {
1963
+ assert.equal(true, typeof a.synchronizeIbnIntent === 'function');
1964
+ done();
1965
+ } catch (error) {
1966
+ log.error(`Test Failure: ${error}`);
1967
+ done(error);
1968
+ }
1969
+ }).timeout(attemptTimeout);
1970
+ it('should error if - missing intent', (done) => {
1971
+ try {
1972
+ a.synchronizeIbnIntent(null, (data, error) => {
1973
+ try {
1974
+ const displayE = 'intent is required';
1975
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-synchronizeIbnIntent', displayE);
1976
+ done();
1977
+ } catch (err) {
1978
+ log.error(`Test Failure: ${err}`);
1979
+ done(err);
1980
+ }
1981
+ });
1982
+ } catch (error) {
1983
+ log.error(`Adapter Exception: ${error}`);
1984
+ done(error);
1985
+ }
1986
+ }).timeout(attemptTimeout);
1987
+ });
1988
+
1989
+ describe('#auditIbnIntent - errors', () => {
1990
+ it('should have a auditIbnIntent function', (done) => {
1991
+ try {
1992
+ assert.equal(true, typeof a.auditIbnIntent === 'function');
1993
+ done();
1994
+ } catch (error) {
1995
+ log.error(`Test Failure: ${error}`);
1996
+ done(error);
1997
+ }
1998
+ }).timeout(attemptTimeout);
1999
+ it('should error if - missing intent', (done) => {
2000
+ try {
2001
+ a.auditIbnIntent(null, (data, error) => {
2002
+ try {
2003
+ const displayE = 'intent is required';
2004
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-auditIbnIntent', displayE);
2005
+ done();
2006
+ } catch (err) {
2007
+ log.error(`Test Failure: ${err}`);
2008
+ done(err);
2009
+ }
2010
+ });
2011
+ } catch (error) {
2012
+ log.error(`Adapter Exception: ${error}`);
2013
+ done(error);
2014
+ }
2015
+ }).timeout(attemptTimeout);
2016
+ });
2017
+
2018
+ describe('#getEntityOntView - errors', () => {
2019
+ it('should have a getEntityOntView function', (done) => {
2020
+ try {
2021
+ assert.equal(true, typeof a.getEntityOntView === 'function');
2022
+ done();
2023
+ } catch (error) {
2024
+ log.error(`Test Failure: ${error}`);
2025
+ done(error);
2026
+ }
2027
+ }).timeout(attemptTimeout);
2028
+ it('should error if - missing isamVer', (done) => {
2029
+ try {
2030
+ a.getEntityOntView(null, null, null, null, null, (data, error) => {
2031
+ try {
2032
+ const displayE = 'isamVer is required';
2033
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntView', displayE);
2034
+ done();
2035
+ } catch (err) {
2036
+ log.error(`Test Failure: ${err}`);
2037
+ done(err);
2038
+ }
2039
+ });
2040
+ } catch (error) {
2041
+ log.error(`Adapter Exception: ${error}`);
2042
+ done(error);
2043
+ }
2044
+ }).timeout(attemptTimeout);
2045
+ it('should error if - missing shelfName', (done) => {
2046
+ try {
2047
+ a.getEntityOntView('fakedata', null, null, null, null, (data, error) => {
2048
+ try {
2049
+ const displayE = 'shelfName is required';
2050
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntView', displayE);
2051
+ done();
2052
+ } catch (err) {
2053
+ log.error(`Test Failure: ${err}`);
2054
+ done(err);
2055
+ }
2056
+ });
2057
+ } catch (error) {
2058
+ log.error(`Adapter Exception: ${error}`);
2059
+ done(error);
2060
+ }
2061
+ }).timeout(attemptTimeout);
2062
+ it('should error if - missing demark', (done) => {
2063
+ try {
2064
+ a.getEntityOntView('fakedata', 'fakedata', null, null, null, (data, error) => {
2065
+ try {
2066
+ const displayE = 'demark is required';
2067
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntView', displayE);
2068
+ done();
2069
+ } catch (err) {
2070
+ log.error(`Test Failure: ${err}`);
2071
+ done(err);
2072
+ }
2073
+ });
2074
+ } catch (error) {
2075
+ log.error(`Adapter Exception: ${error}`);
2076
+ done(error);
2077
+ }
2078
+ }).timeout(attemptTimeout);
2079
+ });
2080
+
2081
+ describe('#getEntityOntPort - errors', () => {
2082
+ it('should have a getEntityOntPort function', (done) => {
2083
+ try {
2084
+ assert.equal(true, typeof a.getEntityOntPort === 'function');
2085
+ done();
2086
+ } catch (error) {
2087
+ log.error(`Test Failure: ${error}`);
2088
+ done(error);
2089
+ }
2090
+ }).timeout(attemptTimeout);
2091
+ it('should error if - missing isamVer', (done) => {
2092
+ try {
2093
+ a.getEntityOntPort(null, null, null, null, null, (data, error) => {
2094
+ try {
2095
+ const displayE = 'isamVer is required';
2096
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntPort', displayE);
2097
+ done();
2098
+ } catch (err) {
2099
+ log.error(`Test Failure: ${err}`);
2100
+ done(err);
2101
+ }
2102
+ });
2103
+ } catch (error) {
2104
+ log.error(`Adapter Exception: ${error}`);
2105
+ done(error);
2106
+ }
2107
+ }).timeout(attemptTimeout);
2108
+ it('should error if - missing shelfName', (done) => {
2109
+ try {
2110
+ a.getEntityOntPort('fakedata', null, null, null, null, (data, error) => {
2111
+ try {
2112
+ const displayE = 'shelfName is required';
2113
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntPort', displayE);
2114
+ done();
2115
+ } catch (err) {
2116
+ log.error(`Test Failure: ${err}`);
2117
+ done(err);
2118
+ }
2119
+ });
2120
+ } catch (error) {
2121
+ log.error(`Adapter Exception: ${error}`);
2122
+ done(error);
2123
+ }
2124
+ }).timeout(attemptTimeout);
2125
+ it('should error if - missing demark', (done) => {
2126
+ try {
2127
+ a.getEntityOntPort('fakedata', 'fakedata', null, null, null, (data, error) => {
2128
+ try {
2129
+ const displayE = 'demark is required';
2130
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntPort', displayE);
2131
+ done();
2132
+ } catch (err) {
2133
+ log.error(`Test Failure: ${err}`);
2134
+ done(err);
2135
+ }
2136
+ });
2137
+ } catch (error) {
2138
+ log.error(`Adapter Exception: ${error}`);
2139
+ done(error);
2140
+ }
2141
+ }).timeout(attemptTimeout);
2142
+ });
2143
+
2144
+ describe('#getEntityOntVlanAssociation - errors', () => {
2145
+ it('should have a getEntityOntVlanAssociation function', (done) => {
2146
+ try {
2147
+ assert.equal(true, typeof a.getEntityOntVlanAssociation === 'function');
2148
+ done();
2149
+ } catch (error) {
2150
+ log.error(`Test Failure: ${error}`);
2151
+ done(error);
2152
+ }
2153
+ }).timeout(attemptTimeout);
2154
+ it('should error if - missing isamVer', (done) => {
2155
+ try {
2156
+ a.getEntityOntVlanAssociation(null, null, null, null, null, (data, error) => {
2157
+ try {
2158
+ const displayE = 'isamVer is required';
2159
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntVlanAssociation', displayE);
2160
+ done();
2161
+ } catch (err) {
2162
+ log.error(`Test Failure: ${err}`);
2163
+ done(err);
2164
+ }
2165
+ });
2166
+ } catch (error) {
2167
+ log.error(`Adapter Exception: ${error}`);
2168
+ done(error);
2169
+ }
2170
+ }).timeout(attemptTimeout);
2171
+ it('should error if - missing shelfName', (done) => {
2172
+ try {
2173
+ a.getEntityOntVlanAssociation('fakedata', null, null, null, null, (data, error) => {
2174
+ try {
2175
+ const displayE = 'shelfName is required';
2176
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntVlanAssociation', displayE);
2177
+ done();
2178
+ } catch (err) {
2179
+ log.error(`Test Failure: ${err}`);
2180
+ done(err);
2181
+ }
2182
+ });
2183
+ } catch (error) {
2184
+ log.error(`Adapter Exception: ${error}`);
2185
+ done(error);
2186
+ }
2187
+ }).timeout(attemptTimeout);
2188
+ it('should error if - missing vlanAssociation', (done) => {
2189
+ try {
2190
+ a.getEntityOntVlanAssociation('fakedata', 'fakedata', null, null, null, (data, error) => {
2191
+ try {
2192
+ const displayE = 'vlanAssociation is required';
2193
+ runErrorAsserts(data, error, 'AD.300', 'Test-nokia_altiplano-adapter-getEntityOntVlanAssociation', displayE);
2194
+ done();
2195
+ } catch (err) {
2196
+ log.error(`Test Failure: ${err}`);
2197
+ done(err);
2198
+ }
2199
+ });
2200
+ } catch (error) {
2201
+ log.error(`Adapter Exception: ${error}`);
2202
+ done(error);
2203
+ }
2204
+ }).timeout(attemptTimeout);
2205
+ });
1820
2206
  });
1821
2207
  });
package/utils/tbUtils.js CHANGED
@@ -352,13 +352,7 @@ module.exports = {
352
352
 
353
353
  // get database connection and existing adapter config
354
354
  getAdapterConfig: async function getAdapterConfig() {
355
- const newDirname = this.getDirname();
356
- let iapDir;
357
- if (this.withinIAP(newDirname)) { // when this script is called from IAP
358
- iapDir = newDirname;
359
- } else {
360
- iapDir = path.join(this.getDirname(), 'utils', '../../../../');
361
- }
355
+ const iapDir = this.getIAPHome();
362
356
  const pronghornProps = this.getPronghornProps(iapDir);
363
357
  console.log('Connecting to Database...');
364
358
  const database = await this.connect(iapDir, pronghornProps);
@@ -434,6 +428,25 @@ module.exports = {
434
428
  return stdout.trim();
435
429
  },
436
430
 
431
+ /**
432
+ * @summary Obtain the IAP installation directory depending on how adapter is used:
433
+ * by IAP, or by npm run CLI interface
434
+ * @returns IAP installation directory
435
+ * @function getIAPHome
436
+ */
437
+ getIAPHome: function getIAPHome() {
438
+ // if adapter started via IAP, use path injected by core
439
+ if (process.env.iap_home) return process.env.iap_home;
440
+ // adapter started via CLI `npm run <command>` so we have to be located under
441
+ // <IAP_HOME>/node_modules/@itentialopensource/<adapter>/ directory,
442
+ // use `pwd` command wihout option -P(resolving symlinks) https://linux.die.net/man/1/pwd
443
+ const { stdout } = this.systemSync('pwd', true);
444
+ if (stdout.indexOf('/node_modules') >= 0) {
445
+ return stdout.trim().split('/node_modules')[0];
446
+ }
447
+ return path.join(stdout.trim(), '../../../');
448
+ },
449
+
437
450
  /**
438
451
  * @summary connect to mongodb
439
452
  *