use of io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceNameDTO in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest 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