From 909216070083f2f2e08a80eba949129d78933b34 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Fri, 15 Nov 2019 00:03:52 -0500 Subject: [PATCH] Adjust tests to new params --- .../bisq/core/offer/OpenOfferManagerTest.java | 6 +++--- .../createoffer/CreateOfferDataModelTest.java | 13 +++++++------ .../createoffer/CreateOfferViewModelTest.java | 15 +++++++++------ .../editoffer/EditOfferDataModelTest.java | 11 ++++++++--- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java b/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java index c80ea13e0e..db2f334ded 100644 --- a/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java +++ b/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java @@ -37,7 +37,7 @@ public class OpenOfferManagerTest { when(p2PService.getPeerManager()).thenReturn(mock(PeerManager.class)); - final OpenOfferManager manager = new OpenOfferManager(null, null, p2PService, + final OpenOfferManager manager = new OpenOfferManager(null, null, null, p2PService, null, null, null, offerBookService, null, null, null, null, null, null, null, null, @@ -73,7 +73,7 @@ public class OpenOfferManagerTest { when(p2PService.getPeerManager()).thenReturn(mock(PeerManager.class)); - final OpenOfferManager manager = new OpenOfferManager(null, null, p2PService, + final OpenOfferManager manager = new OpenOfferManager(null, null, null, p2PService, null, null, null, offerBookService, null, null, null, null, null, null, null, null, @@ -101,7 +101,7 @@ public class OpenOfferManagerTest { when(p2PService.getPeerManager()).thenReturn(mock(PeerManager.class)); - final OpenOfferManager manager = new OpenOfferManager(null, null, p2PService, + final OpenOfferManager manager = new OpenOfferManager(null, null, null, p2PService, null, null, null, offerBookService, null, null, null, null, null, null, null, null, diff --git a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferDataModelTest.java b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferDataModelTest.java index e588735a91..4d58655dcc 100644 --- a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferDataModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferDataModelTest.java @@ -2,13 +2,13 @@ package bisq.desktop.main.offer.createoffer; import bisq.desktop.main.offer.MakerFeeProvider; -import bisq.core.btc.TxFeeEstimationService; import bisq.core.btc.model.AddressEntry; import bisq.core.btc.wallet.BtcWalletService; import bisq.core.locale.CryptoCurrency; import bisq.core.locale.FiatCurrency; import bisq.core.locale.GlobalSettings; import bisq.core.locale.Res; +import bisq.core.offer.CreateOfferService; import bisq.core.offer.OfferPayload; import bisq.core.payment.ClearXchangeAccount; import bisq.core.payment.PaymentAccount; @@ -21,6 +21,7 @@ import bisq.core.user.User; import org.bitcoinj.core.Coin; import java.util.HashSet; +import java.util.UUID; import org.junit.Before; import org.junit.Test; @@ -48,20 +49,20 @@ public class CreateOfferDataModelTest { BtcWalletService btcWalletService = mock(BtcWalletService.class); PriceFeedService priceFeedService = mock(PriceFeedService.class); FeeService feeService = mock(FeeService.class); - TxFeeEstimationService feeEstimationService = mock(TxFeeEstimationService.class); + CreateOfferService createOfferService = mock(CreateOfferService.class); preferences = mock(Preferences.class); user = mock(User.class); when(btcWalletService.getOrCreateAddressEntry(anyString(), any())).thenReturn(addressEntry); when(preferences.isUsePercentageBasedPrice()).thenReturn(true); when(preferences.getBuyerSecurityDepositAsPercent(null)).thenReturn(0.01); + when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString()); makerFeeProvider = mock(MakerFeeProvider.class); - model = new CreateOfferDataModel(null, btcWalletService, + model = new CreateOfferDataModel(createOfferService, null, btcWalletService, null, preferences, user, null, - null, priceFeedService, null, - null, feeService, feeEstimationService, - null, null, makerFeeProvider, null); + priceFeedService, null, + feeService, null, makerFeeProvider, null); } @Test diff --git a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java index 515126304c..149f39a892 100644 --- a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java @@ -24,7 +24,6 @@ import bisq.desktop.util.validation.FiatPriceValidator; import bisq.desktop.util.validation.SecurityDepositValidator; import bisq.core.account.witness.AccountAgeWitnessService; -import bisq.core.btc.TxFeeEstimationService; import bisq.core.btc.model.AddressEntry; import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BtcWalletService; @@ -32,6 +31,7 @@ import bisq.core.locale.Country; import bisq.core.locale.CryptoCurrency; import bisq.core.locale.GlobalSettings; import bisq.core.locale.Res; +import bisq.core.offer.CreateOfferService; import bisq.core.offer.OfferPayload; import bisq.core.payment.PaymentAccount; import bisq.core.provider.fee.FeeService; @@ -51,6 +51,8 @@ import javafx.collections.FXCollections; import java.time.Instant; +import java.util.UUID; + import org.junit.Before; import org.junit.Test; @@ -89,7 +91,7 @@ public class CreateOfferViewModelTest { BsqWalletService bsqWalletService = mock(BsqWalletService.class); SecurityDepositValidator securityDepositValidator = mock(SecurityDepositValidator.class); AccountAgeWitnessService accountAgeWitnessService = mock(AccountAgeWitnessService.class); - TxFeeEstimationService txFeeEstimationService = mock(TxFeeEstimationService.class); + CreateOfferService createOfferService = mock(CreateOfferService.class); when(btcWalletService.getOrCreateAddressEntry(anyString(), any())).thenReturn(addressEntry); when(btcWalletService.getBalanceForAddress(any())).thenReturn(Coin.valueOf(1000L)); @@ -103,11 +105,12 @@ public class CreateOfferViewModelTest { when(preferences.getUserCountry()).thenReturn(new Country("ES", "Spain", null)); when(bsqFormatter.formatCoin(any())).thenReturn("0"); when(bsqWalletService.getAvailableConfirmedBalance()).thenReturn(Coin.ZERO); + when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString()); - CreateOfferDataModel dataModel = new CreateOfferDataModel(null, btcWalletService, - bsqWalletService, empty, user, null, null, priceFeedService, null, - accountAgeWitnessService, feeService, txFeeEstimationService, - null, bsFormatter, mock(MakerFeeProvider.class), null); + CreateOfferDataModel dataModel = new CreateOfferDataModel(createOfferService, null, btcWalletService, + bsqWalletService, empty, user, null, priceFeedService, + accountAgeWitnessService, feeService, + bsFormatter, mock(MakerFeeProvider.class), null); dataModel.initWithData(OfferPayload.Direction.BUY, new CryptoCurrency("BTC", "bitcoin")); dataModel.activate(); diff --git a/desktop/src/test/java/bisq/desktop/main/portfolio/editoffer/EditOfferDataModelTest.java b/desktop/src/test/java/bisq/desktop/main/portfolio/editoffer/EditOfferDataModelTest.java index d95ba36bc7..2ee6a5bfde 100644 --- a/desktop/src/test/java/bisq/desktop/main/portfolio/editoffer/EditOfferDataModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/portfolio/editoffer/EditOfferDataModelTest.java @@ -11,6 +11,7 @@ import bisq.core.locale.Country; import bisq.core.locale.CryptoCurrency; import bisq.core.locale.GlobalSettings; import bisq.core.locale.Res; +import bisq.core.offer.CreateOfferService; import bisq.core.offer.OfferPayload; import bisq.core.offer.OpenOffer; import bisq.core.payment.CryptoCurrencyAccount; @@ -32,6 +33,8 @@ import javafx.collections.FXCollections; import java.time.Instant; +import java.util.UUID; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -75,6 +78,7 @@ public class EditOfferDataModelTest { BsqWalletService bsqWalletService = mock(BsqWalletService.class); SecurityDepositValidator securityDepositValidator = mock(SecurityDepositValidator.class); AccountAgeWitnessService accountAgeWitnessService = mock(AccountAgeWitnessService.class); + CreateOfferService createOfferService = mock(CreateOfferService.class); when(btcWalletService.getOrCreateAddressEntry(anyString(), any())).thenReturn(addressEntry); when(btcWalletService.getBalanceForAddress(any())).thenReturn(Coin.valueOf(1000L)); @@ -88,12 +92,13 @@ public class EditOfferDataModelTest { when(preferences.getUserCountry()).thenReturn(new Country("US", "United States", null)); when(bsqFormatter.formatCoin(any())).thenReturn("0"); when(bsqWalletService.getAvailableConfirmedBalance()).thenReturn(Coin.ZERO); + when(createOfferService.getRandomOfferId()).thenReturn(UUID.randomUUID().toString()); - model = new EditOfferDataModel(null, + model = new EditOfferDataModel(createOfferService, null, btcWalletService, bsqWalletService, empty, user, - null, null, priceFeedService, null, + null, priceFeedService, accountAgeWitnessService, feeService, null, null, - null, null, mock(MakerFeeProvider.class), null); + mock(MakerFeeProvider.class), null); } @Test