use of io.nem.sdk.model.namespace.NamespaceInfo in project nem2-sdk-java by nemtech.
the class NamespaceHttpTest method getNamespace.
@Test
void getNamespace() throws ExecutionException, InterruptedException {
NamespaceInfo namespaceInfo = namespaceHttp.getNamespace(XEM.NAMESPACEID).toFuture().get();
assertEquals(new BigInteger("1"), namespaceInfo.getStartHeight());
assertEquals(new BigInteger("-1"), namespaceInfo.getEndHeight());
assertEquals(XEM.NAMESPACEID, namespaceInfo.getLevels().get(0));
}
use of io.nem.sdk.model.namespace.NamespaceInfo in project nem2-sdk-java by nemtech.
the class NamespaceHttpTest method getNamespacesFromAccounts.
@Test
void getNamespacesFromAccounts() throws ExecutionException, InterruptedException {
List<NamespaceInfo> namespacesInfo = namespaceHttp.getNamespacesFromAccounts(Collections.singletonList(Address.createFromRawAddress("SARNASAS2BIAB6LMFA3FPMGBPGIJGK6IJETM3ZSP"))).toFuture().get();
assertEquals(1, namespacesInfo.size());
assertEquals(new BigInteger("1"), namespacesInfo.get(0).getStartHeight());
assertEquals(new BigInteger("-1"), namespacesInfo.get(0).getEndHeight());
assertEquals(XEM.NAMESPACEID, namespacesInfo.get(0).getLevels().get(0));
}
use of io.nem.sdk.model.namespace.NamespaceInfo in project nem2-sdk-java by nemtech.
the class NamespaceHttpTest method getNamespacesFromAccount.
@Test
void getNamespacesFromAccount() throws ExecutionException, InterruptedException {
List<NamespaceInfo> namespacesInfo = namespaceHttp.getNamespacesFromAccount(Address.createFromRawAddress("SARNASAS2BIAB6LMFA3FPMGBPGIJGK6IJETM3ZSP")).toFuture().get();
assertEquals(1, namespacesInfo.size());
assertEquals(new BigInteger("1"), namespacesInfo.get(0).getStartHeight());
assertEquals(new BigInteger("-1"), namespacesInfo.get(0).getEndHeight());
assertEquals(XEM.NAMESPACEID, namespacesInfo.get(0).getLevels().get(0));
}
use of io.nem.sdk.model.namespace.NamespaceInfo in project nem2-sdk-java by nemtech.
the class NamespaceHttp method getNamespacesFromAccounts.
private Observable<List<NamespaceInfo>> getNamespacesFromAccounts(List<Address> addresses, Optional<QueryParams> queryParams) {
JsonObject requestBody = new JsonObject();
requestBody.put("addresses", addresses.stream().map((address -> address.plain())).collect(Collectors.toList()));
Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
return networkTypeResolve.flatMap(networkType -> this.client.postAbs(this.url + "/account/namespaces" + (queryParams.isPresent() ? queryParams.get().toUrl() : "")).as(BodyCodec.jsonArray()).rxSendJson(requestBody).toObservable().map(HttpResponse::body).map(json -> objectMapper.<List<NamespaceInfoDTO>>readValue(json.toString(), new TypeReference<List<NamespaceInfoDTO>>() {
})).flatMapIterable(item -> item).map(namespaceInfoDTO -> new NamespaceInfo(namespaceInfoDTO.getMeta().isActive(), namespaceInfoDTO.getMeta().getIndex(), namespaceInfoDTO.getMeta().getId(), NamespaceType.rawValueOf(namespaceInfoDTO.getNamespace().getType()), namespaceInfoDTO.getNamespace().getDepth(), extractLevels(namespaceInfoDTO), new NamespaceId(namespaceInfoDTO.getNamespace().getParentId().extractIntArray()), new PublicAccount(namespaceInfoDTO.getNamespace().getOwner(), networkType), namespaceInfoDTO.getNamespace().getStartHeight().extractIntArray(), namespaceInfoDTO.getNamespace().getEndHeight().extractIntArray())).toList().toObservable());
}
Aggregations