Search in sources :

Example 11 with OfferBookListItem

use of bisq.desktop.main.offer.offerbook.OfferBookListItem in project bisq-desktop by bisq-network.

the class OfferBookChartViewModelTest method testMaxCharactersForSellVolumeWithNoOffers.

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

Example 12 with OfferBookListItem

use of bisq.desktop.main.offer.offerbook.OfferBookListItem in project bisq-desktop by bisq-network.

the class OfferBookChartViewModelTest method testMaxCharactersForSellVolume.

@Test
public void testMaxCharactersForSellVolume() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService service = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcSellItem));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, new BSFormatter());
    model.activate();
    // 0.01
    assertEquals(4, model.maxPlacesForSellVolume.intValue());
    offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.amount, 100000000L))));
    // 10.00
    assertEquals(5, model.maxPlacesForSellVolume.intValue());
    offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.amount, 22128600000L))));
    // 2212.86
    assertEquals(7, model.maxPlacesForSellVolume.intValue());
}
Also used : OfferBook(bisq.desktop.main.offer.offerbook.OfferBook) OfferBookListItem(bisq.desktop.main.offer.offerbook.OfferBookListItem) PriceFeedService(bisq.core.provider.price.PriceFeedService) BSFormatter(bisq.desktop.util.BSFormatter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with OfferBookListItem

use of bisq.desktop.main.offer.offerbook.OfferBookListItem in project bisq-desktop by bisq-network.

the class OfferBookChartViewModelTest method testMaxCharactersForSellPrice.

@Test
public void testMaxCharactersForSellPrice() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService service = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcSellItem));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, new BSFormatter());
    model.activate();
    assertEquals(7, model.maxPlacesForSellPrice.intValue());
    offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.price, 94016475L))));
    assertEquals(9, model.maxPlacesForSellPrice.intValue());
    offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.price, 101016475L))));
    assertEquals(10, model.maxPlacesForSellPrice.intValue());
}
Also used : OfferBook(bisq.desktop.main.offer.offerbook.OfferBook) OfferBookListItem(bisq.desktop.main.offer.offerbook.OfferBookListItem) PriceFeedService(bisq.core.provider.price.PriceFeedService) BSFormatter(bisq.desktop.util.BSFormatter) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with OfferBookListItem

use of bisq.desktop.main.offer.offerbook.OfferBookListItem in project bisq-desktop by bisq-network.

the class SpreadViewModelTest method testMaxCharactersForAmountWithNoOffers.

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

Aggregations

OfferBook (bisq.desktop.main.offer.offerbook.OfferBook)14 OfferBookListItem (bisq.desktop.main.offer.offerbook.OfferBookListItem)14 BSFormatter (bisq.desktop.util.BSFormatter)14 Test (org.junit.Test)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 PriceFeedService (bisq.core.provider.price.PriceFeedService)8 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)4 CurrencyUtil (bisq.core.locale.CurrencyUtil)2 Price (bisq.core.monetary.Price)2 Offer (bisq.core.offer.Offer)2 OfferPayload (bisq.core.offer.OfferPayload)2 ActivatableViewModel (bisq.desktop.common.model.ActivatableViewModel)2 GUIUtil (bisq.desktop.util.GUIUtil)2 Inject (com.google.inject.Inject)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 IntegerProperty (javafx.beans.property.IntegerProperty)2 FXCollections (javafx.collections.FXCollections)2 ListChangeListener (javafx.collections.ListChangeListener)2