### Question:
SpreadViewModel extends ActivatableViewModel { @Override protected void activate() { offerBookListItems.addListener(listChangeListener); offerBook.fillOfferBookListItems(); update(offerBookListItems); } @Inject  SpreadViewModel(OfferBook offerBook, PriceFeedService priceFeedService, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter); String getAmount(Coin amount);  }### Answer:
@Test public void testMaxCharactersForAmount() { OfferBook offerBook = mock(OfferBook.class); final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList(); offerBookListItems.addAll(make(btcBuyItem)); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); SpreadViewModel model = new SpreadViewModel(offerBook, null, coinFormatter); model.activate(); assertEquals(6, model.maxPlacesForAmount.intValue()); offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.amount, 1403000000L)))); assertEquals(7, model.maxPlacesForAmount.intValue()); }
@Test public void testFilterSpreadItemsForUniqueOffers() { OfferBook offerBook = mock(OfferBook.class); PriceFeedService priceFeedService = mock(PriceFeedService.class); final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList(); offerBookListItems.addAll(make(btcBuyItem)); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); SpreadViewModel model = new SpreadViewModel(offerBook, priceFeedService, coinFormatter); model.activate(); assertEquals(1, model.spreadItems.get(0).numberOfOffers); offerBookListItems.addAll(make(btcBuyItem.but(with(id, "2345"))), make(btcBuyItem.but(with(id, "2345"))), make(btcSellItem.but(with(id, "3456"))), make(btcSellItem.but(with(id, "3456")))); assertEquals(2, model.spreadItems.get(0).numberOfBuyOffers); assertEquals(1, model.spreadItems.get(0).numberOfSellOffers); assertEquals(3, model.spreadItems.get(0).numberOfOffers); }