From fb688aee59d16d79dcf0fe933ee15db4a3703f56 Mon Sep 17 00:00:00 2001 From: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:44:54 +0100 Subject: [PATCH 1/6] Update GetJobs.ts encoding.trim() only works if encoding is interpreted as a string, but it might just be a number. Signed-off-by: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> --- packages/zosjobs/src/GetJobs.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 4e7c510f12..438571b410 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -375,7 +375,10 @@ export class GetJobs { ImperativeExpect.toNotBeNullOrUndefined(spoolId, "Required parameter spoolId must be defined"); let parameters: string = "/" + encodeURIComponent(jobname) + "/" + encodeURIComponent(jobid) + JobsConstants.RESOURCE_SPOOL_FILES + "/" + encodeURIComponent(spoolId) + JobsConstants.RESOURCE_SPOOL_CONTENT; - if (encoding && encoding.trim() != "") {parameters += "?fileEncoding=" + encoding;} + if (encoding) { + encoding = String(encoding); + if(encoding.trim() != "") {parameters += "?fileEncoding=" + encoding;} + } Logger.getAppLogger().info("GetJobs.getSpoolContentById() parameters: " + parameters); return ZosmfRestClient.getExpectString(session, JobsConstants.RESOURCE + parameters, [Headers.TEXT_PLAIN_UTF8]); } From 954816b1059ea49199086c5ecbfacfae11cc230e Mon Sep 17 00:00:00 2001 From: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:29:20 +0100 Subject: [PATCH 2/6] Combining ifs More succinct Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> --- packages/zosjobs/src/GetJobs.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 438571b410..5e70cf0051 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -375,9 +375,9 @@ export class GetJobs { ImperativeExpect.toNotBeNullOrUndefined(spoolId, "Required parameter spoolId must be defined"); let parameters: string = "/" + encodeURIComponent(jobname) + "/" + encodeURIComponent(jobid) + JobsConstants.RESOURCE_SPOOL_FILES + "/" + encodeURIComponent(spoolId) + JobsConstants.RESOURCE_SPOOL_CONTENT; - if (encoding) { - encoding = String(encoding); - if(encoding.trim() != "") {parameters += "?fileEncoding=" + encoding;} + if (encoding != null && String(encoding).trim !== "") { + parameters += "?fileEncoding=" + encoding; + } } Logger.getAppLogger().info("GetJobs.getSpoolContentById() parameters: " + parameters); return ZosmfRestClient.getExpectString(session, JobsConstants.RESOURCE + parameters, [Headers.TEXT_PLAIN_UTF8]); From f3ecd41fffd86225ed6f252a2c7fe7b029b20d66 Mon Sep 17 00:00:00 2001 From: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:52:30 +0100 Subject: [PATCH 3/6] Changelog 8.7.2 Co-authored-by: Timothy Johnson Signed-off-by: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> --- packages/zosjobs/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/zosjobs/CHANGELOG.md b/packages/zosjobs/CHANGELOG.md index 46c4209895..91b76979f3 100644 --- a/packages/zosjobs/CHANGELOG.md +++ b/packages/zosjobs/CHANGELOG.md @@ -2,11 +2,16 @@ All notable changes to the Zowe z/OS jobs SDK package will be documented in this file. +## `8.7.2` + +- BugFix: Check if encoding is set and not empty now works for numeric-only value in encoding. [#2392] (https://github.com/zowe/zowe-cli/pull/2392). + ## `8.7.1` - BugFix: Fixed an error where the Delete Jobs API response was not returned if the `modifyVersion` parameter was not specified, even though it was available. [#2352](https://github.com/zowe/zowe-cli/pull/2352) ## `8.7.0` + - Enhancement: Added waitForOutput & waitForActive as optional parameters to download on zosjobs. [#2326] (https://github.com/zowe/zowe-cli/pull/2326). ## `8.5.0` From 074182ae0e2803ab8d3f221a23a5c10b2215b223 Mon Sep 17 00:00:00 2001 From: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:48:32 +0100 Subject: [PATCH 4/6] Update packages/zosjobs/CHANGELOG.md "Recent Changes" Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> --- packages/zosjobs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zosjobs/CHANGELOG.md b/packages/zosjobs/CHANGELOG.md index 91b76979f3..1811b49980 100644 --- a/packages/zosjobs/CHANGELOG.md +++ b/packages/zosjobs/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe z/OS jobs SDK package will be documented in this file. -## `8.7.2` +## Recent Changes - BugFix: Check if encoding is set and not empty now works for numeric-only value in encoding. [#2392] (https://github.com/zowe/zowe-cli/pull/2392). From 691a726c7b8c63623cd445c43a97621f198b5fdf Mon Sep 17 00:00:00 2001 From: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:50:01 +0100 Subject: [PATCH 5/6] Update packages/zosjobs/src/GetJobs.ts Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> --- packages/zosjobs/src/GetJobs.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 5e70cf0051..27e6b91dba 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -375,10 +375,9 @@ export class GetJobs { ImperativeExpect.toNotBeNullOrUndefined(spoolId, "Required parameter spoolId must be defined"); let parameters: string = "/" + encodeURIComponent(jobname) + "/" + encodeURIComponent(jobid) + JobsConstants.RESOURCE_SPOOL_FILES + "/" + encodeURIComponent(spoolId) + JobsConstants.RESOURCE_SPOOL_CONTENT; - if (encoding != null && String(encoding).trim !== "") { + if (encoding != null && String(encoding).trim() !== "") { parameters += "?fileEncoding=" + encoding; } - } Logger.getAppLogger().info("GetJobs.getSpoolContentById() parameters: " + parameters); return ZosmfRestClient.getExpectString(session, JobsConstants.RESOURCE + parameters, [Headers.TEXT_PLAIN_UTF8]); } From 05614f2d817087e9c7507176d6909eedc1b5a397 Mon Sep 17 00:00:00 2001 From: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:47:35 +0100 Subject: [PATCH 6/6] Add unit test Co-authored-by: Timothy Johnson Signed-off-by: COBOL-Erik <32245335+COBOL-Erik@users.noreply.github.com> --- packages/zosjobs/CHANGELOG.md | 2 +- packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/zosjobs/CHANGELOG.md b/packages/zosjobs/CHANGELOG.md index 1811b49980..4d7f222701 100644 --- a/packages/zosjobs/CHANGELOG.md +++ b/packages/zosjobs/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe z/OS jobs SDK package will be documented in this ## Recent Changes -- BugFix: Check if encoding is set and not empty now works for numeric-only value in encoding. [#2392] (https://github.com/zowe/zowe-cli/pull/2392). +- BugFix: Check if encoding is set and not empty now works for numeric-only value in encoding (GetJobs.ts). [#2392] (https://github.com/zowe/zowe-cli/pull/2392). ## `8.7.1` diff --git a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts index 3f66dc74d7..be18bf4878 100644 --- a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts @@ -521,6 +521,13 @@ describe("GetJobs tests", () => { expect(content).toEqual(GetJobsData.SAMPLE_JES_MSG_LG); }); + it("should return spool content from getSpoolContentById with encoding as a number if z/OSMF response is mocked", async () => { + (ZosmfRestClient.getExpectString as any) = mockGetJobsStringData(GetJobsData.SAMPLE_JES_MSG_LG); + const content = await GetJobs.getSpoolContentById(pretendSession, "MYJOB1", "JOB0123", 1, 278 as any); + expect((ZosmfRestClient.getExpectString as any).mock.calls[0][1]).toContain("fileEncoding=278"); + expect(content).toEqual(GetJobsData.SAMPLE_JES_MSG_LG); + }); + it("should error if spoolID is omitted from getSpoolContentById", async () => { let err: Error; try {