Search in sources :

Example 1 with OfferBook

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

the class OfferBookChartViewModelTest method testMaxCharactersForBuyPriceWithNoOffers.

@Test
public void testMaxCharactersForBuyPriceWithNoOffers() {
    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.maxPlacesForBuyPrice.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 2 with OfferBook

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

the class OfferBookChartViewModelTest method testMaxCharactersForSellPriceWithNoOffers.

@Test
public void testMaxCharactersForSellPriceWithNoOffers() {
    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.maxPlacesForSellPrice.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 3 with OfferBook

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

the class OfferBookChartViewModelTest method testMaxCharactersForBuyPrice.

@Test
public void testMaxCharactersForBuyPrice() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService service = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcItem));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, new BSFormatter());
    model.activate();
    assertEquals(7, model.maxPlacesForBuyPrice.intValue());
    offerBookListItems.addAll(make(btcItem.but(with(OfferBookListItemMaker.price, 94016475L))));
    assertEquals(9, model.maxPlacesForBuyPrice.intValue());
    offerBookListItems.addAll(make(btcItem.but(with(OfferBookListItemMaker.price, 101016475L))));
    assertEquals(10, model.maxPlacesForBuyPrice.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 4 with OfferBook

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

the class OfferBookChartViewModelTest method testMaxCharactersForBuyVolume.

@Test
public void testMaxCharactersForBuyVolume() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService service = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcItem));
    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
    final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, new BSFormatter());
    model.activate();
    // 0.01
    assertEquals(4, model.maxPlacesForBuyVolume.intValue());
    offerBookListItems.addAll(make(btcItem.but(with(OfferBookListItemMaker.amount, 100000000L))));
    // 10.00
    assertEquals(5, model.maxPlacesForBuyVolume.intValue());
    offerBookListItems.addAll(make(btcItem.but(with(OfferBookListItemMaker.amount, 22128600000L))));
    // 2212.86
    assertEquals(7, model.maxPlacesForBuyVolume.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 5 with OfferBook

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

the class OfferBookChartViewModelTest method testMaxCharactersForBuyPriceWithOfflinePriceFeedService.

@Test
public void testMaxCharactersForBuyPriceWithOfflinePriceFeedService() {
    OfferBook offerBook = mock(OfferBook.class);
    PriceFeedService priceFeedService = mock(PriceFeedService.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    final OfferBookListItem item = make(OfferBookListItemMaker.btcItem.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.maxPlacesForBuyPrice.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)

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