Search in sources :

Example 46 with Address

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

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

the class NamespaceRepositoryOkHttpImplTest method shouldGetLinkedAddress.

@Test
public void shouldGetLinkedAddress() throws Exception {
    Address address = Address.generateRandom(networkType);
    NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
    Address ownerAccount = Account.generateNewAccount(NetworkType.MIJIN_TEST).getAddress();
    NamespaceInfoDTO dto = new NamespaceInfoDTO();
    NamespaceMetaDTO meta = new NamespaceMetaDTO();
    meta.setActive(true);
    dto.setId("SomeId");
    meta.setIndex(123);
    dto.setMeta(meta);
    NamespaceDTO namespace = new NamespaceDTO();
    namespace.setDepth(111);
    namespace.setRegistrationType(NamespaceRegistrationTypeEnum.NUMBER_0);
    namespace.setOwnerAddress(ownerAccount.encoded());
    AliasDTO alias = new AliasDTO();
    alias.setType(AliasTypeEnum.NUMBER_2);
    alias.setAddress(address.encoded());
    namespace.setAlias(alias);
    dto.setNamespace(namespace);
    mockRemoteCall(dto);
    Address linkedAddress = repository.getLinkedAddress(namespaceId).toFuture().get();
    Assertions.assertNotNull(linkedAddress);
    Assertions.assertEquals(address, linkedAddress);
}
Also used : NamespaceDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceDTO) Address(io.nem.symbol.sdk.model.account.Address) NamespaceMetaDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceMetaDTO) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceInfoDTO) AliasDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AliasDTO) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 48 with Address

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

the class NamespaceRepositoryOkHttpImplTest method search.

@Test
public void search() throws Exception {
    Address address = Address.generateRandom(networkType);
    Address ownerAccount = Account.generateNewAccount(NetworkType.MIJIN_TEST).getAddress();
    NamespaceInfoDTO dto = new NamespaceInfoDTO();
    NamespaceMetaDTO meta = new NamespaceMetaDTO();
    meta.setActive(true);
    dto.setId("SomeId");
    meta.setIndex(123);
    dto.setMeta(meta);
    NamespaceDTO namespace = new NamespaceDTO();
    namespace.setDepth(111);
    namespace.setStartHeight(BigInteger.valueOf(4));
    namespace.setEndHeight(BigInteger.valueOf(5));
    namespace.setRegistrationType(NamespaceRegistrationTypeEnum.NUMBER_1);
    namespace.setOwnerAddress(ownerAccount.encoded());
    namespace.setVersion(1);
    AliasDTO alias = new AliasDTO();
    alias.setType(AliasTypeEnum.NUMBER_2);
    alias.setAddress(address.encoded());
    namespace.setAlias(alias);
    dto.setNamespace(namespace);
    mockRemoteCall(toPage(dto));
    NamespaceInfo info = repository.search(new NamespaceSearchCriteria().ownerAddress(address)).toFuture().get().getData().get(0);
    Assertions.assertNotNull(info);
    Assertions.assertEquals(NamespaceRegistrationType.SUB_NAMESPACE, info.getRegistrationType());
    Assertions.assertEquals(dto.getId(), info.getRecordId().get());
    Assertions.assertEquals(meta.getIndex(), info.getIndex());
    Assertions.assertEquals(meta.getActive(), info.isActive());
    Assertions.assertEquals(BigInteger.valueOf(4), info.getStartHeight());
    Assertions.assertEquals(BigInteger.valueOf(5), info.getEndHeight());
}
Also used : NamespaceDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceDTO) Address(io.nem.symbol.sdk.model.account.Address) NamespaceMetaDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceMetaDTO) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceInfoDTO) AliasDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AliasDTO) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceSearchCriteria(io.nem.symbol.sdk.api.NamespaceSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 49 with Address

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

the class ReceiptRepositoryOkHttpImplTest method searchAddressResolutionStatements.

@Test
public void searchAddressResolutionStatements() throws Exception {
    ResolutionStatementInfoDTO addressResolutionStatement = new ResolutionStatementInfoDTO();
    Address address = Address.generateRandom(this.networkType);
    ResolutionStatementDTO statement1 = new ResolutionStatementDTO();
    addressResolutionStatement.setStatement(statement1);
    statement1.setUnresolved(address.encoded());
    statement1.setHeight(BigInteger.valueOf(6L));
    mockRemoteCall(toPage(addressResolutionStatement));
    BigInteger height = BigInteger.valueOf(10L);
    List<AddressResolutionStatement> addressResolutionStatements = repository.searchAddressResolutionStatements(new ResolutionStatementSearchCriteria().height(height)).toFuture().get().getData();
    Assertions.assertEquals(1, addressResolutionStatements.size());
    Assertions.assertEquals(BigInteger.valueOf(6L), addressResolutionStatements.get(0).getHeight());
    Assertions.assertEquals(address, addressResolutionStatements.get(0).getUnresolved());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) ResolutionStatementDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementDTO) BigInteger(java.math.BigInteger) ResolutionStatementInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementInfoDTO) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 50 with Address

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

the class ListenerOkHttpTest method confirmAndGetError.

@Test
public void confirmAndGetError() throws InterruptedException, ExecutionException, TimeoutException {
    simulateWebSocketStartup();
    TransactionInfoDTO transactionInfo = TestHelperOkHttp.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json");
    JsonObject transactionInfoDtoJsonObject = jsonHelper.convert(transactionInfo, JsonObject.class);
    Address address = Address.createFromPublicKey(jsonHelper.getString(transactionInfoDtoJsonObject, "transaction", "signerPublicKey"), networkType);
    String channelName = ListenerChannel.CONFIRMED_ADDED.toString();
    List<Transaction> transactions = new ArrayList<>();
    listener.confirmed(address).forEach(transactions::add);
    handle(transactionInfoDtoJsonObject, channelName + "/" + address.plain());
    Assertions.assertEquals(1, transactions.size());
    Assertions.assertEquals(address, transactions.get(0).getSigner().get().getAddress());
    Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName + "/" + address.plain())));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) TransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) ListenerSubscribeMessage(io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage) Test(org.junit.jupiter.api.Test)

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