11package com .openelements .hiero .spring .test ;
22
3- import com .hedera .hashgraph .sdk .TokenId ;
4- import com .openelements .hiero .base .*;
5- import com .openelements .hiero .base .data .*;
3+ import com .hedera .hashgraph .sdk .AccountId ;
4+ import com .openelements .hiero .base .AccountClient ;
5+ import com .openelements .hiero .base .HieroException ;
6+ import com .openelements .hiero .base .data .Account ;
7+ import com .openelements .hiero .base .data .Page ;
8+ import com .openelements .hiero .base .data .Result ;
9+ import com .openelements .hiero .base .data .BalanceModification ;
10+ import com .openelements .hiero .base .data .TransactionInfo ;
611import com .openelements .hiero .base .mirrornode .TransactionRepository ;
712import com .openelements .hiero .base .protocol .data .TransactionType ;
813import com .openelements .hiero .test .HieroTestUtils ;
@@ -21,38 +26,54 @@ public class TransactionRepositoryTest {
2126 @ Autowired
2227 private AccountClient accountClient ;
2328
24- @ Autowired
25- private NftClient nftClient ;
26-
27- @ Autowired
28- private TopicClient topicClient ;
29-
3029 @ Autowired
3130 private HieroTestUtils hieroTestUtils ;
3231
3332 @ Test
3433 void testFindTransactionByAccountId () throws HieroException {
35- final Account account = accountClient .createAccount (10 );
36- final TokenId id = nftClient .createNftType ("Hello Hiero" , "NFT" , account );
37- nftClient .mintNft (id , account .privateKey (), "Hello Hiero" .getBytes ());
38- hieroTestUtils .waitForMirrorNodeRecords ();
34+ final Account account = accountClient .createAccount (1 );
3935
4036 final Page <TransactionInfo > page = transactionRepository .findByAccount (account .accountId ());
4137 Assertions .assertNotNull (page );
38+
4239 final List <TransactionInfo > data = page .getData ();
43- System .out .println (page .getData ().size ());
4440 Assertions .assertFalse (data .isEmpty ());
4541 }
4642
4743 @ Test
48- void test2 () throws HieroException {
49- Page <TransactionInfo > page = transactionRepository .findByAccountAndResult ("0.0.4951978" , Result .FAIL );
50- System .out .println (page .getData ());
44+ void testFindTransactionByAccountIdGiveEmptyListForAccountIdWithZeroTransaction () throws HieroException {
45+ final AccountId accountId = AccountId .fromString ("0.0.0" );
46+ final Page <TransactionInfo > page = transactionRepository .findByAccount (accountId );
47+ Assertions .assertNotNull (page );
48+
49+ final List <TransactionInfo > data = page .getData ();
50+ Assertions .assertTrue (data .isEmpty ());
51+ }
52+
53+ @ Test
54+ void testFindTransactionByAccountIdAndType () throws HieroException {
55+ final Account account = accountClient .createAccount (1 );
56+
57+ final Page <TransactionInfo > page = transactionRepository .findByAccountAndType (account .accountId (),
58+ TransactionType .ACCOUNT_CREATE );
59+ Assertions .assertNotNull (page );
60+ }
61+
62+ @ Test
63+ void testFindTransactionByAccountIdAndResult () throws HieroException {
64+ final Account account = accountClient .createAccount (1 );
65+
66+ final Page <TransactionInfo > page = transactionRepository .findByAccountAndResult (account .accountId (),
67+ Result .SUCCESS );
68+ Assertions .assertNotNull (page );
5169 }
5270
5371 @ Test
54- void test3 () throws HieroException {
55- Page <TransactionInfo > page = transactionRepository .findByAccountAndModification ("0.0.4951978" , BalanceModification .DEBIT );
56- System .out .println (page .getData ());
72+ void testFindTransactionByAccountIdAndBalanceModification () throws HieroException {
73+ final Account account = accountClient .createAccount (1 );
74+
75+ final Page <TransactionInfo > page = transactionRepository .findByAccountAndModification (account .accountId (),
76+ BalanceModification .DEBIT );
77+ Assertions .assertNotNull (page );
5778 }
5879}
0 commit comments