use of io.nem.symbol.sdk.openapi.vertx.model.NamespaceNameDTO 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.openapi.vertx.model.NamespaceNameDTO in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImplTest method shouldGetNamespaceNames.
@Test
public void shouldGetNamespaceNames() throws Exception {
NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
NamespaceNameDTO dto1 = new NamespaceNameDTO();
dto1.setName("someName1");
dto1.setId("1");
dto1.setParentId("2");
NamespaceNameDTO dto2 = new NamespaceNameDTO();
dto2.setName("someName2");
dto2.setId("3");
mockRemoteCall(Arrays.asList(dto1, dto2));
List<NamespaceName> names = repository.getNamespaceNames(Arrays.asList(namespaceId)).toFuture().get();
Assertions.assertNotNull(names);
Assertions.assertEquals(2, names.size());
Assertions.assertEquals("someName1", names.get(0).getName());
Assertions.assertEquals(BigInteger.valueOf(1L), names.get(0).getNamespaceId().getId());
Assertions.assertEquals(BigInteger.valueOf(2L), names.get(0).getParentId().orElseThrow(() -> new IllegalStateException("No parent id")).getId());
Assertions.assertEquals("someName2", names.get(1).getName());
Assertions.assertEquals(BigInteger.valueOf(3L), names.get(1).getNamespaceId().getId());
Assertions.assertFalse(names.get(1).getParentId().isPresent());
}
Aggregations