diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index d1ac906..11f4440 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -5,19 +5,25 @@ on: workflow_dispatch jobs: integration: runs-on: ubuntu-latest + strategy: + matrix: + java: [8, 11, 15, 16, 17, 18, 19, 20, 21, 22] steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - - name: Use Java Version 8 - uses: actions/setup-java@v1 - with: - java-version: 8 + - name: Use Java Version ${{ matrix.java }} + uses: actions/setup-java@v2 + with: + distribution: "zulu" + java-version: ${{ matrix.java }} + cache: "gradle" - - name: Install - run: gradle dependencies + - name: Install + run: gradle dependencies - - name: Test - run: gradle integrationTest - env: - INTEGRATION_TESTS_MNEMONIC: ${{ secrets.MNEMONIC }} + - name: Test + run: gradle integrationTest + env: + INTEGRATION_TESTS_MNEMONIC: ${{ secrets.MNEMONIC }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d17ab3..37b5ee1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,65 +6,65 @@ on: - "master" - "develop" pull_request: - types: [ ready_for_review, synchronize, opened ] + types: [ready_for_review, synchronize, opened] jobs: format: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} - - name: Merge Conflict finder - uses: olivernybroe/action-conflict-finder@v1.1 + - name: Merge Conflict finder + uses: olivernybroe/action-conflict-finder@v1.1 - - name: Use Java Version 8 - uses: actions/setup-java@v2 - with: - distribution: 'adopt' - java-version: 8 - cache: 'gradle' + - name: Use Java Version 8 + uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: 8 + cache: "gradle" - - name: Format code - run: gradle format + - name: Format code + run: gradle format - - name: Commit fixed code - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "style: resolve style guide violations" - branch: ${{ github.head_ref }} + - name: Commit fixed code + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "style: resolve style guide violations" + branch: ${{ github.head_ref }} unit: runs-on: ubuntu-latest strategy: matrix: # test against the latest update of each major Java version, as well as specific updates of LTS versions: - java: [ 8, 11, 15, 16, 17 ] + java: [8, 11, 15, 16, 17, 18, 19, 20, 21, 22] steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} - - name: Merge Conflict finder - uses: olivernybroe/action-conflict-finder@v1.1 + - name: Merge Conflict finder + uses: olivernybroe/action-conflict-finder@v1.1 - - name: Use Java Version ${{ matrix.java }} - uses: actions/setup-java@v2 - with: - distribution: 'zulu' - java-version: ${{ matrix.java }} - cache: 'gradle' + - name: Use Java Version ${{ matrix.java }} + uses: actions/setup-java@v2 + with: + distribution: "zulu" + java-version: ${{ matrix.java }} + cache: "gradle" - - name: Install - run: gradle dependencies + - name: Install + run: gradle dependencies - - name: Test - run: gradle test && gradle jacocoTestReport + - name: Test + run: gradle test && gradle jacocoTestReport - - name: Codecov - run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} + - name: Codecov + run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} diff --git a/src/integration/java/org/arkecosystem/client/api/ApiNodesTest.java b/src/integration/java/org/arkecosystem/client/api/ApiNodesTest.java new file mode 100644 index 0000000..a40b5ca --- /dev/null +++ b/src/integration/java/org/arkecosystem/client/api/ApiNodesTest.java @@ -0,0 +1,30 @@ +package org.arkecosystem.client.api; + +import org.arkecosystem.client.BaseClientTest; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasEntry; +import static org.hamcrest.Matchers.hasKey; + +@SuppressWarnings("unchecked") +public class ApiNodesIntegrationTest extends BaseClientTest { + + @Test + void all() throws IOException { + Map actual = connection.api().apiNodes.all(); + assertThat(actual, hasKey("data")); + assertThat(actual, hasKey("meta")); + } + + @Test + void allWithParams() throws IOException { + Map actual = + connection.api().apiNodes.param("page", 1).param("limit", 100).all(); + assertThat(actual, hasKey("data")); + assertThat(actual, hasKey("meta")); + } +} diff --git a/src/integration/java/org/arkecosystem/client/api/CommitsTest.java b/src/integration/java/org/arkecosystem/client/api/CommitsTest.java new file mode 100644 index 0000000..e9733db --- /dev/null +++ b/src/integration/java/org/arkecosystem/client/api/CommitsTest.java @@ -0,0 +1,20 @@ +package org.arkecosystem.client.api; + +import org.arkecosystem.client.BaseClientTest; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasKey; + +@SuppressWarnings("unchecked") +public class CommitsIntegrationTest extends BaseClientTest { + + @Test + void show() throws IOException { + Map actual = connection.api().commits.show(123456); + assertThat(actual, hasKey("data")); + } +} diff --git a/src/integration/java/org/arkecosystem/client/api/LocksTest.java b/src/integration/java/org/arkecosystem/client/api/LocksTest.java deleted file mode 100644 index 83d230d..0000000 --- a/src/integration/java/org/arkecosystem/client/api/LocksTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.arkecosystem.client.api; - -import org.arkecosystem.client.BaseClientTest; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.util.Collections; -import java.util.Map; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasEntry; -import static org.hamcrest.Matchers.hasKey; - -@SuppressWarnings("unchecked") -public class LocksTest extends BaseClientTest { - - @Test - void all() throws IOException { - Map actual = connection.api().locks.all(); - assertThat(actual, hasKey("meta")); - assertThat(actual, hasKey("data")); - } - - @Test - void allWithParams() throws IOException { - Map actual = - connection.api().locks.param("page", 1).param("limit", 2).all(); - assertThat(actual, hasKey("meta")); - assertThat(actual, hasKey("data")); - assertThat((Map) actual.get("meta"), hasEntry("count", 2.0)); - } - - @Test - void show() throws IOException { - Map actual = connection.api().locks.show("d8e7491055f5b34c0c954da9d4e184f1bdef3fbfe3dfc81d312c81899fbfc74d"); - assertThat(actual, hasKey("data")); - assertThat((Map) actual.get("data"), hasEntry("lockId", "d8e7491055f5b34c0c954da9d4e184f1bdef3fbfe3dfc81d312c81899fbfc74d")); - } - - @Test - void searchUnlocked() throws IOException { - Map actual = connection.api().locks.searchUnlocked(Collections.singletonMap("ids", Collections.singletonList("d8e7491055f5b34c0c954da9d4e184f1bdef3fbfe3dfc81d312c81899fbfc74d"))); - assertThat(actual, hasKey("meta")); - assertThat(actual, hasKey("data")); - assertThat((Map) actual.get("meta"), hasEntry("count", 0.0)); - } - - @Test - void searchUnlockedWithParams() throws IOException { - Map actual = connection.api().locks.param("ids", Collections.singletonList("d8e7491055f5b34c0c954da9d4e184f1bdef3fbfe3dfc81d312c81899fbfc74d")).searchUnlocked(); - assertThat(actual, hasKey("meta")); - assertThat(actual, hasKey("data")); - assertThat((Map) actual.get("meta"), hasEntry("count", 0.0)); - } -} diff --git a/src/integration/java/org/arkecosystem/client/api/RoundsTest.java b/src/integration/java/org/arkecosystem/client/api/RoundsTest.java index 29ccd67..622e112 100644 --- a/src/integration/java/org/arkecosystem/client/api/RoundsTest.java +++ b/src/integration/java/org/arkecosystem/client/api/RoundsTest.java @@ -7,13 +7,36 @@ import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasKey; -public class RoundsTest extends BaseClientTest { +public class RoundsIntegrationTest extends BaseClientTest { @Test void delegates() throws IOException { Map actual = connection.api().rounds.delegates(12345); assertThat(actual, hasKey("data")); } + + @Test + void all() throws IOException { + Map actual = connection.api().rounds.all(); + assertThat(actual, hasKey("data")); + assertThat(actual, hasKey("meta")); + } + + @Test + void allWithParams() throws IOException { + Map actual = + connection.api().rounds.param("page", 1).param("limit", 100).all(); + assertThat(actual, hasKey("data")); + assertThat(actual, hasKey("meta")); + } + + @Test + void show() throws IOException { + Map actual = connection.api().rounds.show(12345); + assertThat(actual, hasKey("data")); + assertThat((Map) actual.get("data"), hasEntry("id", 12345.0)); + } } diff --git a/src/integration/java/org/arkecosystem/client/api/WalletsTest.java b/src/integration/java/org/arkecosystem/client/api/WalletsTest.java index 7e4c12b..1ae3e6b 100644 --- a/src/integration/java/org/arkecosystem/client/api/WalletsTest.java +++ b/src/integration/java/org/arkecosystem/client/api/WalletsTest.java @@ -130,16 +130,6 @@ void votesWithParams() throws IOException { assertThat((Map) actual.get("meta"), hasEntry("count", 3.0)); } - @Test - void locks() throws IOException { - Map actual = connection.api().wallets.locks("D6i8P5N44rFto6M6RALyUXLLs7Q1A1WREW"); - logger.info("actual: {}", actual); - - assertThat(actual, hasKey("meta")); - assertThat(actual, hasKey("data")); - assertThat((Map) actual.get("meta"), hasEntry("count", 0.0)); - } - @Test void top() throws IOException { Map actual = connection.api().wallets.top(); diff --git a/src/main/java/org/arkecosystem/client/api/Api.java b/src/main/java/org/arkecosystem/client/api/Api.java index b177ca4..63f48fa 100644 --- a/src/main/java/org/arkecosystem/client/api/Api.java +++ b/src/main/java/org/arkecosystem/client/api/Api.java @@ -3,30 +3,31 @@ import org.arkecosystem.client.http.Client; public class Api { - public final Blockchain blockchain; public final Blocks blocks; public final Delegates delegates; public final Entities entities; - public final Locks locks; public final Node node; public final Peers peers; public final Rounds rounds; public final Transactions transactions; public final Votes votes; public final Wallets wallets; + public final ApiNodes apiNodes; + public final Commits commits; public Api(Client client) { this.blockchain = new Blockchain(client); this.blocks = new Blocks(client); this.delegates = new Delegates(client); this.entities = new Entities(client); - this.locks = new Locks(client); this.node = new Node(client); this.peers = new Peers(client); this.rounds = new Rounds(client); this.transactions = new Transactions(client); this.votes = new Votes(client); this.wallets = new Wallets(client); + this.apiNodes = new ApiNodes(client); + this.commits = new Commits(client); } } diff --git a/src/main/java/org/arkecosystem/client/api/ApiNodes.java b/src/main/java/org/arkecosystem/client/api/ApiNodes.java new file mode 100644 index 0000000..1667b59 --- /dev/null +++ b/src/main/java/org/arkecosystem/client/api/ApiNodes.java @@ -0,0 +1,26 @@ +package org.arkecosystem.client.api; + +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; +import org.arkecosystem.client.http.Client; + +public class ApiNodes implements SupportsParams { + private final Client client; + + private final Map params = new LinkedHashMap<>(); + + public ApiNodes(Client client) { + this.client = client; + } + + @Override + public ApiNodes param(String name, Object value) { + params.put(name, value); + return this; + } + + public Map all() throws IOException { + return this.client.get("api-nodes", params); + } +} diff --git a/src/main/java/org/arkecosystem/client/api/Commits.java b/src/main/java/org/arkecosystem/client/api/Commits.java new file mode 100644 index 0000000..e7a344c --- /dev/null +++ b/src/main/java/org/arkecosystem/client/api/Commits.java @@ -0,0 +1,17 @@ +package org.arkecosystem.client.api; + +import java.io.IOException; +import java.util.Map; +import org.arkecosystem.client.http.Client; + +public class Commits { + private final Client client; + + public Commits(Client client) { + this.client = client; + } + + public Map show(int height) throws IOException { + return this.client.get("commits/" + height); + } +} diff --git a/src/main/java/org/arkecosystem/client/api/Locks.java b/src/main/java/org/arkecosystem/client/api/Locks.java deleted file mode 100644 index 3226841..0000000 --- a/src/main/java/org/arkecosystem/client/api/Locks.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.arkecosystem.client.api; - -import java.io.IOException; -import java.util.LinkedHashMap; -import java.util.Map; -import org.arkecosystem.client.http.Client; - -public class Locks implements SupportsParams { - private final Client client; - - private final Map params = new LinkedHashMap<>(); - - public Locks(Client client) { - this.client = client; - } - - @Override - public Locks param(String name, Object value) { - params.put(name, value); - return this; - } - - public Map all() throws IOException { - return this.client.get("locks", params); - } - - public Map show(String id) throws IOException { - return this.client.get("locks/" + id); - } - - public Map searchUnlocked() throws IOException { - return this.client.post("locks/unlocked", params); - } - - public Map searchUnlocked(Map parameters) throws IOException { - return this.client.post("locks/unlocked", parameters); - } -} diff --git a/src/main/java/org/arkecosystem/client/api/Rounds.java b/src/main/java/org/arkecosystem/client/api/Rounds.java index 1039e25..1cff635 100644 --- a/src/main/java/org/arkecosystem/client/api/Rounds.java +++ b/src/main/java/org/arkecosystem/client/api/Rounds.java @@ -1,17 +1,32 @@ package org.arkecosystem.client.api; import java.io.IOException; +import java.util.LinkedHashMap; import java.util.Map; import org.arkecosystem.client.http.Client; public class Rounds { private final Client client; + private final Map params = new LinkedHashMap<>(); public Rounds(Client client) { this.client = client; } + public Rounds param(String name, Object value) { + params.put(name, value); + return this; + } + public Map delegates(int id) throws IOException { return this.client.get("rounds/" + id + "/delegates"); } + + public Map all() throws IOException { + return this.client.get("rounds", params); + } + + public Map show(int roundId) throws IOException { + return this.client.get("rounds/" + roundId); + } } diff --git a/src/main/java/org/arkecosystem/client/api/Wallets.java b/src/main/java/org/arkecosystem/client/api/Wallets.java index f3ecd30..d730731 100644 --- a/src/main/java/org/arkecosystem/client/api/Wallets.java +++ b/src/main/java/org/arkecosystem/client/api/Wallets.java @@ -47,8 +47,4 @@ public Map receivedTransactions(String id) throws IOException { public Map votes(String id) throws IOException { return this.client.get("wallets/" + id + "/votes", params); } - - public Map locks(String id) throws IOException { - return this.client.get("wallets/" + id + "/locks"); - } } diff --git a/src/test/java/org/arkecosystem/client/api/ApiNodesTest.java b/src/test/java/org/arkecosystem/client/api/ApiNodesTest.java new file mode 100644 index 0000000..b0fa9dc --- /dev/null +++ b/src/test/java/org/arkecosystem/client/api/ApiNodesTest.java @@ -0,0 +1,27 @@ +package org.arkecosystem.client.api; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.util.Map; +import org.arkecosystem.client.Connection; +import org.arkecosystem.client.MockHelper; +import org.junit.jupiter.api.Test; + +public class ApiNodesTest { + + @Test + void all() throws IOException { + Connection connection = MockHelper.connection(); + Map actual = connection.api().apiNodes.all(); + assertTrue((boolean) actual.get("success")); + } + + @Test + void allWithParams() throws IOException { + Connection connection = MockHelper.connection(); + Map actual = + connection.api().apiNodes.param("page", 1).param("limit", 100).all(); + assertTrue((boolean) actual.get("success")); + } +} diff --git a/src/test/java/org/arkecosystem/client/api/CommitsTest.java b/src/test/java/org/arkecosystem/client/api/CommitsTest.java new file mode 100644 index 0000000..ceea79d --- /dev/null +++ b/src/test/java/org/arkecosystem/client/api/CommitsTest.java @@ -0,0 +1,19 @@ +package org.arkecosystem.client.api; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.util.Map; +import org.arkecosystem.client.Connection; +import org.arkecosystem.client.MockHelper; +import org.junit.jupiter.api.Test; + +public class CommitsTest { + + @Test + void show() throws IOException { + Connection connection = MockHelper.connection(); + Map actual = connection.api().commits.show(123456); + assertTrue((boolean) actual.get("success")); + } +} diff --git a/src/test/java/org/arkecosystem/client/api/LocksTest.java b/src/test/java/org/arkecosystem/client/api/LocksTest.java deleted file mode 100644 index 115f82a..0000000 --- a/src/test/java/org/arkecosystem/client/api/LocksTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.arkecosystem.client.api; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.IOException; -import java.util.Collections; -import java.util.Map; -import org.arkecosystem.client.Connection; -import org.arkecosystem.client.MockHelper; -import org.junit.jupiter.api.Test; - -public class LocksTest { - - @Test - void all() throws IOException { - Connection connection = MockHelper.connection(); - Map actual = connection.api().locks.all(); - assertTrue((boolean) actual.get("success")); - } - - @Test - void allWithParams() throws IOException { - Connection connection = MockHelper.connection(); - Map actual = - connection.api().locks.param("page", 1).param("limit", 100).all(); - assertTrue((boolean) actual.get("success")); - } - - @Test - void show() throws IOException { - Connection connection = MockHelper.connection(); - Map actual = connection.api().locks.show("dummy"); - assertTrue((boolean) actual.get("success")); - } - - @Test - void searchUnlocked() throws IOException { - Connection connection = MockHelper.connection(); - Map actual = connection.api().locks.searchUnlocked(); - assertTrue((boolean) actual.get("success")); - } - - @Test - void searchUnlockedWithParams() throws IOException { - Connection connection = MockHelper.connection(); - Map actual = - connection.api().locks.searchUnlocked(Collections.singletonMap("page", 1)); - assertTrue((boolean) actual.get("success")); - } -} diff --git a/src/test/java/org/arkecosystem/client/api/RoundsTest.java b/src/test/java/org/arkecosystem/client/api/RoundsTest.java index b2175d2..f524938 100644 --- a/src/test/java/org/arkecosystem/client/api/RoundsTest.java +++ b/src/test/java/org/arkecosystem/client/api/RoundsTest.java @@ -16,4 +16,26 @@ void delegates() throws IOException { Map actual = connection.api().rounds.delegates(12345); assertTrue((boolean) actual.get("success")); } + + @Test + void all() throws IOException { + Connection connection = MockHelper.connection(); + Map actual = connection.api().rounds.all(); + assertTrue((boolean) actual.get("success")); + } + + @Test + void allWithParams() throws IOException { + Connection connection = MockHelper.connection(); + Map actual = + connection.api().rounds.param("page", 1).param("limit", 100).all(); + assertTrue((boolean) actual.get("success")); + } + + @Test + void show() throws IOException { + Connection connection = MockHelper.connection(); + Map actual = connection.api().rounds.show(12345); + assertTrue((boolean) actual.get("success")); + } } diff --git a/src/test/java/org/arkecosystem/client/api/WalletsTest.java b/src/test/java/org/arkecosystem/client/api/WalletsTest.java index d09f275..30d7b98 100644 --- a/src/test/java/org/arkecosystem/client/api/WalletsTest.java +++ b/src/test/java/org/arkecosystem/client/api/WalletsTest.java @@ -91,13 +91,6 @@ void votesWithParams() throws IOException { assertTrue((boolean) actual.get("success")); } - @Test - void locks() throws IOException { - Connection connection = MockHelper.connection(); - Map actual = connection.api().wallets.locks("dummy"); - assertTrue((boolean) actual.get("success")); - } - @Test void top() throws IOException { Connection connection = MockHelper.connection();