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/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/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")); + } }