Skip to content

Commit

Permalink
fix: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kammerlo committed Dec 16, 2024
1 parent f664788 commit 68f67f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private AccountBalanceResponse findBalanceDataByAddressAndBlock(String address,
}
AccountBalanceResponse accountBalanceResponse = accountMapper.mapToAccountBalanceResponse(
blockDto, balances);
if (Objects.nonNull(currencies)) {
if (Objects.nonNull(currencies) && !currencies.isEmpty()) {
validateCurrencies(currencies);
List<Amount> accountBalanceResponseAmounts = accountBalanceResponse.getBalances();
accountBalanceResponseAmounts.removeIf(b -> currencies.stream().noneMatch(c -> c.getSymbol().equals(b.getCurrency().getSymbol())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void getAccountBalanceNoStakeAddressPositiveTest() {
verify(ledgerAccountService).findBalanceByAddressAndBlock(accountAddress, 1L);
verify(accountBalanceRequest).getAccountIdentifier();
verify(accountBalanceRequest).getBlockIdentifier();
verify(accountBalanceRequest).getCurrencies();
verifyNoMoreInteractions(ledgerAccountService);
verifyNoMoreInteractions(accountBalanceRequest);
verifyNoMoreInteractions(accountIdentifier);
Expand Down Expand Up @@ -118,6 +119,7 @@ void getAccountBalanceStakeAddressPositiveTest() {
.findBalanceByStakeAddressAndBlock(accountAddress, 1L);
verify(accountBalanceRequest).getAccountIdentifier();
verify(accountBalanceRequest).getBlockIdentifier();
verify(accountBalanceRequest).getCurrencies();
verifyNoMoreInteractions(ledgerAccountService);
verifyNoMoreInteractions(accountBalanceRequest);
verifyNoMoreInteractions(accountIdentifier);
Expand Down Expand Up @@ -156,6 +158,7 @@ void getAccountBalanceNoStakeAddressNullBlockIdentifierPositiveTest() {
// Shelly testnet address
String accountAddress = "addr_test1vru64wlzn85v7fecg0mz33lh00wlggqtquvzzuhf6vusyes32jz9w";
AccountBalanceRequest accountBalanceRequest = Mockito.mock(AccountBalanceRequest.class);

AccountIdentifier accountIdentifier = Mockito.mock(AccountIdentifier.class);
when(accountBalanceRequest.getAccountIdentifier()).thenReturn(accountIdentifier);
when(accountIdentifier.getAddress()).thenReturn(accountAddress);
Expand All @@ -180,6 +183,7 @@ void getAccountBalanceNoStakeAddressNullBlockIdentifierPositiveTest() {
verify(ledgerAccountService).findBalanceByAddressAndBlock(accountAddress, 1L);
verify(accountBalanceRequest).getAccountIdentifier();
verify(accountBalanceRequest).getBlockIdentifier();
verify(accountBalanceRequest).getCurrencies();
verifyNoMoreInteractions(ledgerAccountService);
verifyNoMoreInteractions(accountBalanceRequest);
verifyNoMoreInteractions(accountIdentifier);
Expand Down Expand Up @@ -209,6 +213,7 @@ void getAccountBalanceStakeAddressWithEmptyBalancesThrowTest() {
.findBalanceByStakeAddressAndBlock(accountAddress, 1L);
verify(accountBalanceRequest).getAccountIdentifier();
verify(accountBalanceRequest).getBlockIdentifier();
verify(accountBalanceRequest).getCurrencies();
verifyNoMoreInteractions(ledgerAccountService);
verifyNoMoreInteractions(accountBalanceRequest);
verifyNoMoreInteractions(accountIdentifier);
Expand All @@ -231,6 +236,7 @@ void getAccountBalanceStakeAddressWithBlockDtoNullThrowTest() {
verify(ledgerBlockService).findBlockIdentifier(1L, HASH);
verify(accountBalanceRequest).getAccountIdentifier();
verify(accountBalanceRequest).getBlockIdentifier();
verify(accountBalanceRequest).getCurrencies();
verifyNoMoreInteractions(ledgerAccountService);
verifyNoMoreInteractions(accountBalanceRequest);
verifyNoMoreInteractions(accountIdentifier);
Expand Down Expand Up @@ -278,6 +284,7 @@ void getAccountBalanceWithStakeAddressAndNullBalanceThrowTest() {
.findBalanceByStakeAddressAndBlock(accountAddress, 1L);
verify(accountBalanceRequest).getAccountIdentifier();
verify(accountBalanceRequest).getBlockIdentifier();
verify(accountBalanceRequest).getCurrencies();
verifyNoMoreInteractions(ledgerAccountService);
verifyNoMoreInteractions(accountBalanceRequest);
verifyNoMoreInteractions(accountIdentifier);
Expand Down

0 comments on commit 68f67f5

Please sign in to comment.