From 459c6d0dabfdb459b940870d346ad9be4b423d06 Mon Sep 17 00:00:00 2001 From: Asif Nawaz Date: Wed, 8 Nov 2023 14:24:50 +0000 Subject: [PATCH] chore(ResponseTest.java): Updated contents of string for CommandPlainSecure test. --- .devcontainer/devcontainer.json | 15 +++++++ .../workflows/auto-merge-dependabot-pr.yml | 14 +++--- .github/workflows/release.yml | 21 ++++++--- .github/workflows/test.yml | 8 +++- pom.xml | 6 ++- .../net/hexonet/apiconnector/Response.java | 45 +++++++++++-------- .../hexonet/apiconnector/ResponseTest.java | 2 +- 7 files changed, 76 insertions(+), 35 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..c39d4cf2 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,15 @@ +// .devcontainer/devcontainer.json +{ + "name": "Java", + "image": "mcr.microsoft.com/devcontainers/java", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + } + }, + "extensions": [ + "vscjava.vscode-java-pack" + ] + } +} \ No newline at end of file diff --git a/.github/workflows/auto-merge-dependabot-pr.yml b/.github/workflows/auto-merge-dependabot-pr.yml index e7938377..020ab5ee 100644 --- a/.github/workflows/auto-merge-dependabot-pr.yml +++ b/.github/workflows/auto-merge-dependabot-pr.yml @@ -5,19 +5,21 @@ on: - opened - synchronize -permissions: - contents: write - pull-requests: write - jobs: tests: uses: ./.github/workflows/test.yml secrets: inherit - + permissions: + contents: read + dependabot: name: Auto-merge Dependabot PR - runs-on: ubuntu-latest + runs-on: ${{ vars.RTLDEV_MW_CI_OS }} needs: tests + permissions: + contents: write + pull-requests: write + if: ${{ github.actor == 'dependabot[bot]' }} steps: - name: Dependabot metadata diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 383059f3..0209efab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,14 +7,21 @@ on: - master jobs: - build: - name: Build + tests: uses: ./.github/workflows/test.yml - + secrets: inherit + permissions: + contents: read + release: - name: Release @ ubuntu-latest - runs-on: ubuntu-latest - needs: build + name: Release @ ${{ vars.RTLDEV_MW_CI_OS }} + runs-on: ${{ vars.RTLDEV_MW_CI_OS }} + needs: tests + permissions: + contents: write + issues: write + deployments: write + steps: - name: Checkout uses: actions/checkout@v4 @@ -44,7 +51,6 @@ jobs: run: npm ci - name: Release env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} MAVEN_OPTS: ${{ vars.MAVEN_OPTS }} OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME }} OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }} @@ -52,6 +58,7 @@ jobs: ENCRYPTED_C9F9AEDF26B7_IV: ${{ secrets.ENCRYPTED_C9F9AEDF26B7_IV }} GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + GITHUB_TOKEN: ${{ secrets.RTLDEV_MW_CI_TOKEN }} RTLDEV_MW_NOTIFICATION_URI: ${{ secrets.RTLDEV_MW_NOTIFICATION_URI }} run: | openssl aes-256-cbc -K $ENCRYPTED_C9F9AEDF26B7_KEY -iv $ENCRYPTED_C9F9AEDF26B7_IV -in codesigning.asc.enc -out codesigning.asc -d diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c7d3f35..4ad841d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,9 @@ jobs: # as the build names above change each time Node versions change lint: name: 🧪 Linting - runs-on: ubuntu-latest + runs-on: ${{ vars.RTLDEV_MW_CI_OS }} + permissions: + contents: read steps: - name: Checkout uses: actions/checkout@v4 @@ -26,7 +28,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} test_matrix: - runs-on: ubuntu-latest + runs-on: ${{ vars.RTLDEV_MW_CI_OS }} + permissions: + contents: read strategy: matrix: diff --git a/pom.xml b/pom.xml index 812db2e7..4fcd35b2 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,6 @@ 3.6.2 true - 8 -html5 @@ -123,6 +122,11 @@ maven-install-plugin 3.1.1 + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.4.5 + org.apache.maven.plugins maven-release-plugin diff --git a/src/main/java/net/hexonet/apiconnector/Response.java b/src/main/java/net/hexonet/apiconnector/Response.java index c6fe4584..e14c637c 100644 --- a/src/main/java/net/hexonet/apiconnector/Response.java +++ b/src/main/java/net/hexonet/apiconnector/Response.java @@ -3,10 +3,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; /** - * Response covers all functionality to wrap a Backend API Response like accessing data + * Response covers all functionality to wrap a Backend API Response like + * accessing data * * @author Kai Schwarz * @version %I%, %G% @@ -23,7 +25,8 @@ public class Response { */ private Map command; /** - * Column names available in this responsse NOTE: this includes also FIRST, LAST, LIMIT, COUNT, + * Column names available in this responsse NOTE: this includes also FIRST, + * LAST, LIMIT, COUNT, * TOTAL and maybe further specific columns in case of a list query */ private ArrayList columnkeys; @@ -173,7 +176,8 @@ public double getRuntime() { } /** - * Check if current API response represents an error case API response code is an 5xx code + * Check if current API response represents an error case API response code is + * an 5xx code * * @return boolean result */ @@ -183,7 +187,8 @@ public boolean isError() { } /** - * Check if current API response represents a success case API response code is an 2xx code + * Check if current API response represents a success case API response code is + * an 2xx code * * @return boolean result */ @@ -193,7 +198,8 @@ public boolean isSuccess() { } /** - * Check if current API response represents a temporary error case API response code is an 4xx + * Check if current API response represents a temporary error case API response + * code is an 4xx * code * * @return boolean result @@ -302,16 +308,15 @@ public Map getCommand() { * @return plain text command */ public String getCommandPlain() { - StringBuilder tmp = new StringBuilder(""); - Iterator> it = this.command.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry pair = it.next(); - tmp.append(pair.getKey()); - tmp.append(" = "); - tmp.append(pair.getValue()); - tmp.append("\n"); + StringBuilder result = new StringBuilder(); + List> sortedEntries = new ArrayList<>(this.command.entrySet()); + sortedEntries.sort(Map.Entry.comparingByKey()); + + for (Map.Entry entry : sortedEntries) { + result.append(entry.getKey()).append(" = ").append(entry.getValue()).append("\n"); } - return tmp.toString(); + + return result.toString(); } /** @@ -536,7 +541,8 @@ public int getRecordsTotalCount() { } /** - * Get limit(ation) setting of the current list query This is the count of requested rows + * Get limit(ation) setting of the current list query This is the count of + * requested rows * * @return limit setting or count requested rows */ @@ -598,7 +604,8 @@ private boolean hasColumn(String key) { } /** - * Check if the record list contains a record for the current record index in use + * Check if the record list contains a record for the current record index in + * use * * @return boolean result */ @@ -608,7 +615,8 @@ private boolean hasCurrentRecord() { } /** - * Check if the record list contains a next record for the current record index in use + * Check if the record list contains a next record for the current record index + * in use * * @return boolean result */ @@ -618,7 +626,8 @@ private boolean hasNextRecord() { } /** - * Check if the record list contains a previous record for the current record index in use + * Check if the record list contains a previous record for the current record + * index in use * * @return boolean result */ diff --git a/src/test/java/net/hexonet/apiconnector/ResponseTest.java b/src/test/java/net/hexonet/apiconnector/ResponseTest.java index 5be2ef2a..cffe98df 100644 --- a/src/test/java/net/hexonet/apiconnector/ResponseTest.java +++ b/src/test/java/net/hexonet/apiconnector/ResponseTest.java @@ -108,7 +108,7 @@ public void getCommandPlainSecure() { cmd.put("SUBUSER", "test.user"); cmd.put("PASSWORD", "test.passw0rd"); Response r = new Response("", cmd); - String str = "SUBUSER = test.user\nCOMMAND = CheckAuthentication\nPASSWORD = ***\n"; + String str = "COMMAND = CheckAuthentication\nPASSWORD = ***\nSUBUSER = test.user\n"; assertEquals(str, r.getCommandPlain()); }