Search in sources :

Example 61 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class AccountRepositoryIntegrationTest method getAccountInfoNotExisting.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAccountInfoNotExisting(RepositoryType type) {
    AccountRepository accountHttp = getRepositoryFactory(type).createAccountRepository();
    Address addressObject = Address.createFromPublicKey("67F69FA4BFCD158F6E1AF1ABC82F725F5C5C4710D6E29217B12BE66397435DFB", getNetworkType());
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(accountHttp.getAccountInfo(addressObject)));
    Assertions.assertTrue(exception.getMessage().contains("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id"));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 62 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class BlockRepositoryIntegrationTest method searchByBeneficiaryAddressWhenInvalid.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByBeneficiaryAddressWhenInvalid(RepositoryType type) {
    BlockRepository blockRepository = getBlockRepository(type);
    BlockSearchCriteria criteria = new BlockSearchCriteria();
    Address expectedBeneficiaryAddress = Account.generateNewAccount(getNetworkType()).getAddress();
    criteria.setBeneficiaryAddress(expectedBeneficiaryAddress);
    BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
    List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertTrue(blocks.isEmpty());
}
Also used : BlockRepository(io.nem.symbol.sdk.api.BlockRepository) BlockSearchCriteria(io.nem.symbol.sdk.api.BlockSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) BlockPaginationStreamer(io.nem.symbol.sdk.api.BlockPaginationStreamer) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 63 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class BlockRepositoryIntegrationTest method searchByBeneficiaryAddress.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByBeneficiaryAddress(RepositoryType type) {
    BlockRepository blockRepository = getBlockRepository(type);
    BlockInfo block1 = get(blockRepository.getBlockByHeight(BigInteger.ONE));
    BlockSearchCriteria criteria = new BlockSearchCriteria();
    Address expectedBeneficiaryAddress = block1.getBeneficiaryAddress();
    criteria.setBeneficiaryAddress(expectedBeneficiaryAddress);
    BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
    List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
    blocks.forEach(b -> Assertions.assertEquals(expectedBeneficiaryAddress, b.getBeneficiaryAddress()));
    Assertions.assertFalse(blocks.isEmpty());
}
Also used : BlockRepository(io.nem.symbol.sdk.api.BlockRepository) BlockSearchCriteria(io.nem.symbol.sdk.api.BlockSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) BlockPaginationStreamer(io.nem.symbol.sdk.api.BlockPaginationStreamer) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 64 with Address

use of io.nem.symbol.sdk.model.account.Address 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 65 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class AccountRestrictionIntegrationTest method getAccountRestrictionsWhenAccountDoesNotExist.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAccountRestrictionsWhenAccountDoesNotExist(RepositoryType type) {
    RestrictionAccountRepository repository = getRepositoryFactory(type).createRestrictionAccountRepository();
    Address address = Address.createFromPublicKey("67F69FA4BFCD158F6E1AF1ABC82F725F5C5C4710D6E29217B12BE66397435DFB", getNetworkType());
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(repository.getAccountRestrictions(address)));
    Assertions.assertTrue(exception.getMessage().contains("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id"));
}
Also used : UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) Address(io.nem.symbol.sdk.model.account.Address) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) RestrictionAccountRepository(io.nem.symbol.sdk.api.RestrictionAccountRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Address (io.nem.symbol.sdk.model.account.Address)172 Test (org.junit.jupiter.api.Test)124 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)53 BigInteger (java.math.BigInteger)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 ArrayList (java.util.ArrayList)28 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)27 EnumSource (org.junit.jupiter.params.provider.EnumSource)26 Account (io.nem.symbol.sdk.model.account.Account)20 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)19 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)19 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)16 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)16 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)15 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)14 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)13 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)13 Observable (io.reactivex.Observable)13 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)12 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)10