use of io.nem.symbol.sdk.model.namespace.NamespaceInfo 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.NamespaceInfo 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.namespace.NamespaceInfo in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImpl method search.
@Override
public Observable<Page<NamespaceInfo>> search(NamespaceSearchCriteria criteria) {
String ownerAddress = toDto(criteria.getOwnerAddress());
NamespaceRegistrationTypeEnum registrationType = criteria.getRegistrationType() == null ? null : NamespaceRegistrationTypeEnum.fromValue(criteria.getRegistrationType().getValue());
String level0 = criteria.getLevel0();
AliasTypeEnum aliasType = criteria.getAliasType() == null ? null : AliasTypeEnum.fromValue(criteria.getAliasType().getValue());
Integer pageSize = criteria.getPageSize();
Integer pageNumber = criteria.getPageNumber();
String offset = criteria.getOffset();
Order order = toDto(criteria.getOrder());
Consumer<Handler<AsyncResult<NamespacePage>>> callback = handler -> getClient().searchNamespaces(ownerAddress, registrationType, level0, aliasType, pageSize, pageNumber, offset, order, handler);
return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(this::toNamespaceInfo).collect(Collectors.toList()))));
}
use of io.nem.symbol.sdk.model.namespace.NamespaceInfo in project nem2-sdk-java by nemtech.
the class StateProofServiceImpl method namespace.
@Override
public Observable<StateMerkleProof<NamespaceInfo>> namespace(NamespaceInfo state) {
NamespaceId id = state.getId();
NamespaceRepository namespaceRepository = this.repositoryFactory.createNamespaceRepository();
PaginationStreamer<NamespaceInfo, NamespaceSearchCriteria> streamer = namespaceRepository.streamer();
return namespaceRepository.getNamespaceMerkle(id).flatMap(merkle -> streamer.search(new NamespaceSearchCriteria().level0(state.getId().getIdAsHex()).registrationType(NamespaceRegistrationType.SUB_NAMESPACE)).toList().toObservable().map(state::serialize).map(s -> toStateMerkleProof(state, merkle, s)));
}
use of io.nem.symbol.sdk.model.namespace.NamespaceInfo in project nem2-sdk-java by nemtech.
the class NamespaceRegistrationIntegrationTest method aggregateSubNamespaceRegisterNamespaceTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateSubNamespaceRegisterNamespaceTransaction(RepositoryType type) {
this.aggregateRootRegisterNamespaceTransaction(type);
String namespaceName = "test-sub-namespace-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), namespaceName, this.rootNamespaceId).maxFee(maxFee).build();
announceAggregateAndValidate(type, namespaceRegistrationTransaction, this.account);
sleep(1000);
NamespaceInfo namespaceInfo = get(getRepositoryFactory(type).createNamespaceRepository().getNamespace(namespaceRegistrationTransaction.getNamespaceId()));
Assertions.assertEquals(this.account.getAddress(), namespaceInfo.getOwnerAddress());
Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceId(), namespaceInfo.getId());
}
Aggregations