Search in sources :

Example 1 with NamespaceNameDTO

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());
}
Also used : NamespaceName(io.nem.symbol.sdk.model.namespace.NamespaceName) NamespaceNameDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceNameDTO) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Aggregations

NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)1 NamespaceName (io.nem.symbol.sdk.model.namespace.NamespaceName)1 NamespaceNameDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceNameDTO)1 Test (org.junit.jupiter.api.Test)1