Skip to content

Commit fba7ab9

Browse files
committed
add commits class
1 parent c0d9259 commit fba7ab9

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.arkecosystem.client.api;
2+
3+
import org.arkecosystem.client.BaseClientTest;
4+
import org.junit.jupiter.api.Test;
5+
6+
import java.io.IOException;
7+
import java.util.Map;
8+
9+
import static org.hamcrest.MatcherAssert.assertThat;
10+
import static org.hamcrest.Matchers.hasKey;
11+
12+
@SuppressWarnings("unchecked")
13+
public class CommitsIntegrationTest extends BaseClientTest {
14+
15+
@Test
16+
void show() throws IOException {
17+
Map<String, Object> actual = connection.api().commits.show(123456);
18+
assertThat(actual, hasKey("data"));
19+
}
20+
}

src/main/java/org/arkecosystem/client/api/Api.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.arkecosystem.client.http.Client;
44

55
public class Api {
6-
76
public final Blockchain blockchain;
87
public final Blocks blocks;
98
public final Delegates delegates;
@@ -15,6 +14,7 @@ public class Api {
1514
public final Votes votes;
1615
public final Wallets wallets;
1716
public final ApiNodes apiNodes;
17+
public final Commits commits;
1818

1919
public Api(Client client) {
2020
this.blockchain = new Blockchain(client);
@@ -28,5 +28,6 @@ public Api(Client client) {
2828
this.votes = new Votes(client);
2929
this.wallets = new Wallets(client);
3030
this.apiNodes = new ApiNodes(client);
31+
this.commits = new Commits(client);
3132
}
3233
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.arkecosystem.client.api;
2+
3+
import java.io.IOException;
4+
import java.util.Map;
5+
import org.arkecosystem.client.http.Client;
6+
7+
public class Commits {
8+
private final Client client;
9+
10+
public Commits(Client client) {
11+
this.client = client;
12+
}
13+
14+
public Map<String, Object> show(int height) throws IOException {
15+
return this.client.get("commits/" + height);
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.arkecosystem.client.api;
2+
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import java.io.IOException;
6+
import java.util.Map;
7+
import org.arkecosystem.client.Connection;
8+
import org.arkecosystem.client.MockHelper;
9+
import org.junit.jupiter.api.Test;
10+
11+
public class CommitsTest {
12+
13+
@Test
14+
void show() throws IOException {
15+
Connection connection = MockHelper.connection();
16+
Map<String, Object> actual = connection.api().commits.show(123456);
17+
assertTrue((boolean) actual.get("success"));
18+
}
19+
}

0 commit comments

Comments
 (0)