@Override public Balance getBalance() { Balance balance = new Balance(); balance.setAmount(new BigDecimal(local.getBalance())); return balance; }
@Test public void test_Update_Balance() throws Exception { Balance balance = new Balance(); balanceObserverCaptor.getValue().onChanged(balance); verify(balanceView).updateBalance(0); balance.setAmount(new BigDecimal(30)); balanceObserverCaptor.getValue().onChanged(balance); verify(balanceView).updateBalance(30); }
@Test public void purchase_Spend_Failed_Insufficient_Kin() throws Exception { final CountDownLatch countDownLatch = new CountDownLatch(1); when(remote.createExternalOrderSync(anyString())).thenReturn(openOrder); when(openOrder.getOfferType()).thenReturn(OfferType.SPEND); when(blockchainSource.getBalance()).thenReturn(new Balance(new BigDecimal(3))); orderRepository.purchase("generatedOfferJWT", new KinCallback<OrderConfirmation>() { @Override public void onResponse(OrderConfirmation response) { } @Override public void onFailure(KinEcosystemException exception) { countDownLatch.countDown(); assertTrue(exception instanceof BlockchainException); assertEquals(INSUFFICIENT_KIN, exception.getCode()); } }); Thread.sleep(500); ShadowLooper.runUiThreadTasks(); verify(remote).cancelOrderSync(anyString()); countDownLatch.await(500, TimeUnit.MICROSECONDS); }
@Before public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); resetInstance(); when(offer.getId()).thenReturn(offerID); when(openOrder.getId()).thenReturn(orderID); when(openOrder.getOfferId()).thenReturn(offerID); when(openOrder.getAmount()).thenReturn(11); when(openOrder.getBlockchainData()).thenReturn(blockchainData); when(order.getOrderId()).thenReturn(orderID); when(order.getOfferId()).thenReturn(offerID); when(blockchainData.getRecipientAddress()).thenReturn("recipientAddress"); when(blockchainData.getSenderAddress()).thenReturn("senderAddress"); when(blockchainData.getTransactionId()).thenReturn("someTransactionHash"); when(payment.getOrderID()).thenReturn(orderID); when(payment.isSucceed()).thenReturn(true); when(payment.getTransactionID()).thenReturn("transactionID"); when(blockchainSource.getBalance()).thenReturn(new Balance(new BigDecimal(9999))); }