2121
2222public class GetTransactionsTest extends BaseApiIntegrationTest {
2323
24- @ Disabled ("currently, dont work correctly - re-enable once it's working again" )
24+ @ Disabled ("currently, dont work correctly - re-enable once it's working again" )
2525 @ SneakyThrows
2626 @ Test
2727 void getTransactions_byExistingAccountId_ok () {
@@ -30,8 +30,8 @@ void getTransactions_byExistingAccountId_ok() {
3030
3131 // get first account transactions
3232 Response <TransactionsResponse > transactionsResponse = client .service ()
33- .getTransactions (firstAccountId )
34- .execute ();
33+ .getTransactions (firstAccountId )
34+ .execute ();
3535
3636 TransactionsResponse transactions = transactionsResponse .body ();
3737
@@ -41,7 +41,7 @@ void getTransactions_byExistingAccountId_ok() {
4141 assertTrue (transactions .getResults ().size () > 0 );
4242 }
4343
44- @ Disabled ("currently, dont work correctly - re-enable once it's working again" )
44+ @ Disabled ("currently, dont work correctly - re-enable once it's working again" )
4545 @ SneakyThrows
4646 @ Test
4747 void getTransactions_byExistingAccountId_withDateFilters_ok () {
@@ -50,8 +50,8 @@ void getTransactions_byExistingAccountId_withDateFilters_ok() {
5050
5151 // precondition: get account transactions (all results)
5252 Response <TransactionsResponse > allTransactionsResponse = client .service ()
53- .getTransactions (firstAccountId , new TransactionsSearchRequest ().pageSize (100 ))
54- .execute ();
53+ .getTransactions (firstAccountId , new TransactionsSearchRequest ().pageSize (100 ))
54+ .execute ();
5555
5656 TransactionsResponse allTransactionsResults = allTransactionsResponse .body ();
5757
@@ -65,35 +65,36 @@ void getTransactions_byExistingAccountId_withDateFilters_ok() {
6565
6666 int allTransactionsCount = allTransactions .size ();
6767 assertTrue (allTransactionsCount >= 3 ,
68- String .format ("Expected at least 3 txs for account id '%s', got tx(s): ['%s']" ,
69- firstAccountId , allTxsString ));
68+ String .format ("Expected at least 3 txs for account id '%s', got tx(s): ['%s']" ,
69+ firstAccountId , allTxsString ));
7070
71- // sort transactions result by date string, and extract a sub-range of dates from the total txs results
71+ // sort transactions result by date string, and extract a sub-range of dates
72+ // from the total txs results
7273 allTransactions .sort (Comparator .comparing (Transaction ::getDate ));
7374 String minDate = allTransactions .get (0 ).getDate ();
7475 String middleDate = allTransactions .get (Math .floorDiv (allTransactionsCount , 2 )).getDate ();
7576 String maxDate = allTransactions .get (allTransactionsCount - 1 ).getDate ();
7677 assertTrue (minDate .compareTo (maxDate ) < 0 ,
77- String .format ("expected min date '%s' of txs to be earlier than max date '%s'" ,
78- minDate , maxDate ));
78+ String .format ("expected min date '%s' of txs to be earlier than max date '%s'" ,
79+ minDate , maxDate ));
7980 assertTrue (minDate .compareTo (middleDate ) < 0 ,
80- String .format ("expected min date '%s' of txs to be earlier than middle date '%s'" ,
81- minDate , middleDate ));
81+ String .format ("expected min date '%s' of txs to be earlier than middle date '%s'" ,
82+ minDate , middleDate ));
8283 assertTrue (middleDate .compareTo (maxDate ) < 0 ,
83- String .format ("expected middle date '%s' of txs to be earlier than max date '%s'" ,
84- minDate , middleDate ));
84+ String .format ("expected middle date '%s' of txs to be earlier than max date '%s'" ,
85+ minDate , middleDate ));
8586
8687 // get account transactions with sub-range date filters
8788 String fromDateFilter = "2019-11-15" ;
8889 String toDateFilter = middleDate .substring (0 , 10 );
8990 TransactionsSearchRequest dateFilters = new TransactionsSearchRequest ()
90- .from (fromDateFilter )
91- .to (toDateFilter )
92- .pageSize (100 );
91+ .from (fromDateFilter )
92+ .to (toDateFilter )
93+ .pageSize (100 );
9394
9495 Response <TransactionsResponse > transactionsFilteredResponse = client .service ()
95- .getTransactions (firstAccountId , dateFilters )
96- .execute ();
96+ .getTransactions (firstAccountId , dateFilters )
97+ .execute ();
9798
9899 TransactionsResponse transactionsFiltered = transactionsFilteredResponse .body ();
99100
@@ -103,17 +104,17 @@ void getTransactions_byExistingAccountId_withDateFilters_ok() {
103104 int transactionsFilteredCount = transactionsFiltered .getResults ().size ();
104105
105106 String expectedTransactionsFilteredMsg = String .format (
106- "Expected at least 1 tx between '%s' (out of total '%d' txs) for account id '%s', all txs: '%s'" ,
107- dateFilters ,
108- allTransactionsCount , firstAccountId , allTxsString );
107+ "Expected at least 1 tx between '%s' (out of total '%d' txs) for account id '%s', all txs: '%s'" ,
108+ dateFilters ,
109+ allTransactionsCount , firstAccountId , allTxsString );
109110
110111 assertTrue (transactionsFilteredCount > 0 , expectedTransactionsFilteredMsg );
111112
112113 // expect filtered transactions count to be less than total transactions count
113114 assertTrue (transactionsFilteredCount < allTransactionsCount ,
114- String .format (
115- "Transactions filtered result: %d should be less than all transactions result: %d, using date filters '%s'" ,
116- transactionsFilteredCount , allTransactionsCount , dateFilters ));
115+ String .format (
116+ "Transactions filtered result: %d should be less than all transactions result: %d, using date filters '%s'" ,
117+ transactionsFilteredCount , allTransactionsCount , dateFilters ));
117118 }
118119
119120 @ SneakyThrows
@@ -126,12 +127,12 @@ void getTransactions_byExistingAccountId_withPageFilters_ok() {
126127 int pageSize = 2 ;
127128 int firstPage = 1 ;
128129 TransactionsSearchRequest firstPageParams = new TransactionsSearchRequest ()
129- .page (firstPage )
130- .pageSize (pageSize );
130+ .page (firstPage )
131+ .pageSize (pageSize );
131132
132133 Response <TransactionsResponse > firstPageResponse = client .service ()
133- .getTransactions (firstAccountId , firstPageParams )
134- .execute ();
134+ .getTransactions (firstAccountId , firstPageParams )
135+ .execute ();
135136
136137 // precondition: expect to have more txs present in the next page
137138 TransactionsResponse transactionsFirstPage = firstPageResponse .body ();
@@ -142,47 +143,46 @@ void getTransactions_byExistingAccountId_withPageFilters_ok() {
142143 Integer allTxsCount = transactionsFirstPage .getTotal ();
143144
144145 // expect to have more pages left
145- assertTrue (allTxsCount > firstPageTxsCount ,
146- String .format ("expected total '%d' txs count to be greater than first page txs "
147- + "count '%d', for account id '%s'" , allTxsCount , firstPageTxsCount , firstAccountId ));
146+ assertTrue (allTxsCount >= firstPageTxsCount ,
147+ String .format ("expected total '%d' txs count to be greater than first page txs "
148+ + "count '%d', for account id '%s'" , allTxsCount , firstPageTxsCount , firstAccountId ));
148149
149150 // expect first page to be complete (ie. to equal page size param)
150151 assertEquals (firstPageTxsCount , pageSize ,
151- String .format ("expected first page txs response count '%d' to equal the page size param '%d'" ,
152- firstPageTxsCount , pageSize ));
152+ String .format ("expected first page txs response count '%d' to equal the page size param '%d'" ,
153+ firstPageTxsCount , pageSize ));
153154
154155 // fetch next page
155156 TransactionsSearchRequest nextPageParams = new TransactionsSearchRequest ()
156- .page (firstPageParams .getPage () + 1 )
157- .pageSize (firstPageParams .getPageSize ());
157+ .page (firstPageParams .getPage () + 1 )
158+ .pageSize (firstPageParams .getPageSize ());
158159
159160 Response <TransactionsResponse > nextPageResponse = client .service ()
160- .getTransactions (firstAccountId , nextPageParams )
161- .execute ();
161+ .getTransactions (firstAccountId , nextPageParams )
162+ .execute ();
162163
163164 // expect second page to include results, and to be different than first page.
164165 TransactionsResponse transactionsNextPage = nextPageResponse .body ();
165166 assertNotNull (transactionsNextPage );
166167 List <Transaction > nextPageTransactions = transactionsNextPage .getResults ();
167168 assertTrue (nextPageTransactions .size () > 0 );
168169
169-
170170 // fetch transactions by ids
171171 Response <TransactionsResponse > transactionsbyIds = client .service ()
172- .getTransactions (firstAccountId , new TransactionsSearchRequest ().ids (Arrays .asList (nextPageTransactions .get (0 ).getId ())))
173- .execute ();
172+ .getTransactions (firstAccountId ,
173+ new TransactionsSearchRequest ().ids (Arrays .asList (nextPageTransactions .get (0 ).getId ())))
174+ .execute ();
174175 assertEquals (transactionsbyIds .body ().getResults ().size (), 1 );
175176
176-
177177 // expect first tx of next page to be different from the first page.
178178 assertNotEquals (nextPageTransactions .get (0 ).getId (),
179- firstPageTransactions .get (firstPageTxsCount - 1 ).getId ());
179+ firstPageTransactions .get (firstPageTxsCount - 1 ).getId ());
180180 }
181181
182182 private String transactionsToIdAndDateStrings (TransactionsResponse allTransactions ) {
183183 return allTransactions .getResults ().stream ()
184- .map (transaction -> String .format (
185- "{id=%s, date=%s}" , transaction .getId (), transaction .getDate ().substring (0 , 10 )))
186- .collect (Collectors .joining (", " ));
184+ .map (transaction -> String .format (
185+ "{id=%s, date=%s}" , transaction .getId (), transaction .getDate ().substring (0 , 10 )))
186+ .collect (Collectors .joining (", " ));
187187 }
188188}
0 commit comments