From fba7ab9d9e66c53d77e2efc3aa984409c5f7a02c Mon Sep 17 00:00:00 2001 From: Alfonso Bribiesca Date: Tue, 2 Jul 2024 11:25:59 -0600 Subject: [PATCH] add commits class --- .../arkecosystem/client/api/CommitsTest.java | 20 +++++++++++++++++++ .../java/org/arkecosystem/client/api/Api.java | 3 ++- .../org/arkecosystem/client/api/Commits.java | 17 ++++++++++++++++ .../arkecosystem/client/api/CommitsTest.java | 19 ++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/integration/java/org/arkecosystem/client/api/CommitsTest.java create mode 100644 src/main/java/org/arkecosystem/client/api/Commits.java create mode 100644 src/test/java/org/arkecosystem/client/api/CommitsTest.java 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/main/java/org/arkecosystem/client/api/Api.java b/src/main/java/org/arkecosystem/client/api/Api.java index ab8f7ac..63f48fa 100644 --- a/src/main/java/org/arkecosystem/client/api/Api.java +++ b/src/main/java/org/arkecosystem/client/api/Api.java @@ -3,7 +3,6 @@ import org.arkecosystem.client.http.Client; public class Api { - public final Blockchain blockchain; public final Blocks blocks; public final Delegates delegates; @@ -15,6 +14,7 @@ public class Api { 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); @@ -28,5 +28,6 @@ public Api(Client 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/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/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")); + } +}