Search in sources :

Example 1 with AccountOperationRestrictionFlags

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));
}
Also used : AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with AccountOperationRestrictionFlags

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);
}
Also used : Deadline(io.nem.symbol.sdk.model.transaction.Deadline) List(java.util.List) AccountRestrictionFlagsEnum(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionFlagsEnum) AccountOperationRestrictionTransactionDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountOperationRestrictionTransactionDTO) JsonHelper(io.nem.symbol.sdk.model.transaction.JsonHelper) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) TransactionTypeEnum(io.nem.symbol.sdk.openapi.vertx.model.TransactionTypeEnum) Collectors(java.util.stream.Collectors) AccountOperationRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransactionFactory) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType)

Example 3 with AccountOperationRestrictionFlags

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);
}
Also used : AccountRestrictionFlagsEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionFlagsEnum) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) List(java.util.List) AccountOperationRestrictionTransactionDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountOperationRestrictionTransactionDTO) JsonHelper(io.nem.symbol.sdk.model.transaction.JsonHelper) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) TransactionTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionTypeEnum) Collectors(java.util.stream.Collectors) AccountOperationRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransactionFactory) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType)

Aggregations

AccountOperationRestrictionFlags (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags)3 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)3 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)2 AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)2 AccountOperationRestrictionTransactionFactory (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransactionFactory)2 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)2 JsonHelper (io.nem.symbol.sdk.model.transaction.JsonHelper)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 AccountOperationRestrictionTransactionDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountOperationRestrictionTransactionDTO)1 AccountRestrictionFlagsEnum (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionFlagsEnum)1 TransactionTypeEnum (io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionTypeEnum)1 AccountOperationRestrictionTransactionDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountOperationRestrictionTransactionDTO)1 AccountRestrictionFlagsEnum (io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionFlagsEnum)1 TransactionTypeEnum (io.nem.symbol.sdk.openapi.vertx.model.TransactionTypeEnum)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1