-
Notifications
You must be signed in to change notification settings - Fork 18
Added new test cases #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DanaSunal
merged 18 commits into
openBackhaul:develop
from
at00825957:AmanTyagi/issue648
Sep 8, 2023
Merged
Added new test cases #813
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d23ee44
adding new test cases
at00825957 b9b0f38
update test cases
at00825957 e7b2ed1
change test case
at00825957 f1f9740
Merge branch 'develop' into AmanTyagi/issue648
at00825957 368496b
Merge branch 'develop' into AmanTyagi/issue648
at00825957 7087637
add negative test cases
at00825957 b025fcb
Merge branch 'develop' into AmanTyagi/issue648
at00825957 a302cbb
resolve comments
at00825957 0f2ca61
Merge branch 'develop' into AmanTyagi/issue648
DanaSunal ed8f3d9
Merge branch 'develop' into AmanTyagi/issue648
at00825957 4c5319e
Merge branch 'develop' into AmanTyagi/issue648
at00825957 3e988cb
resolve comments
at00825957 86260bd
Resolvs comments
at00825957 156c5bb
resolve test case issue
at00825957 870c6de
resolve lint error
at00825957 d813734
merge
at00825957 6dd79c9
resolve comments
at00825957 a95e4bc
Remove redundant test
at00825957 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
271 changes: 271 additions & 0 deletions
271
...attern/applicationPattern/onfModel/services/ForwardingConstructAutomationServices.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,271 @@ | ||
| const ForwardingConstructAutomationServices = require('./ForwardingConstructAutomationServices'); | ||
| const OperationServerInterface = require('../models/layerProtocols/OperationServerInterface'); | ||
| const ForwardingDomain = require('../models/ForwardingDomain'); | ||
| const Event = require('../../rest/client/eventDispatcher'); | ||
| const LogicalTerminationPoint = require('../models/LogicalTerminationPoint'); | ||
| const HttpClientInterface = require('../models/layerProtocols/HttpClientInterface'); | ||
|
|
||
|
|
||
| jest.mock('../../rest/client/eventDispatcher'); | ||
|
|
||
| const fc = { | ||
| "uuid": "ro-2-0-1-op-fc-bm-001", | ||
| "name": [ | ||
| { | ||
| "value-name": "ForwardingKind", | ||
| "value": "core-model-1-4:FORWARDING_KIND_TYPE_INVARIANT_PROCESS_SNIPPET" | ||
| }, | ||
| { | ||
| "value-name": "ForwardingName", | ||
| "value": "PromptForEmbeddingCausesRequestForBequeathingData" | ||
| } | ||
| ], | ||
| "fc-port": [ | ||
| { | ||
| "local-id": "100", | ||
| "port-direction": "core-model-1-4:PORT_DIRECTION_TYPE_INPUT", | ||
| "logical-termination-point": "ro-2-0-1-op-s-bm-001" | ||
| }, | ||
| { | ||
| "local-id": "200", | ||
| "port-direction": "core-model-1-4:PORT_DIRECTION_TYPE_OUTPUT", | ||
| "logical-termination-point": "ro-2-0-1-op-c-bm-or-1-0-0-000" | ||
| } | ||
| ] | ||
| }; | ||
|
|
||
| const fcForProcessSnippet = { | ||
| "uuid": "ro-2-0-1-op-fc-is-000", | ||
| "name": [ | ||
| { | ||
| "value-name": "ForwardingKind", | ||
| "value": "core-model-1-4:FORWARDING_KIND_TYPE_PROCESS_SNIPPET" | ||
| }, | ||
| { | ||
| "value-name": "ForwardingName", | ||
| "value": "TypeApprovalCausesRequestForEmbedding" | ||
| } | ||
| ], | ||
| "fc-port": [ | ||
| { | ||
| "local-id": "000", | ||
| "port-direction": "core-model-1-4:PORT_DIRECTION_TYPE_MANAGEMENT", | ||
| "logical-termination-point": "ro-2-0-1-op-s-is-001" | ||
| }, | ||
| { | ||
| "local-id": "001", | ||
| "port-direction": "core-model-1-4:PORT_DIRECTION_TYPE_MANAGEMENT", | ||
| "logical-termination-point": "ro-2-0-1-op-s-is-002" | ||
| }, | ||
| { | ||
| "local-id": "100", | ||
| "port-direction": "core-model-1-4:PORT_DIRECTION_TYPE_INPUT", | ||
| "logical-termination-point": "ro-2-0-1-op-s-is-003" | ||
| }, | ||
| { | ||
| "local-id": "201", | ||
| "port-direction": "core-model-1-4:PORT_DIRECTION_TYPE_OUTPUT", | ||
| "logical-termination-point": "ro-2-0-1-op-c-im-tar-1-0-0-000" | ||
| } | ||
| ] | ||
| }; | ||
|
|
||
| const forwardingAutomationInputList = [ | ||
| { | ||
| forwardingName: 'PromptForEmbeddingCausesRequestForBequeathingData', | ||
| attributeList: { | ||
| 'new-application-name': 'RegistryOffice', | ||
| 'new-application-release': '2.0.1', | ||
| 'new-application-protocol': 'HTTP', | ||
| 'new-application-address': { 'ipv-4-address': '1.1.3.8' }, | ||
| 'new-application-port': 3008 | ||
| }, | ||
| context: undefined | ||
| }, | ||
| { | ||
| forwardingName: 'ServiceRequestCausesLtpUpdateRequest', | ||
| attributeList: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AttributeList has 0 information, the parameter is passed from automateForwardingConstruct to eventDispatcher without any alternation, it can safely be an empty array. |
||
| uuid: 'ro-2-0-1-tcp-c-or-1-0-0-000', | ||
| 'ltp-direction': 'core-model-1-4:TERMINATION_DIRECTION_SINK', | ||
| 'client-ltp': [ | ||
| 'ro-2-0-1-http-c-or-1-0-0-000' | ||
| ], | ||
| 'server-ltp': [], | ||
| 'layer-protocol': [ | ||
| { | ||
| 'local-id': '0', | ||
| 'layer-protocol-name': 'tcp-client-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_TCP_LAYER', | ||
| 'tcp-client-interface-1-0:tcp-client-interface-pac': { | ||
| 'tcp-client-interface-configuration': { | ||
| 'remote-protocol': 'tcp-client-interface-1-0:PROTOCOL_TYPE_HTTP', | ||
| 'remote-address': { | ||
| 'ip-address': { | ||
| 'ipv-4-address': '1.1.3.1' | ||
| } | ||
| }, | ||
| 'remote-port': 3001 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| context: 'TypeApprovalRegister2.0.1' | ||
| } | ||
|
|
||
| ]; | ||
|
|
||
| describe("automateForwardingConstructAsync", () => { | ||
| test("automateForwardingConstructAsync - success when FC is Process Snippet", async () => { | ||
| const operationServerName = '/v1/embed-yourself'; | ||
| const httpRequestBody = { | ||
| "client-ltp": [ | ||
| "ro-2-0-1-http-c-or-1-0-0-000" | ||
| ], | ||
| "layer-protocol": [ | ||
| { | ||
| "layer-protocol-name": "tcp-client-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_TCP_LAYER", | ||
| "local-id": "0", | ||
| "tcp-client-interface-1-0:tcp-client-interface-pac": { | ||
| "tcp-client-interface-configuration": { | ||
| "remote-address": { | ||
| "ip-address": { | ||
| "ipv-4-address": "1.1.3.1" | ||
| } | ||
| }, | ||
| "remote-port": 3001, | ||
| "remote-protocol": "tcp-client-interface-1-0:PROTOCOL_TYPE_HTTP" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "ltp-direction": "core-model-1-4:TERMINATION_DIRECTION_SINK", | ||
| "server-ltp": [], | ||
| "uuid": "ro-2-0-1-tcp-c-or-1-0-0-000" | ||
| }; | ||
| const xCorrelator = "550e8400-e29b-11d4-a716-446655440000"; | ||
| jest.spyOn(OperationServerInterface, 'getOperationServerUuidAsync').mockImplementation(() => 'ro-2-0-1-op-s-is-003'); | ||
| jest.spyOn(ForwardingDomain, 'getForwardingConstructForTheForwardingNameAsync').mockImplementation(() => fcForProcessSnippet); | ||
| jest.spyOn(LogicalTerminationPoint, 'getServerLtpListAsync').mockReturnValue(["ro-2-0-1-http-c-tar-1-0-0-000"]); | ||
| jest.spyOn(HttpClientInterface, 'getApplicationNameAsync').mockReturnValue('TypeApprovalRegister'); | ||
| jest.spyOn(HttpClientInterface, 'getReleaseNumberAsync').mockReturnValue('2.0.1'); | ||
| jest.spyOn(Event, 'dispatchEvent').mockReturnValue(true); | ||
|
|
||
| await ForwardingConstructAutomationServices.automateForwardingConstructAsync( | ||
| operationServerName, forwardingAutomationInputList, 'User Name', | ||
| '550e8400-e29b-11d4-a716-446655440000', '1.3.1', 'Unknown value'); | ||
|
|
||
| expect(Event.dispatchEvent).toHaveBeenCalledTimes(1); | ||
| expect(Event.dispatchEvent).toHaveBeenCalledWith( | ||
| "ro-2-0-1-op-c-im-tar-1-0-0-000", | ||
| expect.objectContaining(httpRequestBody), | ||
| "User Name", | ||
| xCorrelator, | ||
| "1.3.1.1", | ||
| "Unknown value" | ||
| ); | ||
| }); | ||
|
|
||
| test("automateForwardingConstructAsync - success when FC is Process Subscription", async () => { | ||
| const operationServerName = '/v1/embed-yourself'; | ||
| const httpRequestBody = { | ||
| "client-ltp": [ | ||
| "ro-2-0-1-http-c-or-1-0-0-000" | ||
| ], | ||
| "layer-protocol": [ | ||
| { | ||
| "layer-protocol-name": "tcp-client-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_TCP_LAYER", | ||
| "local-id": "0", | ||
| "tcp-client-interface-1-0:tcp-client-interface-pac": { | ||
| "tcp-client-interface-configuration": { | ||
| "remote-address": { | ||
| "ip-address": { | ||
| "ipv-4-address": "1.1.3.1" | ||
| } | ||
| }, | ||
| "remote-port": 3001, | ||
| "remote-protocol": "tcp-client-interface-1-0:PROTOCOL_TYPE_HTTP" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "ltp-direction": "core-model-1-4:TERMINATION_DIRECTION_SINK", | ||
| "server-ltp": [], | ||
| "uuid": "ro-2-0-1-tcp-c-or-1-0-0-000" | ||
| }; | ||
| const xCorrelator = "550e8400-e29b-11d4-a716-446655440000"; | ||
|
|
||
| jest.spyOn(OperationServerInterface, 'getOperationServerUuidAsync').mockImplementation(() => 'ro-2-0-1-op-s-bm-001'); | ||
| jest.spyOn(ForwardingDomain, 'getForwardingConstructForTheForwardingNameAsync').mockImplementation(() => fc); | ||
| jest.spyOn(Event, 'dispatchEvent').mockImplementation(() => true); | ||
|
|
||
| await ForwardingConstructAutomationServices.automateForwardingConstructAsync( | ||
| operationServerName, forwardingAutomationInputList, 'User Name', | ||
| '550e8400-e29b-11d4-a716-446655440000', '1.3.1', 'Unknown value'); | ||
| expect(Event.dispatchEvent).toHaveBeenCalledTimes(2); | ||
| expect(Event.dispatchEvent).toHaveBeenCalledWith( | ||
| "ro-2-0-1-op-c-bm-or-1-0-0-000", | ||
| expect.objectContaining(httpRequestBody), | ||
| "User Name", | ||
| xCorrelator, | ||
| "1.3.1.2", | ||
| "Unknown value" | ||
| ); | ||
| }); | ||
|
|
||
| }) | ||
|
|
||
| describe("automateForwardingConstructWithoutInputAsync", () => { | ||
| test("automateForwardingConstructWithoutInputAsync - successful when FC is Process Snippet", async () => { | ||
| const httpRequestBody = { | ||
| "client-ltp": [ | ||
| "ro-2-0-1-http-c-or-1-0-0-000" | ||
| ], | ||
| "layer-protocol": [ | ||
| { | ||
| "layer-protocol-name": "tcp-client-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_TCP_LAYER", | ||
| "local-id": "0", | ||
| "tcp-client-interface-1-0:tcp-client-interface-pac": { | ||
| "tcp-client-interface-configuration": { | ||
| "remote-address": { | ||
| "ip-address": { | ||
| "ipv-4-address": "1.1.3.1" | ||
| } | ||
| }, | ||
| "remote-port": 3001, | ||
| "remote-protocol": "tcp-client-interface-1-0:PROTOCOL_TYPE_HTTP" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "ltp-direction": "core-model-1-4:TERMINATION_DIRECTION_SINK", | ||
| "server-ltp": [], | ||
| "uuid": "ro-2-0-1-tcp-c-or-1-0-0-000" | ||
| }; | ||
| const xCorrelator = "550e8400-e29b-11d4-a716-446655440000"; | ||
|
|
||
| jest.spyOn(ForwardingDomain, 'getForwardingConstructForTheForwardingNameAsync').mockImplementation(() => fcForProcessSnippet); | ||
| jest.spyOn(LogicalTerminationPoint, 'getServerLtpListAsync').mockReturnValue(["ro-2-0-1-http-c-tar-1-0-0-000"]) | ||
| jest.spyOn(HttpClientInterface, 'getApplicationNameAsync').mockReturnValue('TypeApprovalRegister') | ||
| jest.spyOn(HttpClientInterface, 'getReleaseNumberAsync').mockReturnValue('2.0.1'); | ||
| jest.spyOn(Event, 'dispatchEvent').mockImplementation(() => true); | ||
|
|
||
| await ForwardingConstructAutomationServices.automateForwardingConstructWithoutInputAsync( | ||
| forwardingAutomationInputList, 'User Name', '550e8400-e29b-11d4-a716-446655440000', | ||
| '1.3.1', 'Unknown value'); | ||
|
|
||
| expect(Event.dispatchEvent).toHaveBeenCalledTimes(1); | ||
| expect(Event.dispatchEvent).toHaveBeenCalledWith( | ||
| "ro-2-0-1-op-c-im-tar-1-0-0-000", | ||
| expect.objectContaining(httpRequestBody), | ||
| "User Name", | ||
| xCorrelator, | ||
| "1.3.1.1", | ||
| "Unknown value" | ||
| ); | ||
| }); | ||
|
|
||
| }) | ||
|
|
||
| afterEach(() => { | ||
| jest.resetAllMocks(); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.