Skip to content

Commit 7a7f1f7

Browse files
Added test to verify NullPointerException for null transactions
1 parent 2cdeb59 commit 7a7f1f7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

hedera-base/src/test/java/com/openelements/hedera/base/test/ProtocolLayerClientTests.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
package com.openelements.hedera.base.test;
22

3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
5+
36
import com.hedera.hashgraph.sdk.AccountId;
47
import com.hedera.hashgraph.sdk.Client;
58
import com.hedera.hashgraph.sdk.PrivateKey;
69
import com.openelements.hedera.base.Account;
710
import com.openelements.hedera.base.implementation.ProtocolLayerClientImpl;
8-
import com.openelements.hedera.base.protocol.ProtocolLayerClient;
9-
import org.junit.jupiter.api.Assertions;
10-
import org.junit.jupiter.api.Test;
1111

1212
public class ProtocolLayerClientTests {
1313

1414
@Test
1515
void testNullConstructorParam() {
16-
//then
16+
//given
1717
final Client client = Client.forTestnet();
1818
final Account account = new Account(AccountId.fromString("0.0.12345"), PrivateKey.generateED25519().getPublicKey(), PrivateKey.generateED25519());
19+
20+
//then
1921
Assertions.assertThrows(NullPointerException.class, () -> new ProtocolLayerClientImpl(client, null));
2022
Assertions.assertThrows(NullPointerException.class, () -> new ProtocolLayerClientImpl(null, account));
2123
Assertions.assertThrows(NullPointerException.class, () -> new ProtocolLayerClientImpl(null, null));
@@ -25,7 +27,7 @@ void testNullConstructorParam() {
2527
void testNullParams() {
2628
//given
2729
final Account account = new Account(AccountId.fromString("0.0.12345"), PrivateKey.generateED25519().getPublicKey(), PrivateKey.generateED25519());
28-
final ProtocolLayerClient client = new ProtocolLayerClientImpl(Client.forTestnet(), account);
30+
final ProtocolLayerClientImpl client = new ProtocolLayerClientImpl(Client.forTestnet(), account);
2931

3032
//then
3133
Assertions.assertThrows(NullPointerException.class, () -> client.executeAccountBalanceQuery(null));
@@ -38,5 +40,16 @@ void testNullParams() {
3840
Assertions.assertThrows(NullPointerException.class, () -> client.executeContractCallTransaction(null));
3941
Assertions.assertThrows(NullPointerException.class, () -> client.executeFileInfoQuery(null));
4042
Assertions.assertThrows(NullPointerException.class, () -> client.executeAccountDeleteTransaction(null));
43+
Assertions.assertThrows(NullPointerException.class, () -> client.executeContractDeleteTransaction(null));
44+
Assertions.assertThrows(NullPointerException.class, () -> client.executeAccountCreateTransaction(null));
45+
Assertions.assertThrows(NullPointerException.class, () -> client.executeTokenCreateTransaction(null));
46+
Assertions.assertThrows(NullPointerException.class, () -> client.executeTokenAssociateTransaction(null));
47+
Assertions.assertThrows(NullPointerException.class, () -> client.executeTopicCreateTransaction(null));
48+
Assertions.assertThrows(NullPointerException.class, () -> client.executeTopicDeleteTransaction(null));
49+
Assertions.assertThrows(NullPointerException.class, () -> client.executeTopicMessageSubmitTransaction(null));
50+
Assertions.assertThrows(NullPointerException.class, () -> client.executeTokenCreateTransaction(null));
51+
Assertions.assertThrows(NullPointerException.class, () -> client.executeBurnTokenTransaction(null));
52+
Assertions.assertThrows(NullPointerException.class, () -> client.executeMintTokenTransaction(null));
53+
Assertions.assertThrows(NullPointerException.class, () -> client.executeTransferTransactionForNft(null));
4154
}
4255
}

hedera-base/src/test/java/com/openelements/hedera/base/test/ProtocolLayerDataCreationTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.hedera.hashgraph.sdk.ContractFunctionResult;
1212
import com.hedera.hashgraph.sdk.TokenId;
1313
import com.hedera.hashgraph.sdk.TokenType;
14-
import com.hedera.hashgraph.sdk.TopicId;
1514
import com.hedera.hashgraph.sdk.proto.ContractFunctionResultOrBuilder;
1615
import com.openelements.hedera.base.Account;
1716
import com.openelements.hedera.base.ContractParam;

0 commit comments

Comments
 (0)