Skip to content

Commit

Permalink
Merge pull request #2280 from zowe/addressSpaceApps
Browse files Browse the repository at this point in the history
[v3] TSO app message transmission/reception
  • Loading branch information
zFernand0 authored Oct 29, 2024
2 parents 4b7a194 + 06c65a4 commit c8b5bc8
Show file tree
Hide file tree
Showing 48 changed files with 2,550 additions and 188 deletions.
4 changes: 3 additions & 1 deletion __tests__/__packages__/cli-test-utils/src/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ export function mockHandlerParameters(params: PartialHandlerParameters): IHandle
},
progress: {
startBar: jest.fn((parms) => undefined),
endBar: jest.fn(() => undefined)
endBar: jest.fn(() => undefined),
startSpinner: jest.fn(() => undefined),
endSpinner: jest.fn(() => undefined)
},
format: {
output: jest.fn((parms) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ exports[`zos-tso should display the help 1`] = `
GROUPS
------
issue Issue TSO commands
ping Ping a TSO address space
send Send data to TSO
start | st Start TSO/E address space
stop | sp Stop TSO/E address space
issue Issue TSO commands
ping Ping a TSO address space
receive | r Receive message from TSO address space app
send Send data to TSO
start | st Start TSO/E address space
stop | sp Stop TSO/E address space
GLOBAL OPTIONS
--------------
Expand All @@ -46,8 +47,8 @@ exports[`zos-tso should display the help 1`] = `
\\"success\\": true,
\\"exitCode\\": 0,
\\"message\\": \\"The help was constructed for command: zos-tso.\\",
\\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso <group>\\\\n\\\\n Where <group> is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n send Send data to TSO \\\\n start | st Start TSO/E address space\\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\",
\\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso <group>\\\\n\\\\n Where <group> is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receive | r Receive message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\",
\\"stderr\\": \\"\\",
\\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso <group>\\\\n\\\\n Where <group> is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n send Send data to TSO \\\\n start | st Start TSO/E address space\\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\"
\\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso <group>\\\\n\\\\n Where <group> is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receive | r Receive message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\"
}"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("zos-tso", () => {
expect(response.stdout.toString()).toBe("");
expect(response.stderr.toString()).toContain('Unknown arguments: not-valid-option, notValidOption');
expect(response.stderr.toString()).toContain('Command failed due to improper syntax');
expect(response.stderr.toString()).toContain('Did you mean: zos-tso start');
expect(response.stderr.toString()).toContain('Did you mean: zos-tso send app');
expect(response.stderr.toString()).toContain('Command entered: "zos-tso --not-valid-option"');
expect(response.stderr.toString()).toContain('Use "zowe zos-tso --help" to view groups, commands, and options.');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ exports[`zos-tso send should display the help 1`] = `
COMMANDS
--------
address-space | as Send data to a TSO address space
address-space | as Send data to a TSO address space
app | a Send message to an application at a TSO address space
GLOBAL OPTIONS
--------------
Expand All @@ -42,8 +43,8 @@ exports[`zos-tso send should display the help 1`] = `
\\"success\\": true,
\\"exitCode\\": 0,
\\"message\\": \\"The help was constructed for command: send.\\",
\\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\",
\\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space \\\\n app | a Send message to an application at a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\",
\\"stderr\\": \\"\\",
\\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\"
\\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space \\\\n app | a Send message to an application at a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\"
}"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ exports[`zos-tso start should display the help 1`] = `
COMMANDS
--------
address-space | as Start a TSO address space
address-space | as Start a TSO address space
app | a Start application at TSO address space
GLOBAL OPTIONS
--------------
Expand All @@ -42,8 +43,8 @@ exports[`zos-tso start should display the help 1`] = `
\\"success\\": true,
\\"exitCode\\": 0,
\\"message\\": \\"The help was constructed for command: start.\\",
\\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\",
\\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space \\\\n app | a Start application at TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\",
\\"stderr\\": \\"\\",
\\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\"
\\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start <command>\\\\n\\\\n Where <command> is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space \\\\n app | a Start application at TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n\\"
}"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("zos-tso start", () => {
expect(response.stderr.toString()).toContain('Command failed due to improper syntax');
expect(response.stderr.toString()).toContain('Did you mean: zos-tso start');
expect(response.stderr.toString()).toContain('Command entered: "zos-tso start foobar"');
expect(response.stderr.toString()).toContain('Available commands are "address-space".');
expect(response.stderr.toString()).toContain('Available commands are "address-space, app".');
expect(response.stderr.toString()).toContain('Use "zowe zos-tso start --help" to view groups, commands, and options.');
expect(response.stderr.toString()).toContain('Error: Unknown argument: foobar');
});
Expand All @@ -53,7 +53,7 @@ describe("zos-tso start", () => {
expect(response.stderr.toString()).toContain('Unknown arguments: foo-bar, fooBar');
expect(response.stderr.toString()).toContain('Command failed due to improper syntax');
expect(response.stderr.toString()).toContain('Command entered: "zos-tso start --foo-bar"');
expect(response.stderr.toString()).toContain('Available commands are "address-space".');
expect(response.stderr.toString()).toContain('Available commands are "address-space, app".');
expect(response.stderr.toString()).toContain('Use "zowe zos-tso start --help" to view groups, commands, and options.');
expect(response.stderr.toString()).toContain('Error: Unknown arguments: foo-bar, fooBar');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ICommandDefinition } from "@zowe/imperative";

describe("zos-tso group definition", () => {
it("should not have changed", () => {
const CHILDREN = 5;
const CHILDREN = 6;
const definition: ICommandDefinition = require("../../../src/zostso/ZosTso.definition");
expect(definition).toBeDefined();
expect(definition.children.length).toBe(CHILDREN);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

import { ICommandDefinition } from "@zowe/imperative";

describe("zos-tso receive group definition", () => {
it("should not have changed", () => {
const definition: ICommandDefinition = require("../../../../src/zostso/receive/Receive.definition").ReceiveCommand;
expect(definition).toBeDefined();
expect(definition.children.length).toBe(1);
delete definition.children;
expect(definition).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`zos-tso receive group definition should not have changed 1`] = `
Object {
"aliases": Array [
"r",
],
"description": "Receive message from TSO address space app",
"name": "receive",
"summary": "Receive message from TSO address space app",
"type": "group",
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk";
import { AddressSpaceApps } from "@zowe/zos-tso-for-zowe-sdk";
import * as ReceiveASAppHandler from "../../../../../src/zostso/receive/app/ReceiveASApp.handler";
import * as ReceiveASAppDefinition from "../../../../../src/zostso/receive/app/ReceiveASApp.definition";
import { IHandlerParameters } from "@zowe/imperative";
import { mockHandlerParameters } from "@zowe/cli-test-utils";
import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants";

const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({
arguments: UNIT_TEST_ZOSMF_PROF_OPTS,
positionals: ["zos-tso","r","app"],
definition: ReceiveASAppDefinition.ReceiveASApp
});
const MOCK_RECEIVE_RESPONSE: any = {
version: undefined,
reused: false,
timeout: false,
servletKey: "ZOWEUSER-122-aabyaaaj",
queueID: null,
tsoData: [
{
"TSO MESSAGE": { VERSION: "0100", DATA: "Processing started." },
},
{
"TSO MESSAGE": { VERSION: "0100", DATA: "READY" },
},
],
};

describe("receive TSO app handler behavior", () => {
beforeEach(() => {
jest.clearAllMocks();
});

it("should properly receive and parse data from receive TSO response", async () => {
jest.spyOn(ZosmfRestClient, "getExpectJSON").mockResolvedValueOnce(
MOCK_RECEIVE_RESPONSE
);
const receiveSpy = jest.spyOn(AddressSpaceApps,"receive");
const handler = new ReceiveASAppHandler.default();
const params = Object.assign({}, ...[DEFAULT_PARAMETERS]);
let error = undefined;
params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "ZOWEUSER-122-aabyaaaj", runUntilReady: true};
try{
await handler.process(params);
}
catch(e)
{
error = e;
}
expect(error).toBeUndefined();
expect(receiveSpy).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 1`] = `
"
"
`;

exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 2`] = `"Processing started."`;

exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 3`] = `"READY"`;

exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 4`] = `
Object {
"queueID": null,
"reused": false,
"servletKey": "ZOWEUSER-122-aabyaaaj",
"timeout": false,
"tsoData": Array [
Object {
"DATA": "Processing started.",
"VERSION": "0100",
},
Object {
"DATA": "READY",
"VERSION": "0100",
},
],
"version": undefined,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("zos-tso send group definition", () => {
it("should not have changed", () => {
const definition: ICommandDefinition = require("../../../../src/zostso/send/Send.definition").SendCommand;
expect(definition).toBeDefined();
expect(definition.children.length).toBe(1);
expect(definition.children.length).toBe(2);
delete definition.children;
expect(definition).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit c8b5bc8

Please sign in to comment.