From abaef5b3fde366013ad722f60de80440436ca15c Mon Sep 17 00:00:00 2001 From: Boris Velkovski Date: Mon, 27 Feb 2023 14:42:36 +0200 Subject: [PATCH] Add Junit test for result type --- build.gradle | 2 +- polkaj-adapter-tests/build.gradle | 1 + polkaj-api-base/build.gradle | 1 + polkaj-api-http/build.gradle | 1 + polkaj-api-ws/build.gradle | 1 + polkaj-common-types/build.gradle | 1 + polkaj-json-types/build.gradle | 1 + polkaj-scale-types/build.gradle | 1 + ...codeResult.java => EncodeDecodeResultTest.java} | 14 +++++++------- polkaj-scale/build.gradle | 1 + polkaj-schnorrkel/build.gradle | 1 + polkaj-ss58/build.gradle | 1 + polkaj-tx/build.gradle | 1 + 13 files changed, 19 insertions(+), 8 deletions(-) rename polkaj-scale-types/src/test/java/io/emeraldpay/polkaj/scaletypes/{EncodeDecodeResult.java => EncodeDecodeResultTest.java} (74%) diff --git a/build.gradle b/build.gradle index 3429a528..92fbcabf 100644 --- a/build.gradle +++ b/build.gradle @@ -62,4 +62,4 @@ bintray { name = 'none' } } -} \ No newline at end of file +} diff --git a/polkaj-adapter-tests/build.gradle b/polkaj-adapter-tests/build.gradle index 54b154d3..17b8b2d1 100644 --- a/polkaj-adapter-tests/build.gradle +++ b/polkaj-adapter-tests/build.gradle @@ -17,4 +17,5 @@ dependencies { api 'org.codehaus.groovy:groovy-all:3.0.3' api 'commons-codec:commons-codec:1.14' api 'cglib:cglib-nodep:3.3.0' + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' } \ No newline at end of file diff --git a/polkaj-api-base/build.gradle b/polkaj-api-base/build.gradle index 41ee3c85..87e8ce34 100644 --- a/polkaj-api-base/build.gradle +++ b/polkaj-api-base/build.gradle @@ -5,4 +5,5 @@ apply from: '../common_java_app.gradle' dependencies { api project(":polkaj-json-types") + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' } \ No newline at end of file diff --git a/polkaj-api-http/build.gradle b/polkaj-api-http/build.gradle index 64c53ecd..0518e2fd 100644 --- a/polkaj-api-http/build.gradle +++ b/polkaj-api-http/build.gradle @@ -8,6 +8,7 @@ compileJava { dependencies { api project(":polkaj-json-types") api project(":polkaj-api-base") + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' testImplementation 'org.mock-server:mockserver-netty:5.10' testImplementation project(":polkaj-adapter-tests") diff --git a/polkaj-api-ws/build.gradle b/polkaj-api-ws/build.gradle index 496ee64b..aedbae92 100644 --- a/polkaj-api-ws/build.gradle +++ b/polkaj-api-ws/build.gradle @@ -9,6 +9,7 @@ compileJava { dependencies { api project(":polkaj-json-types") api project(":polkaj-api-base") + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' testImplementation 'org.java-websocket:Java-WebSocket:1.5.1' testImplementation project(":polkaj-adapter-tests") diff --git a/polkaj-common-types/build.gradle b/polkaj-common-types/build.gradle index 77c8cd4c..57ff5d2e 100644 --- a/polkaj-common-types/build.gradle +++ b/polkaj-common-types/build.gradle @@ -2,4 +2,5 @@ apply from: '../common_java_app.gradle' dependencies { api project(":polkaj-ss58") + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' } \ No newline at end of file diff --git a/polkaj-json-types/build.gradle b/polkaj-json-types/build.gradle index 72e5c404..b1d54d14 100644 --- a/polkaj-json-types/build.gradle +++ b/polkaj-json-types/build.gradle @@ -5,5 +5,6 @@ dependencies { api project(":polkaj-ss58") api 'com.fasterxml.jackson.core:jackson-databind:2.11.0' + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' } \ No newline at end of file diff --git a/polkaj-scale-types/build.gradle b/polkaj-scale-types/build.gradle index b60d52c0..469959bb 100644 --- a/polkaj-scale-types/build.gradle +++ b/polkaj-scale-types/build.gradle @@ -3,5 +3,6 @@ apply from: '../common_java_app.gradle' dependencies { api project(":polkaj-scale") api project(":polkaj-common-types") + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' testImplementation 'org.testng:testng:7.1.0' } \ No newline at end of file diff --git a/polkaj-scale-types/src/test/java/io/emeraldpay/polkaj/scaletypes/EncodeDecodeResult.java b/polkaj-scale-types/src/test/java/io/emeraldpay/polkaj/scaletypes/EncodeDecodeResultTest.java similarity index 74% rename from polkaj-scale-types/src/test/java/io/emeraldpay/polkaj/scaletypes/EncodeDecodeResult.java rename to polkaj-scale-types/src/test/java/io/emeraldpay/polkaj/scaletypes/EncodeDecodeResultTest.java index f5c95c77..59ffc4b1 100644 --- a/polkaj-scale-types/src/test/java/io/emeraldpay/polkaj/scaletypes/EncodeDecodeResult.java +++ b/polkaj-scale-types/src/test/java/io/emeraldpay/polkaj/scaletypes/EncodeDecodeResultTest.java @@ -2,17 +2,17 @@ import io.emeraldpay.polkaj.scale.ScaleCodecReader; import io.emeraldpay.polkaj.scale.ScaleCodecWriter; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Assertions; -public class EncodeDecodeResult { +public class EncodeDecodeResultTest { @Test - public void EncodeDecodeResult() { + public void EncodeDecodeResultTest() { Result dataToEncode = new Result<>(Result.ResultMode.OK, 10, 5); ByteArrayOutputStream buf = new ByteArrayOutputStream(); try (ScaleCodecWriter writer = new ScaleCodecWriter(buf)) { @@ -24,9 +24,9 @@ public void EncodeDecodeResult() { ResultReader resultReader = new ResultReader<>(); Result result = resultReader.readResult(reader, ScaleCodecReader::readCompactInt, ScaleCodecReader::readCompactInt); - assertEquals(dataToEncode.mode, result.mode); - assertEquals(dataToEncode.getOkValue(), result.getOkValue()); - assertEquals(null, result.getErrorValue()); + Assertions.assertEquals(dataToEncode.mode, result.mode); + Assertions.assertEquals(dataToEncode.getOkValue(), result.getOkValue()); + Assertions.assertEquals(null, result.getErrorValue()); } catch (IOException e) { e.printStackTrace(); } diff --git a/polkaj-scale/build.gradle b/polkaj-scale/build.gradle index 64cdaea9..d050bcee 100644 --- a/polkaj-scale/build.gradle +++ b/polkaj-scale/build.gradle @@ -2,4 +2,5 @@ apply from: '../common_java_app.gradle' dependencies { api project(":polkaj-common-types") + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' } \ No newline at end of file diff --git a/polkaj-schnorrkel/build.gradle b/polkaj-schnorrkel/build.gradle index f959f146..ff0ca907 100644 --- a/polkaj-schnorrkel/build.gradle +++ b/polkaj-schnorrkel/build.gradle @@ -1,6 +1,7 @@ apply from: '../common_java_app.gradle' dependencies { +api 'org.junit.jupiter:junit-jupiter-api:5.9.2' } test { diff --git a/polkaj-ss58/build.gradle b/polkaj-ss58/build.gradle index 42f765a9..e0b83816 100644 --- a/polkaj-ss58/build.gradle +++ b/polkaj-ss58/build.gradle @@ -2,5 +2,6 @@ apply from: '../common_java_app.gradle' dependencies { api 'com.github.multiformats:java-multibase:v1.0.0' + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' implementation 'org.bouncycastle:bcprov-jdk15on:1.65' } \ No newline at end of file diff --git a/polkaj-tx/build.gradle b/polkaj-tx/build.gradle index b57bf4c3..210fd49c 100644 --- a/polkaj-tx/build.gradle +++ b/polkaj-tx/build.gradle @@ -11,4 +11,5 @@ dependencies { // for xxHash api 'net.openhft:zero-allocation-hashing:0.11' api 'org.bouncycastle:bcprov-jdk15on:1.65' + api 'org.junit.jupiter:junit-jupiter-api:5.9.2' } \ No newline at end of file