Search in sources :

Example 6 with OfferBook

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

the class SpreadViewModelTest method testMaxCharactersForAmount.

@Test
public void testMaxCharactersForAmount() {
    OfferBook offerBook = mock(OfferBook.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcItem));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final SpreadViewModel model = new SpreadViewModel(offerBook, null, new BSFormatter());
    model.activate();
    // 0.001
    assertEquals(6, model.maxPlacesForAmount.intValue());
    offerBookListItems.addAll(make(btcItem.but(with(OfferBookListItemMaker.amount, 1403000000L))));
    // 14.0300
    assertEquals(7, 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)

Example 7 with OfferBook

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

the class OfferBookChartViewModelTest method testMaxCharactersForBuyVolumeWithNoOffers.

@Test
public void testMaxCharactersForBuyVolumeWithNoOffers() {
    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.maxPlacesForBuyVolume.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 8 with OfferBook

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

the class OfferBookChartViewModelTest method testMaxCharactersForSellPriceWithOfflinePriceFeedService.

@Test
public void testMaxCharactersForSellPriceWithOfflinePriceFeedService() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService priceFeedService = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    final OfferBookListItem item = make(OfferBookListItemMaker.btcSellItem.but(with(OfferBookListItemMaker.useMarketBasedPrice, true)));
    item.getOffer().setPriceFeedService(priceFeedService);
    offerBookListItems.addAll(item);
    when(priceFeedService.getMarketPrice(anyString())).thenReturn(null);
    when(priceFeedService.updateCounterProperty()).thenReturn(new SimpleIntegerProperty());
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, priceFeedService, null, new BSFormatter());
    model.activate();
    assertEquals(0, 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) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with OfferBook

use of bisq.desktop.main.offer.offerbook.OfferBook 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 10 with OfferBook

use of bisq.desktop.main.offer.offerbook.OfferBook 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)

Aggregations

OfferBook (bisq.desktop.main.offer.offerbook.OfferBook)12 OfferBookListItem (bisq.desktop.main.offer.offerbook.OfferBookListItem)12 BSFormatter (bisq.desktop.util.BSFormatter)12 Test (org.junit.Test)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 PriceFeedService (bisq.core.provider.price.PriceFeedService)6 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)2