From 161018f40c1055b0366be5fee4e43241604bde36 Mon Sep 17 00:00:00 2001 From: nex Date: Wed, 4 Mar 2020 02:54:43 +0800 Subject: [PATCH] Update ClientTests.java --- ...edgerClientTests.java => ClientTests.java} | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) rename src/test/java/bdledger/api/{TransactionLedgerClientTests.java => ClientTests.java} (75%) diff --git a/src/test/java/bdledger/api/TransactionLedgerClientTests.java b/src/test/java/bdledger/api/ClientTests.java similarity index 75% rename from src/test/java/bdledger/api/TransactionLedgerClientTests.java rename to src/test/java/bdledger/api/ClientTests.java index c2ef461..7a9a759 100644 --- a/src/test/java/bdledger/api/TransactionLedgerClientTests.java +++ b/src/test/java/bdledger/api/ClientTests.java @@ -1,7 +1,7 @@ package bdledger.api; -import bdchain.api.grpc.txledger.GetLedgersResponse; -import bdchain.api.grpc.common.TransactionType; +import bdledger.api.grpc.ledger.GetLedgersResponse; +import bdledger.api.grpc.common.TransactionType; import io.grpc.Status; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -14,35 +14,35 @@ import java.util.stream.IntStream; import static org.junit.jupiter.api.Assertions.*; @DisplayName("Transaction Ledger tests") -class TransactionLedgerClientTests { +class ClientTests { private static final String ledger = "test"; - private String[] ledgers = new String[] {"first", "second", "third"}; + private String[] ledgers = new String[]{"first", "second", "third"}; - private static TransactionLedgerClient tlClient; + private static Client client; @BeforeAll static void initAll() { - tlClient = new TransactionLedgerClient("localhost", 10000); + client = new Client("localhost", 10000); } @Test @DisplayName("ClientVersion#1") void clientVersion1() throws InterruptedException, ExecutionException { assertEquals( - "TxLedgerGo/v0.0.1alpha/darwin/go1.11", tlClient.clientVersion().get().getVersion()); + "TxLedgerGo/v0.0.1alpha/darwin/go1.11", client.clientVersion().get().getVersion()); } @Test @DisplayName("CreateLedger#1") void createLedger1() throws InterruptedException, ExecutionException { - assertTrue(tlClient.createLedger(ledger).get().getOk()); + assertTrue(client.createLedger(ledger).get().getOk()); } @Test @DisplayName("CreateLedger#2") void createLedger2() { - Throwable e = assertThrows(Exception.class, () -> tlClient.createLedger("").get()); + Throwable e = assertThrows(Exception.class, () -> client.createLedger("").get()); Status s = Status.fromThrowable(e); assertEquals(Status.Code.INVALID_ARGUMENT, s.getCode()); assertEquals("name must not be empty", s.getDescription()); @@ -51,9 +51,9 @@ class TransactionLedgerClientTests { @Test @DisplayName("GetLedgers#1") void getLedgers1() throws InterruptedException, ExecutionException { - GetLedgersResponse r = tlClient.getLedgers().get(); + GetLedgersResponse r = client.getLedgers().get(); assertEquals(3, r.getLedgersCount()); - String[] expected = new String[] {"first", "second", "third"}; + String[] expected = new String[]{"first", "second", "third"}; assertAll( IntStream.range(0, 3).boxed().map(i -> () -> assertEquals(ledgers[i], r.getLedgers(i)))); } @@ -63,7 +63,7 @@ class TransactionLedgerClientTests { void sendTransaction1() throws InterruptedException, ExecutionException { String hash = Utils.byteArrayToHexString( - tlClient + client .sendTransaction( ledger, TransactionType.MESSAGE, @@ -83,7 +83,7 @@ class TransactionLedgerClientTests { assertThrows( Exception.class, () -> - tlClient + client .sendTransaction(ledger, TransactionType.MESSAGE, null, "50bada55", null) .get()); Status s = Status.fromThrowable(e); @@ -93,6 +93,6 @@ class TransactionLedgerClientTests { @AfterAll static void teadDwonAll() throws InterruptedException { - tlClient.shutdown(); + client.shutdown(); } }