Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const operationClientInterface = require('../models/layerProtocols/OperationClie
const LogicalTerminationPointConfigurationStatus = require('./models/logicalTerminationPoint/ConfigurationStatus');
const ConfigurationStatus = require('./models/ConfigurationStatus');
const TcpClientInterface = require('../models/layerProtocols/TcpClientInterface');

const ForwardingConstruct = require('../models/ForwardingConstruct');
const ForwardingDomain = require('../models/ForwardingDomain');
const FcPort = require('../models/FcPort');
const onfAttributes = require('../constants/OnfAttributes');

/**
* @description This function find a application in the same or different release and updates the http,
Expand Down Expand Up @@ -179,78 +182,74 @@ exports.findOrCreateApplicationInformationAsync = function (logicalTerminationPo

/**
* @description This function deletes the tcp,http,operation client for the provided application and release number.
* @param {String} applicationName name of the client application<br>
* @param {String} releaseNumber release of the client application<br>
* @returns {Promise} OperationClientLists associated to the application
* @param {String} applicationName name of the client application
* @param {String} releaseNumber release of the client application
* @returns {Promise<LogicalTerminationPointConfigurationStatus>} status of deletions
**/
exports.deleteApplicationInformationAsync = function (applicationName, releaseNumber, newReleaseForwardingName) {
return new Promise(async function (resolve, reject) {

let logicalTerminationPointConfigurationStatus;
let httpClientConfigurationStatus;
let tcpClientConfigurationStatusList = [];
let operationClientConfigurationStatusList = [];
try {
let httpClientUuid;
let tcpClientUuid;
exports.deleteApplicationInformationAsync = async function (applicationName, releaseNumber, newReleaseForwardingName) {
let httpClientConfigurationStatus;
let tcpClientConfigurationStatusList = [];
let operationClientConfigurationStatusList = [];

let httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease(
applicationName,
releaseNumber,
newReleaseForwardingName
);
if (httpClientUuid === undefined) {
console.log(`Could not find Http Client UUID with ${applicationName}, ${releaseNumber} and ${newReleaseForwardingName}`);
return new LogicalTerminationPointConfigurationStatus(
operationClientConfigurationStatusList,
httpClientConfigurationStatus,
tcpClientConfigurationStatusList
);
}
// remove tcp clients
let serverLtpList = await logicalTerminationPoint.getServerLtpListAsync(httpClientUuid);
for (let tcpClientUuid of serverLtpList) {
let isDeleted = await controlConstruct.deleteLogicalTerminationPointAsync(tcpClientUuid);
let tcpClientConfigurationStatus = new ConfigurationStatus(
tcpClientUuid,
'',
isDeleted);
tcpClientConfigurationStatusList.push(tcpClientConfigurationStatus);
}
// remove operations
let clientLtpList = await logicalTerminationPoint.getClientLtpListAsync(httpClientUuid);
for (let operationClientUuid of clientLtpList) {
let isDeleted = await deleteOperationClientLTPAsync(operationClientUuid);
let operationClientConfigurationStatus = new ConfigurationStatus(
operationClientUuid,
'',
isDeleted);
operationClientConfigurationStatusList.push(operationClientConfigurationStatus);
}
// remove http client
let isDeleted = await controlConstruct.deleteLogicalTerminationPointAsync(httpClientUuid);
httpClientConfigurationStatus = new ConfigurationStatus(
httpClientUuid,
'',
isDeleted);
return new LogicalTerminationPointConfigurationStatus(
operationClientConfigurationStatusList,
httpClientConfigurationStatus,
tcpClientConfigurationStatusList
);
}

httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease(
applicationName,
releaseNumber,
newReleaseForwardingName
);
if (httpClientUuid !== undefined) {
let serverLtpList = await logicalTerminationPoint.getServerLtpListAsync(
httpClientUuid);
if (serverLtpList != undefined && serverLtpList.length > 0) {
for (let i = 0; i < serverLtpList.length; i++) {
tcpClientUuid = serverLtpList[i];
if (tcpClientUuid) {
let isDeleted = await controlConstruct.deleteLogicalTerminationPointAsync(
tcpClientUuid);
let tcpClientConfigurationStatus = new ConfigurationStatus(
tcpClientUuid,
'',
isDeleted);
tcpClientConfigurationStatusList.push(tcpClientConfigurationStatus);
}
}
}
let clientLtpList = await logicalTerminationPoint.getClientLtpListAsync(
httpClientUuid);
if (clientLtpList != undefined && clientLtpList.length > 0) {
for (let i = 0; i < clientLtpList.length; i++) {
let operationClientuuid = clientLtpList[i];
if (operationClientuuid) {
let isDeleted = await controlConstruct.deleteLogicalTerminationPointAsync(
operationClientuuid);
let operationClientConfigurationStatus = new ConfigurationStatus(
operationClientuuid,
'',
isDeleted);
operationClientConfigurationStatusList.push(
operationClientConfigurationStatus);
}
}
}
let isDeleted = await controlConstruct.deleteLogicalTerminationPointAsync(
httpClientUuid);
httpClientConfigurationStatus = new ConfigurationStatus(
httpClientUuid,
'',
isDeleted);
}
logicalTerminationPointConfigurationStatus = new LogicalTerminationPointConfigurationStatus(
operationClientConfigurationStatusList,
httpClientConfigurationStatus,
tcpClientConfigurationStatusList
);
resolve(logicalTerminationPointConfigurationStatus);
} catch (error) {
reject(error);
async function deleteOperationClientLTPAsync(operationClientUuid) {
let fcList = await ForwardingDomain.getForwardingConstructListForTheFcPortAsync(operationClientUuid, FcPort.portDirectionEnum.OUTPUT);
for (let fc of fcList) {
let fcPorts = fc[onfAttributes.FORWARDING_CONSTRUCT.FC_PORT]
let filteredFcPorts = fcPorts.filter(fc =>
fc[onfAttributes.FC_PORT.LOGICAL_TERMINATION_POINT] === operationClientUuid
);
for (let port of filteredFcPorts) {
await ForwardingConstruct.deleteFcPortAsync(fc[onfAttributes.GLOBAL_CLASS.UUID], port[onfAttributes.LOCAL_CLASS.LOCAL_ID]);
}
});
}
}
return await controlConstruct.deleteLogicalTerminationPointAsync(operationClientUuid);
}

/**
* @description This function creates logical-termination-point for the provided values.
Expand Down Expand Up @@ -1141,4 +1140,4 @@ function findAndUpdateOperationClientInterface(httpClientUuid, operationServerNa
reject(error);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const LtpWithMappingServices = require("./LogicalTerminationPointWithMappingServices");
const HttpClientInterface = require('../models/layerProtocols/HttpClientInterface');
const ControlConstruct = require('../models/ControlConstruct');
const LogicalTerminationPoint = require('../models/LogicalTerminationPoint');
const ConfigurationStatus = require('./models/ConfigurationStatus');
const LogicalTerminationPointConfigurationStatus = require('./models/logicalTerminationPoint/ConfigurationStatus');
const ForwardingDomain = require('../models/ForwardingDomain');
const ForwardingConstruct = require('../models/ForwardingConstruct');

jest.mock('../models/layerProtocols/HttpClientInterface');
jest.mock('../models/ControlConstruct');
jest.mock('../models/LogicalTerminationPoint');
jest.mock('../models/ForwardingDomain');
jest.mock('../models/ForwardingConstruct');

const fc = {
"uuid" : "ol-2-0-1-op-fc-bm-010",
"name" : [],
"fc-port" : [
{
"local-id" : "000",
"port-direction" : "core-model-1-4:PORT_DIRECTION_TYPE_MANAGEMENT",
"logical-termination-point" : "ol-2-0-1-op-s-bm-009"
},
{
"local-id" : "100",
"port-direction" : "core-model-1-4:PORT_DIRECTION_TYPE_INPUT",
"logical-termination-point" : "ol-2-0-1-op-s-bm-004"
},
{
"local-id" : "200",
"port-direction" : "core-model-1-4:PORT_DIRECTION_TYPE_OUTPUT",
"logical-termination-point" : "ol-2-0-1-op-c-im-cc-1-0-0-004"
},
{
"local-id" : "201",
"port-direction" : "core-model-1-4:PORT_DIRECTION_TYPE_OUTPUT",
"logical-termination-point" : "nl-2-0-1-op-c-bm-alt-1-0-0-006"
}
]
};

beforeEach(() => {

});

test("deleteApplicationInformationAsync", async () => {
jest.spyOn(LogicalTerminationPoint, 'getServerLtpListAsync').mockReturnValue(["ol-2-0-1-tcp-c-cc-1-0-0-000"]);
jest.spyOn(LogicalTerminationPoint, 'getClientLtpListAsync').mockReturnValue(
["ol-2-0-1-op-c-im-cc-1-0-0-004", "ol-2-0-1-op-c-im-cc-1-0-0-005"]
);
jest.spyOn(ControlConstruct, 'deleteLogicalTerminationPointAsync').mockReturnValue(true);
jest.spyOn(HttpClientInterface, 'getHttpClientUuidExcludingOldReleaseAndNewRelease').mockReturnValue("ol-2-0-1-http-c-cc-1-0-0-000");
jest.spyOn(ForwardingDomain, 'getForwardingConstructListForTheFcPortAsync').mockReturnValue([fc]);
let result = await LtpWithMappingServices.deleteApplicationInformationAsync(
"foo", "bar", "baz"
);

let expectedOperationClientConfigurationStatusList = [
new ConfigurationStatus("ol-2-0-1-op-c-im-cc-1-0-0-004", '', true),
new ConfigurationStatus("ol-2-0-1-op-c-im-cc-1-0-0-005", '', true)
];
let expectedHttpClientConfigurationStatus = new ConfigurationStatus("ol-2-0-1-http-c-cc-1-0-0-000", '', true)
let expectedTcpClientConfigurationStatusList = [
new ConfigurationStatus("ol-2-0-1-tcp-c-cc-1-0-0-000", '', true),
];

expect(ForwardingConstruct.deleteFcPortAsync).toHaveBeenCalledWith("ol-2-0-1-op-fc-bm-010", "200");

expect(result).toStrictEqual(new LogicalTerminationPointConfigurationStatus(
expectedOperationClientConfigurationStatusList,
expectedHttpClientConfigurationStatus,
expectedTcpClientConfigurationStatusList
));
});

afterEach(() => {
jest.resetAllMocks();
});