use of io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionFlags in project nem2-sdk-java by nemtech.
the class AccountMosaicRestrictionTransactionMapper method createFactory.
@Override
protected AccountMosaicRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountMosaicRestrictionTransactionDTO transaction) {
AccountMosaicRestrictionFlags restrictionFlags = AccountMosaicRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
List<UnresolvedMosaicId> additions = transaction.getRestrictionAdditions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
List<UnresolvedMosaicId> deletions = transaction.getRestrictionDeletions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
return AccountMosaicRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
use of io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionFlags in project nem2-sdk-java by nemtech.
the class AccountMosaicRestrictionTransactionMapper method createFactory.
@Override
protected AccountMosaicRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountMosaicRestrictionTransactionDTO transaction) {
AccountMosaicRestrictionFlags restrictionFlags = AccountMosaicRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
List<UnresolvedMosaicId> additions = transaction.getRestrictionAdditions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
List<UnresolvedMosaicId> deletions = transaction.getRestrictionDeletions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
return AccountMosaicRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
use of io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionFlags in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method addAndRemoveMosaicRestriction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addAndRemoveMosaicRestriction(RepositoryType type) {
AccountMosaicRestrictionFlags restrictionFlags = AccountMosaicRestrictionFlags.ALLOW_INCOMING_MOSAIC;
MosaicNonce nonce = MosaicNonce.createRandom();
MosaicId mosaicId = MosaicId.createFromNonce(nonce, testAccount.getPublicAccount());
Assertions.assertNotNull(get(getRepositoryFactory(type).createAccountRepository().getAccountInfo(testAccount.getAddress())));
if (hasRestriction(type, testAccount, restrictionFlags, mosaicId)) {
System.out.println("Removing existing mosaic restriction!");
sendAccountRestrictionMosaic(type, mosaicId, false, restrictionFlags);
Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, mosaicId));
}
System.out.println("Adding mosaic restriction");
sendAccountRestrictionMosaic(type, mosaicId, true, restrictionFlags);
Assertions.assertTrue(hasRestriction(type, testAccount, restrictionFlags, mosaicId));
System.out.println("Removing mosaic restriction");
sendAccountRestrictionMosaic(type, mosaicId, false, restrictionFlags);
Assertions.assertFalse(hasRestriction(type, testAccount, restrictionFlags, mosaicId));
}
Aggregations