use of io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method addAndRemoveTransactionRestriction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addAndRemoveTransactionRestriction(RepositoryType type) {
AccountOperationRestrictionFlags restrictionFlags = AccountOperationRestrictionFlags.BLOCK_OUTGOING_TRANSACTION_TYPE;
TransactionType transactionType = TransactionType.SECRET_PROOF;
Assertions.assertNotNull(get(getRepositoryFactory(type).createAccountRepository().getAccountInfo(testAccount.getAddress())));
if (hasRestriction(type, testAccount, restrictionFlags, transactionType)) {
System.out.println("Removing existing transaction restriction!");
sendAccountRestrictionTransaction(type, transactionType, false, restrictionFlags);
Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, transactionType));
}
System.out.println("Adding transaction restriction");
sendAccountRestrictionTransaction(type, transactionType, true, restrictionFlags);
Assertions.assertTrue(hasRestriction(type, testAccount, restrictionFlags, transactionType));
System.out.println("Removing transaction restriction");
sendAccountRestrictionTransaction(type, transactionType, false, restrictionFlags);
Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, transactionType));
}
use of io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags in project nem2-sdk-java by nemtech.
the class AccountOperationRestrictionTransactionMapper method createFactory.
@Override
protected AccountOperationRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountOperationRestrictionTransactionDTO transaction) {
AccountOperationRestrictionFlags restrictionFlags = AccountOperationRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
List<TransactionType> additions = transaction.getRestrictionAdditions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
List<TransactionType> deletions = transaction.getRestrictionDeletions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
return AccountOperationRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
use of io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags in project nem2-sdk-java by nemtech.
the class AccountOperationRestrictionTransactionMapper method createFactory.
@Override
protected AccountOperationRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountOperationRestrictionTransactionDTO transaction) {
AccountOperationRestrictionFlags restrictionFlags = AccountOperationRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
List<TransactionType> additions = transaction.getRestrictionAdditions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
List<TransactionType> deletions = transaction.getRestrictionDeletions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
return AccountOperationRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
Aggregations