From 68f67f5141fbf4d8cb06f86fe4f282c471fa6490 Mon Sep 17 00:00:00 2001 From: Kammerlo Date: Mon, 16 Dec 2024 16:18:37 +0100 Subject: [PATCH] fix: fixed tests --- .../rosetta/api/account/service/AccountServiceImpl.java | 2 +- .../api/account/service/AccountServiceImplTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImpl.java b/api/src/main/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImpl.java index 02c2c3f1..b70a257f 100644 --- a/api/src/main/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImpl.java +++ b/api/src/main/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImpl.java @@ -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 accountBalanceResponseAmounts = accountBalanceResponse.getBalances(); accountBalanceResponseAmounts.removeIf(b -> currencies.stream().noneMatch(c -> c.getSymbol().equals(b.getCurrency().getSymbol()))); diff --git a/api/src/test/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImplTest.java b/api/src/test/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImplTest.java index 673c52cc..019508e3 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImplTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/api/account/service/AccountServiceImplTest.java @@ -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); @@ -118,6 +119,7 @@ void getAccountBalanceStakeAddressPositiveTest() { .findBalanceByStakeAddressAndBlock(accountAddress, 1L); verify(accountBalanceRequest).getAccountIdentifier(); verify(accountBalanceRequest).getBlockIdentifier(); + verify(accountBalanceRequest).getCurrencies(); verifyNoMoreInteractions(ledgerAccountService); verifyNoMoreInteractions(accountBalanceRequest); verifyNoMoreInteractions(accountIdentifier); @@ -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); @@ -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); @@ -209,6 +213,7 @@ void getAccountBalanceStakeAddressWithEmptyBalancesThrowTest() { .findBalanceByStakeAddressAndBlock(accountAddress, 1L); verify(accountBalanceRequest).getAccountIdentifier(); verify(accountBalanceRequest).getBlockIdentifier(); + verify(accountBalanceRequest).getCurrencies(); verifyNoMoreInteractions(ledgerAccountService); verifyNoMoreInteractions(accountBalanceRequest); verifyNoMoreInteractions(accountIdentifier); @@ -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); @@ -278,6 +284,7 @@ void getAccountBalanceWithStakeAddressAndNullBalanceThrowTest() { .findBalanceByStakeAddressAndBlock(accountAddress, 1L); verify(accountBalanceRequest).getAccountIdentifier(); verify(accountBalanceRequest).getBlockIdentifier(); + verify(accountBalanceRequest).getCurrencies(); verifyNoMoreInteractions(ledgerAccountService); verifyNoMoreInteractions(accountBalanceRequest); verifyNoMoreInteractions(accountIdentifier);