use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class CurrencyTest method assertCreatedUsingNamespaceId.
@Test
void assertCreatedUsingNamespaceId() {
NamespaceId namespaceId = NamespaceId.createFromName("mycurrency");
Currency currency = new CurrencyBuilder(namespaceId, 6).withSupplyMutable(false).withTransferable(true).build();
Assertions.assertEquals(namespaceId, currency.getNamespaceId().get());
Assertions.assertEquals(namespaceId, currency.getUnresolvedMosaicId());
Assertions.assertFalse(currency.getMosaicId().isPresent());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest method shouldGetNamespace.
@Test
public void shouldGetNamespace() throws Exception {
Address ownerAccount = Account.generateNewAccount(NetworkType.MIJIN_TEST).getAddress();
NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
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_1);
alias.setMosaicId("123");
namespace.setAlias(alias);
dto.setNamespace(namespace);
mockRemoteCall(dto);
NamespaceInfo info = repository.getNamespace(namespaceId).toFuture().get();
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.namespace.NamespaceId 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.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImpl method getNamespaceNames.
@Override
public Observable<List<NamespaceName>> getNamespaceNames(List<NamespaceId> namespaceIds) {
NamespaceIds ids = new NamespaceIds().namespaceIds(namespaceIds.stream().map(NamespaceId::getIdAsHex).collect(Collectors.toList()));
Consumer<Handler<AsyncResult<List<NamespaceNameDTO>>>> callback = handler -> client.getNamespacesNames(ids, handler);
return exceptionHandling(call(callback).flatMapIterable(item -> item).map(this::toNamespaceName).toList().toObservable());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class ListenerOkHttpTest method confirmedUsingHashUsingAlias.
@Test
public void confirmedUsingHashUsingAlias() 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);
NamespaceId alias = NamespaceId.createFromId(BigInteger.TEN);
String channelName = ListenerChannel.CONFIRMED_ADDED.toString();
List<Transaction> transactions = new ArrayList<>();
List<Throwable> exceptions = new ArrayList<>();
listener.confirmedOrError(alias, getHash(transactionInfo)).doOnError(exceptions::add).forEach(transactions::add);
handle(transactionInfoDtoJsonObject, channelName + "/" + alias.plain());
Assertions.assertEquals(1, transactions.size());
Assertions.assertEquals(0, exceptions.size());
Assertions.assertEquals(address, transactions.get(0).getSigner().get().getAddress());
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName + "/" + alias.plain())));
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + alias.plain())));
}
Aggregations