private void setUpMockitoRules() throws Exception {

    when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory);
    when(mockDatabaseTable.getEmptyRecord()).thenReturn(mockDatabaseTableRecord);
    when(mockDatabase.getTable(
            AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_TABLE_NAME))
        .thenReturn(mockDatabaseTable);
    when(mockDatabase.getTable(
            AssetIssuingTransactionDatabaseConstants
                .DIGITAL_ASSET_TRANSACTION_ASSET_ISSUING_TABLE_NAME))
        .thenReturn(mockDatabaseTable2);
    when(mockDatabaseTable2.getEmptyRecord()).thenReturn(mockDatabaseTableRecord);
    when(mockDatabaseTable2.getRecords()).thenReturn(records);
    when(pluginDatabaseSystem.openDatabase(
            pluginId, AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_DATABASE))
        .thenReturn(mockDatabase);

    when(deviceUser.getPublicKey()).thenReturn("myPublicKey");
    when(deviceUserManager.getLoggedInDeviceUser()).thenReturn(deviceUser);

    when(actorAssetIssuerManager.getActorAssetIssuer()).thenReturn(actorAssetIssuer);

    when(eventManager.getNewListener(
            EventType.INCOMING_ASSET_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER))
        .thenReturn(fermatEventListener1);
    when(eventManager.getNewListener(
            EventType.INCOMING_ASSET_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER))
        .thenReturn(fermatEventListener2);
    when(eventManager.getNewListener(
            EventType.INCOMING_ASSET_REVERSED_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER))
        .thenReturn(fermatEventListener3);
    when(eventManager.getNewListener(
            EventType.INCOMING_ASSET_REVERSED_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER))
        .thenReturn(fermatEventListener4);

    when(pluginFileSystem.createTextFile(
            this.pluginId,
            "digital-asset-issuing/publicKey",
            "name.xml",
            FilePrivacy.PUBLIC,
            FileLifeSpan.PERMANENT))
        .thenReturn(pluginTextFile);
    when(bitcoinWalletManager.loadWallet(this.walletPublicKey)).thenReturn(bitcoinWalletWallet);
    when(bitcoinWalletWallet.getBalance(BalanceType.AVAILABLE)).thenReturn(bitcoinWalletBalance);
    when(bitcoinWalletBalance.getBalance()).thenReturn(bitcoinWalletAvailableBalance);
    when(assetVaultManager.getNewAssetVaultCryptoAddress(this.blockchainNetworkType))
        .thenReturn(cryptoAddress);
    //        doNothing().when(assetIssuingPluginRoot).issueAssets(digitalAsset, 1, walletPublicKey,
    // blockchainNetworkType);
  }
Exemplo n.º 2
0
 public static boolean isAvailableBalanceInAssetVault(
     AssetVaultManager assetVaultManager, long genesisAmount, String genesisTransaction) {
   long availableBalanceForTransaction =
       assetVaultManager.getAvailableBalanceForTransaction(genesisTransaction);
   return availableBalanceForTransaction < genesisAmount;
 }