Search in sources :

Example 1 with AccountAddressRestrictionFlags

use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags in project nem2-sdk-java by nemtech.

the class AccountRestrictionIntegrationTest method addAndRemoveAddressRestriction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addAndRemoveAddressRestriction(RepositoryType type) {
    AccountAddressRestrictionFlags restrictionFlags = AccountAddressRestrictionFlags.ALLOW_OUTGOING_ADDRESS;
    Address address = getRecipient();
    Assertions.assertNotNull(get(getRepositoryFactory(type).createAccountRepository().getAccountInfo(testAccount.getAddress())));
    if (hasRestriction(type, testAccount, restrictionFlags, address)) {
        System.out.println("Removing existing address restriction!");
        sendAccountRestrictionAddress(type, address, false, restrictionFlags);
        Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, address));
    }
    System.out.println("Adding address restriction");
    sendAccountRestrictionAddress(type, address, true, restrictionFlags);
    Assertions.assertTrue(hasRestriction(type, testAccount, restrictionFlags, address));
    System.out.println("Removing address restriction");
    sendAccountRestrictionAddress(type, address, false, restrictionFlags);
    Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, address));
}
Also used : UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) Address(io.nem.symbol.sdk.model.account.Address) AccountAddressRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with AccountAddressRestrictionFlags

use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags in project nem2-sdk-java by nemtech.

the class AccountAddressRestrictionTransactionMapper method createFactory.

@Override
protected AccountAddressRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountAddressRestrictionTransactionDTO transaction) {
    AccountAddressRestrictionFlags restrictionFlags = AccountAddressRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
    List<UnresolvedAddress> restrictionAdditions = transaction.getRestrictionAdditions().stream().map(MapperUtils::toUnresolvedAddress).collect(Collectors.toList());
    List<UnresolvedAddress> restrictionDeletions = transaction.getRestrictionDeletions().stream().map(MapperUtils::toUnresolvedAddress).collect(Collectors.toList());
    return AccountAddressRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, restrictionAdditions, restrictionDeletions);
}
Also used : UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) AccountAddressRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags)

Example 3 with AccountAddressRestrictionFlags

use of io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags in project nem2-sdk-java by nemtech.

the class AccountAddressRestrictionTransactionMapper method createFactory.

@Override
protected AccountAddressRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountAddressRestrictionTransactionDTO transaction) {
    AccountAddressRestrictionFlags restrictionFlags = AccountAddressRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
    List<UnresolvedAddress> restrictionAdditions = transaction.getRestrictionAdditions().stream().map(MapperUtils::toUnresolvedAddress).collect(Collectors.toList());
    List<UnresolvedAddress> restrictionDeletions = transaction.getRestrictionDeletions().stream().map(MapperUtils::toUnresolvedAddress).collect(Collectors.toList());
    return AccountAddressRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, restrictionAdditions, restrictionDeletions);
}
Also used : UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) AccountAddressRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags)

Aggregations

UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)3 AccountAddressRestrictionFlags (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags)3 Address (io.nem.symbol.sdk.model.account.Address)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1