Skip to content

Commit

Permalink
Merge pull request #993 from openBackhaul/PrathibaJee/issue992
Browse files Browse the repository at this point in the history
PrathibaJee/issue992 Updated JEST unit testcases
  • Loading branch information
IswaryaaS authored Jul 31, 2024
2 parents eaec808 + ebd0a1e commit c0c19f5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ const ForwardingConstruct = require('../models/ForwardingConstruct');
const TcpClientInterface = require('../models/layerProtocols/TcpClientInterface');
const OperationClientInterface = require("../models/layerProtocols/OperationClientInterface");
const HttpClientInterface = require("../models/layerProtocols/HttpClientInterface");
const fileOperation = require('../../databaseDriver/JSONDriver');

jest.mock('../models/ControlConstruct');
jest.mock('../models/LogicalTerminationPoint');
jest.mock('../models/ForwardingDomain');
jest.mock('../models/ForwardingConstruct');
jest.mock('../../databaseDriver/JSONDriver');

const fc = {
"uuid": "ol-2-0-1-op-fc-bm-010",
Expand Down Expand Up @@ -130,6 +132,7 @@ const individualServicesOperationsMapping =
beforeEach(() => {
jest.spyOn(ControlConstruct, 'getUuidAsync').mockReturnValue('ol-2-0-1');
jest.spyOn(ControlConstruct, 'addLogicalTerminationPointAsync').mockReturnValue(true);
jest.spyOn(fileOperation, 'writeToDatabaseAsync').mockImplementation(() => true);
});

describe("createOrUpdateApplicationLtpsAsync", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let httpRequestHeader = {
"customer-journey": "unknown",
"operation-key": "Not yet defined.",
"originator": "RegistryOffice",
"trace-indicator": 1,
"trace-indicator": "1",
"user": "dana"
};

Expand All @@ -57,7 +57,8 @@ test("isAuthorized -- response true", async () => {
"ol-2-0-1-op-c-bm-alt-1-0-0-005",
"POST",
expect.objectContaining(httpRequestHeader),
expect.objectContaining(httpRequestBody)
expect.objectContaining(httpRequestBody),
undefined
);
expect(res).toStrictEqual({"isAuthorized": true});
});
Expand Down Expand Up @@ -87,7 +88,8 @@ test("isAuthorized -- authorization error", async () => {
"ol-2-0-1-op-c-bm-alt-1-0-0-005",
"POST",
expect.objectContaining(httpRequestHeader),
expect.objectContaining(httpRequestBody)
expect.objectContaining(httpRequestBody),
undefined
);
expect(res).toStrictEqual({"isAuthorized": false});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let httpRequestHeader = {
"customer-journey": "unknown",
"operation-key": "Not yet defined.",
"originator": "RegistryOffice",
"trace-indicator": 1,
"trace-indicator": "1",
"user": "dana"
};

Expand Down Expand Up @@ -61,7 +61,7 @@ test("recordServiceRequest -- response true, detailedLogging false", async () =>
"ol-2-0-1-op-c-bm-alt-1-0-0-005",
"POST",
expect.objectContaining(httpRequestHeader),
httpRequestBody
expect.objectContaining(httpRequestBody)
);
expect(res).toBeTruthy();
});
Expand Down Expand Up @@ -119,7 +119,7 @@ test("recordServiceRequestFromClient -- response true, detailedLogging false", a
"ol-2-0-1-op-c-bm-alt-1-0-0-005",
"POST",
expect.objectContaining(httpRequestHeader),
httpRequestBody
expect.objectContaining(httpRequestBody)
);
expect(res).toBeTruthy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const HttpServerInterface = require('../onfModel/models/layerProtocols/HttpServe
const RequestBuilder = require('../rest/client/RequestBuilder');
const ForwardingDomain = require('../onfModel/models/ForwardingDomain');


jest.mock('../onfModel/models/ForwardingDomain');
jest.mock('../onfModel/models/layerProtocols/OperationClientInterface');
jest.mock('../onfModel/models/layerProtocols/HttpServerInterface');
Expand Down Expand Up @@ -42,8 +43,9 @@ test("recordOamRequest -- response true", async () => {
"customer-journey": "unknown",
"operation-key": "Not yet defined.",
"originator": "RegistryOffice",
"trace-indicator": 1,
"user": "dana"
"trace-indicator": "1",
"user": "dana",
"x-correlator": expect.any(String)
};
let httpRequestBody = {
"application-name": "RegistryOffice",
Expand All @@ -52,11 +54,12 @@ test("recordOamRequest -- response true", async () => {
"resource": "{ testbody: foo }",
"response-code": "200",
"stringified-body": "{}",
"user-name": "dana",
"timestamp": expect.any(String),
"user-name": "dana"
};
expect(RequestBuilder.BuildAndTriggerRestRequest).toHaveBeenCalledWith(
"ol-2-0-1-op-c-bm-alt-1-0-0-005",
"POST",
"POST",
expect.objectContaining(httpRequestHeader),
expect.objectContaining(httpRequestBody)
);
Expand Down
4 changes: 2 additions & 2 deletions server/applicationPattern/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/applicationPattern/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onf-core-model-ap",
"version": "2.1.1-beta.1",
"version": "2.1.1",
"description": "onf core model application pattern",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions server/basicServices/basicServices/BasicServicesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,17 @@ exports.embedYourself = async function (body, user, xCorrelator, traceIndicator,
let oldReleaseAddress = body["old-release-address"];
let oldReleaseProtocol = body["old-release-protocol"];
let oldReleasePort = body["old-release-port"];
if (JSON.stringify(oldReleaseAddress) != JSON.stringify(existingpreceedingApplicationAddress)) {
if (oldReleaseAddress!=undefined && JSON.stringify(oldReleaseAddress) != JSON.stringify(existingpreceedingApplicationAddress)) {
isORAddressUpdated = await tcpClientInterface.setRemoteAddressAsync(
preceedingApplicationClientUuidStack.tcpClientUuid,
oldReleaseAddress);
}
if (oldReleasePort != existingpreceedingApplicationPort) {
if (oldReleasePort!=undefined && oldReleasePort != existingpreceedingApplicationPort) {
isORPortUpdated = await tcpClientInterface.setRemotePortAsync(
preceedingApplicationClientUuidStack.tcpClientUuid,
oldReleasePort);
}
if (oldReleaseProtocol != existingpreceedingApplicationProtocol) {
if (oldReleaseProtocol!=undefined && oldReleaseProtocol != existingpreceedingApplicationProtocol) {
isORProtocolUpdated = await tcpClientInterface.setRemoteProtocolAsync(
preceedingApplicationClientUuidStack.tcpClientUuid,
oldReleaseProtocol);
Expand Down Expand Up @@ -1404,7 +1404,7 @@ async function processInvariantSubscription(subscribingApplicationName, subscrib
let forwardingAutomationInputList = await prepareForwardingAutomation.updateLtpToALT(
ltpConfigurationList
);
ForwardingAutomationService.automateForwardingConstructAsync(
await ForwardingAutomationService.automateForwardingConstructAsync(
operationServerName,
forwardingAutomationInputList,
user,
Expand Down
4 changes: 2 additions & 2 deletions server/basicServices/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onf-core-model-ap-bs",
"version": "2.1.1-beta.1",
"version": "2.1.1",
"description": "onf core model application pattern",
"main": "index.js",
"scripts": {
Expand All @@ -14,7 +14,7 @@
"js-yaml": "^3.3.0",
"moment": "^2.29.1",
"node-statsd": "^0.1.1",
"onf-core-model-ap": "2.1.1-beta.1",
"onf-core-model-ap": "2.1.1",
"openbackhaul-oas3-tools": "2.3.1-alpha.3",
"randexp": "^0.5.3",
"response-time": "^2.3.2"
Expand Down

0 comments on commit c0c19f5

Please sign in to comment.