use of io.nem.symbol.sdk.model.account.AccountNames in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest method shouldGetAccountsNamesFromAddresses.
@Test
public void shouldGetAccountsNamesFromAddresses() throws Exception {
Address address = Address.generateRandom(networkType);
AccountNamesDTO dto = new AccountNamesDTO();
dto.setAddress(encodeAddress(address));
dto.setNames(Collections.singletonList("accountalias"));
AccountsNamesDTO accountsNamesDTO = new AccountsNamesDTO();
accountsNamesDTO.setAccountNames(Collections.singletonList(dto));
mockRemoteCall(accountsNamesDTO);
List<AccountNames> resolvedList = repository.getAccountsNames(Collections.singletonList(address)).toFuture().get();
Assertions.assertEquals(1, resolvedList.size());
AccountNames accountNames = resolvedList.get(0);
Assertions.assertEquals(address, accountNames.getAddress());
Assertions.assertEquals("accountalias", accountNames.getNames().get(0).getName());
}
use of io.nem.symbol.sdk.model.account.AccountNames in project nem2-sdk-java by nemtech.
the class AddressAliasTransactionIntegrationTest method sendAddressAliasTransactionAggregate.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void sendAddressAliasTransactionAggregate(RepositoryType type) {
Account account = config().getDefaultAccount();
String namespaceName = "test-root-namespace-aggregate-for-address-alias-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, helper().getDuration()).maxFee(maxFee).build();
NamespaceId rootNamespaceId = announceAggregateAndValidate(type, namespaceRegistrationTransaction, account).getLeft().getNamespaceId();
AddressAliasTransaction addressAliasTransaction = AddressAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, account.getAddress()).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction2 = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(addressAliasTransaction.toAggregate(account.getPublicAccount()))).maxFee(maxFee).build();
announceAndValidate(type, account, aggregateTransaction2);
sleep(1000);
List<AccountNames> accountNames = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(account.getAddress())));
Assertions.assertEquals(1, accountNames.size());
assertEquals(1, accountNames.size());
assertEquals(account.getAddress(), accountNames.get(0).getAddress());
assertTrue(accountNames.get(0).getNames().stream().map(NamespaceName::getName).collect(Collectors.toList()).contains(namespaceName));
}
use of io.nem.symbol.sdk.model.account.AccountNames in project nem2-sdk-java by nemtech.
the class AddressAliasTransactionIntegrationTest method sendAddressAliasTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void sendAddressAliasTransaction(RepositoryType type) {
Account account = config().getDefaultAccount();
String namespaceName = "test-root-namespace-for-address-alias-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, helper().getDuration()).maxFee(maxFee).build();
NamespaceId rootNamespaceId = announceAndValidate(type, account, namespaceRegistrationTransaction).getNamespaceId();
AddressAliasTransaction addressAliasTransaction = AddressAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, account.getAddress()).maxFee(maxFee).build();
announceAndValidate(type, account, addressAliasTransaction);
sleep(1000);
List<AccountNames> accountNames = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(account.getAddress())));
Assertions.assertEquals(1, accountNames.size());
assertEquals(1, accountNames.size());
assertEquals(account.getAddress(), accountNames.get(0).getAddress());
assertTrue(accountNames.get(0).getNames().stream().map(NamespaceName::getName).collect(Collectors.toList()).contains(namespaceName));
}
use of io.nem.symbol.sdk.model.account.AccountNames in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method getAccountsNamesFromAddresses.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAccountsNamesFromAddresses(RepositoryType type) {
Address accountAddress = config().getTestAccount().getAddress();
List<AccountNames> accountNames = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(accountAddress)));
System.out.println(jsonHelper().print(accountNames));
assertEquals(1, accountNames.size());
assertEquals(accountAddress, accountNames.get(0).getAddress());
assertNotNull(accountNames.get(0).getNames());
}
use of io.nem.symbol.sdk.model.account.AccountNames in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImplTest method shouldGetAccountsNamesFromAddresses.
@Test
public void shouldGetAccountsNamesFromAddresses() throws Exception {
Address address = Address.generateRandom(this.networkType);
AccountNamesDTO dto = new AccountNamesDTO();
dto.setAddress(encodeAddress(address));
dto.setNames(Collections.singletonList("accountalias"));
AccountsNamesDTO accountsNamesDTO = new AccountsNamesDTO();
accountsNamesDTO.setAccountNames(Collections.singletonList(dto));
mockRemoteCall(accountsNamesDTO);
List<AccountNames> resolvedList = repository.getAccountsNames(Collections.singletonList(address)).toFuture().get();
Assertions.assertEquals(1, resolvedList.size());
AccountNames accountNames = resolvedList.get(0);
Assertions.assertEquals(address, accountNames.getAddress());
Assertions.assertEquals("accountalias", accountNames.getNames().get(0).getName());
}
Aggregations