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"));
}
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());
}
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());
}
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));
}
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"));
}
Aggregations