Search in sources :

Example 1 with AccountNames

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());
}
Also used : AccountsNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountsNamesDTO) Address(io.nem.symbol.sdk.model.account.Address) AccountNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountNamesDTO) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) Test(org.junit.jupiter.api.Test)

Example 2 with AccountNames

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));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with AccountNames

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));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with AccountNames

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());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with AccountNames

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());
}
Also used : AccountsNamesDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountsNamesDTO) Address(io.nem.symbol.sdk.model.account.Address) AccountNamesDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountNamesDTO) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) Test(org.junit.jupiter.api.Test)

Aggregations

AccountNames (io.nem.symbol.sdk.model.account.AccountNames)5 Address (io.nem.symbol.sdk.model.account.Address)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 Account (io.nem.symbol.sdk.model.account.Account)2 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)2 AddressAliasTransaction (io.nem.symbol.sdk.model.transaction.AddressAliasTransaction)2 NamespaceRegistrationTransaction (io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)2 Test (org.junit.jupiter.api.Test)2 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)1 AccountNamesDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountNamesDTO)1 AccountsNamesDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountsNamesDTO)1 AccountNamesDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountNamesDTO)1 AccountsNamesDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountsNamesDTO)1