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