-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cec7974
commit c0d9259
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/integration/java/org/arkecosystem/client/api/ApiNodesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, Object> actual = connection.api().apiNodes.all(); | ||
assertThat(actual, hasKey("data")); | ||
assertThat(actual, hasKey("meta")); | ||
} | ||
|
||
@Test | ||
void allWithParams() throws IOException { | ||
Map<String, Object> actual = | ||
connection.api().apiNodes.param("page", 1).param("limit", 100).all(); | ||
assertThat(actual, hasKey("data")); | ||
assertThat(actual, hasKey("meta")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ApiNodes> { | ||
private final Client client; | ||
|
||
private final Map<String, Object> 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<String, Object> all() throws IOException { | ||
return this.client.get("api-nodes", params); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/org/arkecosystem/client/api/ApiNodesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, Object> actual = connection.api().apiNodes.all(); | ||
assertTrue((boolean) actual.get("success")); | ||
} | ||
|
||
@Test | ||
void allWithParams() throws IOException { | ||
Connection connection = MockHelper.connection(); | ||
Map<String, Object> actual = | ||
connection.api().apiNodes.param("page", 1).param("limit", 100).all(); | ||
assertTrue((boolean) actual.get("success")); | ||
} | ||
} |