use of bisq.core.offer.OpenOfferManager in project bisq-desktop by bisq-network.
the class OfferBookViewModelTest method testMaxCharactersForVolumeRange.
@Test
public void testMaxCharactersForVolumeRange() {
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.maxPlacesForVolume.intValue());
offerBookListItems.addAll(make(btcItemWithRange.but(with(amount, 2000000000L))));
assertEquals(17, model.maxPlacesForVolume.intValue());
offerBookListItems.addAll(make(btcItemWithRange.but(with(minAmount, 30000000000L), with(amount, 30000000000L))));
assertEquals(25, model.maxPlacesForVolume.intValue());
}
use of bisq.core.offer.OpenOfferManager in project bisq-desktop by bisq-network.
the class OfferBookViewModelTest method testGetPrice.
@Test
public void testGetPrice() {
OfferBook offerBook = mock(OfferBook.class);
OpenOfferManager openOfferManager = mock(OpenOfferManager.class);
PriceFeedService priceFeedService = mock(PriceFeedService.class);
final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true));
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null, null, null, null, null, new BSFormatter());
final OfferBookListItem item = make(btcItem.but(with(useMarketBasedPrice, true), with(marketPriceMargin, -0.12)));
final OfferBookListItem lowItem = make(btcItem.but(with(useMarketBasedPrice, true), with(marketPriceMargin, 0.01)));
final OfferBookListItem fixedItem = make(btcItem);
item.getOffer().setPriceFeedService(priceFeedService);
lowItem.getOffer().setPriceFeedService(priceFeedService);
offerBookListItems.addAll(lowItem, fixedItem);
model.activate();
assertEquals("12557.2046 (1.00%)", model.getPrice(lowItem));
assertEquals(" 10.0000 ", model.getPrice(fixedItem));
offerBookListItems.addAll(item);
assertEquals("14206.1304 (-12.00%)", model.getPrice(item));
assertEquals("12557.2046 (1.00%)", model.getPrice(lowItem));
}
Aggregations