Search in sources :

Example 1 with BSFormatter

use of bisq.desktop.util.BSFormatter in project bisq-desktop by bisq-network.

the class OfferBookViewModelTest method testMaxCharactersForAmountRange.

@Test
public void testMaxCharactersForAmountRange() {
    OfferBook offerBook = mock(OfferBook.class);
    OpenOfferManager openOfferManager = mock(OpenOfferManager.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcItemWithRange));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null, null, null, null, null, new BSFormatter());
    model.activate();
    assertEquals(15, model.maxPlacesForAmount.intValue());
    offerBookListItems.addAll(make(btcItemWithRange.but(with(amount, 2000000000L))));
    assertEquals(16, model.maxPlacesForAmount.intValue());
    offerBookListItems.addAll(make(btcItemWithRange.but(with(minAmount, 30000000000L), with(amount, 30000000000L))));
    assertEquals(19, model.maxPlacesForAmount.intValue());
}
Also used : OpenOfferManager(bisq.core.offer.OpenOfferManager) BSFormatter(bisq.desktop.util.BSFormatter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with BSFormatter

use of bisq.desktop.util.BSFormatter in project bisq-desktop by bisq-network.

the class OfferBookViewModelTest method testMaxCharactersForVolume.

@Test
public void testMaxCharactersForVolume() {
    OfferBook offerBook = mock(OfferBook.class);
    OpenOfferManager openOfferManager = mock(OpenOfferManager.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcItem));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null, null, null, null, null, new BSFormatter());
    model.activate();
    assertEquals(8, model.maxPlacesForVolume.intValue());
    offerBookListItems.addAll(make(btcItem.but(with(amount, 2000000000L))));
    assertEquals(10, model.maxPlacesForVolume.intValue());
}
Also used : OpenOfferManager(bisq.core.offer.OpenOfferManager) BSFormatter(bisq.desktop.util.BSFormatter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with BSFormatter

use of bisq.desktop.util.BSFormatter in project bisq-desktop by bisq-network.

the class OfferBookViewModelTest method testMaxCharactersForAmount.

@Test
public void testMaxCharactersForAmount() {
    OfferBook offerBook = mock(OfferBook.class);
    OpenOfferManager openOfferManager = mock(OpenOfferManager.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcItem));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null, null, null, null, null, new BSFormatter());
    model.activate();
    assertEquals(6, model.maxPlacesForAmount.intValue());
    offerBookListItems.addAll(make(btcItem.but(with(amount, 2000000000L))));
    assertEquals(7, model.maxPlacesForAmount.intValue());
}
Also used : OpenOfferManager(bisq.core.offer.OpenOfferManager) BSFormatter(bisq.desktop.util.BSFormatter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with BSFormatter

use of bisq.desktop.util.BSFormatter in project bisq-desktop by bisq-network.

the class OfferBookViewModelTest method testMaxCharactersForPriceWithNoOffers.

@Test
public void testMaxCharactersForPriceWithNoOffers() {
    OfferBook offerBook = mock(OfferBook.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, null, null, null, null, null, new BSFormatter());
    assertEquals(0, model.maxPlacesForPrice.intValue());
}
Also used : BSFormatter(bisq.desktop.util.BSFormatter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with BSFormatter

use of bisq.desktop.util.BSFormatter in project bisq-desktop by bisq-network.

the class OfferBookViewModelTest method testMaxCharactersForAmountWithNoOffes.

@Test
public void testMaxCharactersForAmountWithNoOffes() {
    OfferBook offerBook = mock(OfferBook.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, null, null, null, null, null, new BSFormatter());
    assertEquals(0, model.maxPlacesForAmount.intValue());
}
Also used : BSFormatter(bisq.desktop.util.BSFormatter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BSFormatter (bisq.desktop.util.BSFormatter)27 Test (org.junit.Test)24 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)23 OfferBook (bisq.desktop.main.offer.offerbook.OfferBook)12 OfferBookListItem (bisq.desktop.main.offer.offerbook.OfferBookListItem)12 PriceFeedService (bisq.core.provider.price.PriceFeedService)9 OpenOfferManager (bisq.core.offer.OpenOfferManager)7 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)4 AddressEntry (bisq.core.btc.AddressEntry)2 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)2 MarketPrice (bisq.core.provider.price.MarketPrice)2 Popup (bisq.desktop.main.overlays.popups.Popup)2 Coin (org.bitcoinj.core.Coin)2 Transaction (org.bitcoinj.core.Transaction)2 AddressEntryException (bisq.core.btc.AddressEntryException)1 InsufficientFundsException (bisq.core.btc.InsufficientFundsException)1 TransactionVerificationException (bisq.core.btc.exceptions.TransactionVerificationException)1 WalletException (bisq.core.btc.exceptions.WalletException)1 BsqWalletService (bisq.core.btc.wallet.BsqWalletService)1 ChangeBelowDustException (bisq.core.btc.wallet.ChangeBelowDustException)1