@Test public void test_OK() throws Exception { when(assetIssuingTransactionDao.getNumberOfIssuedAssets(assetPublicKey)).thenReturn(5); int issuedAssets = digitalAssetCryptoTransactionFactory.getNumberOfIssuedAssets(assetPublicKey); assertThat(issuedAssets).isEqualTo(5); }
@Test public void test_Throws_CantCheckAssetIssuingProgressException() throws Exception { when(assetIssuingTransactionDao.getNumberOfIssuedAssets(assetPublicKey)).thenCallRealMethod(); doThrow(new CantOpenDatabaseException("error")).when(database).openDatabase(); catchException(digitalAssetCryptoTransactionFactory).getNumberOfIssuedAssets(assetPublicKey); Exception thrown = caughtException(); assertThat(thrown).isNotNull().isInstanceOf(CantCheckAssetIssuingProgressException.class); assertThat(thrown.getCause()).isInstanceOf(CantOpenDatabaseException.class); }