UNPKG

@itentialopensource/adapter-accedian_skylight

Version:

This adapter integrates with system described as: accedianSkylight.

1,334 lines (1,256 loc) 351 kB
/* @copyright Itential, LLC 2019 (pre-modifications) */ // Set globals /* global describe it log pronghornProps */ /* eslint no-unused-vars: warn */ /* eslint no-underscore-dangle: warn */ /* eslint import/no-dynamic-require:warn */ // include required items for testing & logging const assert = require('assert'); const fs = require('fs'); const path = require('path'); const util = require('util'); const mocha = require('mocha'); const winston = require('winston'); const { expect } = require('chai'); const { use } = require('chai'); const td = require('testdouble'); const log = require('../../utils/logger'); const anything = td.matchers.anything(); // stub and attemptTimeout are used throughout the code so set them here const isRapidFail = false; const isSaveMockData = false; // read in the properties from the sampleProperties files let adaptdir = __dirname; if (adaptdir.endsWith('/test/integration')) { adaptdir = adaptdir.substring(0, adaptdir.length - 17); } else if (adaptdir.endsWith('/test/unit')) { adaptdir = adaptdir.substring(0, adaptdir.length - 10); } const samProps = require(`${adaptdir}/sampleProperties.json`).properties; // these variables can be changed to run in integrated mode so easier to set them here // always check these in with bogus data!!! samProps.stub = true; // uncomment if connecting // samProps.host = 'replace.hostorip.here'; // samProps.authentication.username = 'username'; // samProps.authentication.password = 'password'; // samProps.authentication.token = 'password'; // samProps.protocol = 'http'; // samProps.port = 80; // samProps.ssl.enabled = false; // samProps.ssl.accept_invalid_cert = false; if (samProps.request.attempt_timeout < 30000) { samProps.request.attempt_timeout = 30000; } samProps.devicebroker.enabled = true; const attemptTimeout = samProps.request.attempt_timeout; const { stub } = samProps; // these are the adapter properties. You generally should not need to alter // any of these after they are initially set up global.pronghornProps = { pathProps: { encrypted: false }, adapterProps: { adapters: [{ id: 'Test-accedian_skylight', type: 'AccedianSkylight', properties: samProps }] } }; global.$HOME = `${__dirname}/../..`; /** * Runs the common asserts for test */ function runCommonAsserts(data, error) { assert.equal(undefined, error); assert.notEqual(undefined, data); assert.notEqual(null, data); assert.notEqual(undefined, data.response); assert.notEqual(null, data.response); } /** * Runs the error asserts for the test */ function runErrorAsserts(data, error, code, origin, displayStr) { assert.equal(null, data); assert.notEqual(undefined, error); assert.notEqual(null, error); assert.notEqual(undefined, error.IAPerror); assert.notEqual(null, error.IAPerror); assert.notEqual(undefined, error.IAPerror.displayString); assert.notEqual(null, error.IAPerror.displayString); assert.equal(code, error.icode); assert.equal(origin, error.IAPerror.origin); assert.equal(displayStr, error.IAPerror.displayString); } /** * @function saveMockData * Attempts to take data from responses and place them in MockDataFiles to help create Mockdata. * Note, this was built based on entity file structure for Adapter-Engine 1.6.x * @param {string} entityName - Name of the entity saving mock data for * @param {string} actionName - Name of the action saving mock data for * @param {string} descriptor - Something to describe this test (used as a type) * @param {string or object} responseData - The data to put in the mock file. */ function saveMockData(entityName, actionName, descriptor, responseData) { // do not need to save mockdata if we are running in stub mode (already has mock data) or if told not to save if (stub || !isSaveMockData) { return false; } // must have a response in order to store the response if (responseData && responseData.response) { let data = responseData.response; // if there was a raw response that one is better as it is untranslated if (responseData.raw) { data = responseData.raw; try { const temp = JSON.parse(data); data = temp; } catch (pex) { // do not care if it did not parse as we will just use data } } try { const base = path.join(__dirname, `../../entities/${entityName}/`); const mockdatafolder = 'mockdatafiles'; const filename = `mockdatafiles/${actionName}-${descriptor}.json`; if (!fs.existsSync(base + mockdatafolder)) { fs.mkdirSync(base + mockdatafolder); } // write the data we retrieved fs.writeFile(base + filename, JSON.stringify(data, null, 2), 'utf8', (errWritingMock) => { if (errWritingMock) throw errWritingMock; // update the action file to reflect the changes. Note: We're replacing the default object for now! fs.readFile(`${base}action.json`, (errRead, content) => { if (errRead) throw errRead; // parse the action file into JSON const parsedJson = JSON.parse(content); // The object update we'll write in. const responseObj = { type: descriptor, key: '', mockFile: filename }; // get the object for method we're trying to change. const currentMethodAction = parsedJson.actions.find((obj) => obj.name === actionName); // if the method was not found - should never happen but... if (!currentMethodAction) { throw Error('Can\'t find an action for this method in the provided entity.'); } // if there is a response object, we want to replace the Response object. Otherwise we'll create one. const actionResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === descriptor); // Add the action responseObj back into the array of response objects. if (!actionResponseObj) { // if there is a default response object, we want to get the key. const defaultResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === 'default'); // save the default key into the new response object if (defaultResponseObj) { responseObj.key = defaultResponseObj.key; } // save the new response object currentMethodAction.responseObjects = [responseObj]; } else { // update the location of the mock data file actionResponseObj.mockFile = responseObj.mockFile; } // Save results fs.writeFile(`${base}action.json`, JSON.stringify(parsedJson, null, 2), (err) => { if (err) throw err; }); }); }); } catch (e) { log.debug(`Failed to save mock data for ${actionName}. ${e.message}`); return false; } } // no response to save log.debug(`No data passed to save into mockdata for ${actionName}`); return false; } // require the adapter that we are going to be using const AccedianSkylight = require('../../adapter'); // begin the testing - these should be pretty well defined between the describe and the it! describe('[integration] Accedian_skylight Adapter Test', () => { describe('AccedianSkylight Class Tests', () => { const a = new AccedianSkylight( pronghornProps.adapterProps.adapters[0].id, pronghornProps.adapterProps.adapters[0].properties ); if (isRapidFail) { const state = {}; state.passed = true; mocha.afterEach(function x() { state.passed = state.passed && (this.currentTest.state === 'passed'); }); mocha.beforeEach(function x() { if (!state.passed) { return this.currentTest.skip(); } return true; }); } describe('#class instance created', () => { it('should be a class with properties', (done) => { try { assert.notEqual(null, a); assert.notEqual(undefined, a); const checkId = global.pronghornProps.adapterProps.adapters[0].id; assert.equal(checkId, a.id); assert.notEqual(null, a.allProps); const check = global.pronghornProps.adapterProps.adapters[0].properties.healthcheck.type; assert.equal(check, a.healthcheckType); done(); } catch (error) { log.error(`Test Failure: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#connect', () => { it('should get connected - no healthcheck', (done) => { try { a.healthcheckType = 'none'; a.connect(); try { assert.equal(true, a.alive); done(); } catch (error) { log.error(`Test Failure: ${error}`); done(error); } } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }); it('should get connected - startup healthcheck', (done) => { try { a.healthcheckType = 'startup'; a.connect(); try { assert.equal(true, a.alive); done(); } catch (error) { log.error(`Test Failure: ${error}`); done(error); } } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }); }); describe('#healthCheck', () => { it('should be healthy', (done) => { try { a.healthCheck(null, (data) => { try { assert.equal(true, a.healthy); saveMockData('system', 'healthcheck', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); // broker tests describe('#getDevicesFiltered - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { const opts = { filter: { name: 'deviceName' } }; a.getDevicesFiltered(opts, (data, error) => { try { if (stub) { if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') { assert.equal(null, error); assert.notEqual(undefined, data); assert.notEqual(null, data); assert.equal(0, data.total); assert.equal(0, data.list.length); } else { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } } else { runCommonAsserts(data, error); } done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#iapGetDeviceCount - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { const opts = { filter: { name: 'deviceName' } }; a.iapGetDeviceCount((data, error) => { try { if (stub) { if (samProps.devicebroker.getDevicesFiltered[0].handleFailure === 'ignore') { assert.equal(null, error); assert.notEqual(undefined, data); assert.notEqual(null, data); assert.equal(0, data.count); } else { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } } else { runCommonAsserts(data, error); } done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); // exposed cache tests describe('#iapPopulateEntityCache - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.iapPopulateEntityCache('Device', (data, error) => { try { if (stub) { assert.equal(null, data); assert.notEqual(undefined, error); assert.notEqual(null, error); done(); } else { assert.equal(undefined, error); assert.equal('success', data[0]); done(); } } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#iapRetrieveEntitiesCache - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.iapRetrieveEntitiesCache('Device', {}, (data, error) => { try { if (stub) { assert.equal(null, data); assert.notEqual(null, error); assert.notEqual(undefined, error); } else { assert.equal(undefined, error); assert.notEqual(null, data); assert.notEqual(undefined, data); } done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); /* ----------------------------------------------------------------------- ----------------------------------------------------------------------- *** All code above this comment will be replaced during a migration *** ******************* DO NOT REMOVE THIS COMMENT BLOCK ****************** ----------------------------------------------------------------------- ----------------------------------------------------------------------- */ const endpointCreateNewReflectorEndpointBodyParam = {}; describe('#createNewReflectorEndpoint - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createNewReflectorEndpoint(endpointCreateNewReflectorEndpointBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'createNewReflectorEndpoint', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointCreateSupervisonEndpointBodyParam = {}; describe('#createSupervisonEndpoint - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createSupervisonEndpoint(endpointCreateSupervisonEndpointBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'createSupervisonEndpoint', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getEndpoints - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getEndpoints((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'getEndpoints', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointId = 'fakedata'; describe('#getReflectorEndpointByName - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getReflectorEndpointByName(endpointId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'getReflectorEndpointByName', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointChangeIpAddressUnmanagedEndpointBodyParam = {}; describe('#changeIpAddressUnmanagedEndpoint - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.changeIpAddressUnmanagedEndpoint(endpointId, endpointChangeIpAddressUnmanagedEndpointBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'changeIpAddressUnmanagedEndpoint', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointChangeCapabilityUnmanagedEndpointBodyParam = {}; describe('#changeCapabilityUnmanagedEndpoint - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.changeCapabilityUnmanagedEndpoint(endpointId, endpointChangeCapabilityUnmanagedEndpointBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'changeCapabilityUnmanagedEndpoint', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getReflectorEndpointByMAC - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getReflectorEndpointByMAC(endpointId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'getReflectorEndpointByMAC', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointChangeTwampControlProtocolSettingsBodyParam = 'fakedata'; describe('#changeTwampControlProtocolSettings - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.changeTwampControlProtocolSettings(endpointId, endpointChangeTwampControlProtocolSettingsBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'changeTwampControlProtocolSettings', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getSupervisionEndpointByName - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getSupervisionEndpointByName(endpointId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'getSupervisionEndpointByName', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointType = 'fakedata'; describe('#getInformationOnEndpointsByType - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getInformationOnEndpointsByType(endpointType, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'getInformationOnEndpointsByType', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointAlterEndpointDescriptionBodyParam = {}; describe('#alterEndpointDescription - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.alterEndpointDescription(endpointId, endpointAlterEndpointDescriptionBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'alterEndpointDescription', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getEndpointInformation - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getEndpointInformation(endpointId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'getEndpointInformation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointChangeNameOfEndpointBodyParam = {}; describe('#changeNameOfEndpoint - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.changeNameOfEndpoint(endpointId, endpointChangeNameOfEndpointBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'changeNameOfEndpoint', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const endpointOperationOnEndpointBodyParam = {}; describe('#operationOnEndpoint - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.operationOnEndpoint(endpointId, endpointOperationOnEndpointBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'operationOnEndpoint', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionCreateEchoSessionBodyParam = {}; describe('#createEchoSession - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createEchoSession(sessionCreateEchoSessionBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'createEchoSession', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionCreateEthOamSessionBodyParam = {}; describe('#createEthOamSession - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createEthOamSession(sessionCreateEthOamSessionBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'createEthOamSession', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionCreateTWAMPSessionBodyParam = {}; describe('#createTWAMPSession - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createTWAMPSession(sessionCreateTWAMPSessionBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'createTWAMPSession', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getSessionInformation - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getSessionInformation((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'getSessionInformation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionId = 'fakedata'; describe('#getEchoSessionInformation - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getEchoSessionInformation(sessionId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'getEchoSessionInformation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getEthOamSessionInformation - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getEthOamSessionInformation(sessionId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'getEthOamSessionInformation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getTWAMPSessionInformation - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getTWAMPSessionInformation(sessionId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'getTWAMPSessionInformation', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionAlterSessionDescriptionBodyParam = {}; describe('#alterSessionDescription - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.alterSessionDescription(sessionId, sessionAlterSessionDescriptionBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'alterSessionDescription', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getSessionHeadInformationByName - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getSessionHeadInformationByName(sessionId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'getSessionHeadInformationByName', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getSessionLastRR - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getSessionLastRR(sessionId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'getSessionLastRR', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionAlterTerminatedNotResolvedSessionNameBodyParam = {}; describe('#alterTerminatedNotResolvedSessionName - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.alterTerminatedNotResolvedSessionName(sessionId, sessionAlterTerminatedNotResolvedSessionNameBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'alterTerminatedNotResolvedSessionName', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionOperationOnSessionBodyParam = {}; describe('#operationOnSession - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.operationOnSession(sessionId, sessionOperationOnSessionBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'operationOnSession', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const sessionAlterTerminatedNotResolvedSessionStreamBodyParam = {}; describe('#alterTerminatedNotResolvedSessionStream - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.alterTerminatedNotResolvedSessionStream(sessionId, sessionAlterTerminatedNotResolvedSessionStreamBodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'alterTerminatedNotResolvedSessionStream', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const slaCreateSLABodyParam = {}; describe('#createSLA - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.createSLA(slaCreateSLABodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Sla', 'createSLA', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getSLAs - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getSLAs((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Sla', 'getSLAs', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); const slaId = 'fakedata'; const slaPutSessionReferenceToSLABodyParam = {}; describe('#putSessionReferenceToSLA - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.putSessionReferenceToSLA(slaId, slaPutSessionReferenceToSLABodyParam, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Sla', 'putSessionReferenceToSLA', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getSessionReferencesForSLA - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getSessionReferencesForSLA(slaId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Sla', 'getSessionReferencesForSLA', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#getSystemVersion - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.getSystemVersion((data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Version', 'getSystemVersion', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#deleteTwampCp - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.deleteTwampCp(endpointId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'deleteTwampCp', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#deleteEndpoint - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.deleteEndpoint(endpointId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Endpoint', 'deleteEndpoint', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); done(error); } }).timeout(attemptTimeout); }); describe('#deleteSession - errors', () => { it('should work if integrated but since no mockdata should error when run standalone', (done) => { try { a.deleteSession(sessionId, (data, error) => { try { if (stub) { const displayE = 'Error 400 received on request'; runErrorAsserts(data, error, 'AD.500', 'Test-accedian_skylight-connectorRest-handleEndResponse', displayE); } else { runCommonAsserts(data, error); } saveMockData('Session', 'deleteSession', 'default', data); done(); } catch (err) { log.error(`Test Failure: ${err}`); done(err); } }); } catch (error) { log.error(`Adapter Exception: ${error}`); d