Skip to content

Commit

Permalink
add commits class
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsobries committed Jul 2, 2024
1 parent c0d9259 commit fba7ab9
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/integration/java/org/arkecosystem/client/api/CommitsTest.java
Original file line number Diff line number Diff line change
@@ -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<String, Object> actual = connection.api().commits.show(123456);
assertThat(actual, hasKey("data"));
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/arkecosystem/client/api/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/arkecosystem/client/api/Commits.java
Original file line number Diff line number Diff line change
@@ -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<String, Object> show(int height) throws IOException {
return this.client.get("commits/" + height);
}
}
19 changes: 19 additions & 0 deletions src/test/java/org/arkecosystem/client/api/CommitsTest.java
Original file line number Diff line number Diff line change
@@ -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<String, Object> actual = connection.api().commits.show(123456);
assertTrue((boolean) actual.get("success"));
}
}

0 comments on commit fba7ab9

Please sign in to comment.