Search in sources :

Example 1 with MosaicsNamesDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicsNamesDTO in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryOkHttpImpl method getMosaicsNames.

@Override
public Observable<List<MosaicNames>> getMosaicsNames(List<MosaicId> ids) {
    MosaicIds mosaicIds = new MosaicIds();
    mosaicIds.mosaicIds(ids.stream().map(MosaicId::getIdAsHex).collect(Collectors.toList()));
    Callable<MosaicsNamesDTO> callback = () -> getClient().getMosaicsNames(mosaicIds);
    return exceptionHandling(call(callback).map(MosaicsNamesDTO::getMosaicNames).flatMapIterable(item -> item).map(this::toMosaicNames).toList().toObservable());
}
Also used : MosaicsNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicsNamesDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicIds(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicIds)

Example 2 with MosaicsNamesDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicsNamesDTO in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryOkHttpImplTest method shouldGetMosaicsNamesFromPublicKeys.

@Test
public void shouldGetMosaicsNamesFromPublicKeys() throws Exception {
    MosaicId mosaicId = MapperUtils.toMosaicId("99262122238339734");
    MosaicNamesDTO dto = new MosaicNamesDTO();
    dto.setMosaicId("99262122238339734");
    dto.setNames(Collections.singletonList("accountalias"));
    MosaicsNamesDTO accountsNamesDTO = new MosaicsNamesDTO();
    accountsNamesDTO.setMosaicNames(Collections.singletonList(dto));
    mockRemoteCall(accountsNamesDTO);
    List<MosaicNames> resolvedList = repository.getMosaicsNames(Collections.singletonList(mosaicId)).toFuture().get();
    Assertions.assertEquals(1, resolvedList.size());
    MosaicNames accountNames = resolvedList.get(0);
    Assertions.assertEquals(mosaicId, accountNames.getMosaicId());
    Assertions.assertEquals("accountalias", accountNames.getNames().get(0).getName());
}
Also used : MosaicsNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicsNamesDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNames(io.nem.symbol.sdk.model.mosaic.MosaicNames) MosaicNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicNamesDTO) Test(org.junit.jupiter.api.Test)

Aggregations

MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)2 MosaicsNamesDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicsNamesDTO)2 MosaicNames (io.nem.symbol.sdk.model.mosaic.MosaicNames)1 MosaicIds (io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicIds)1 MosaicNamesDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicNamesDTO)1 Test (org.junit.jupiter.api.Test)1