Search in sources :

Example 1 with MetadataPage

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

the class MetadataRepositoryOkHttpImplTest method search.

@Test
public void search() throws Exception {
    Address address = Address.generateRandom(networkType);
    MetadataPage dto = getMetadataEntriesDTO();
    mockRemoteCall(dto);
    List<Metadata> resultList = repository.search(new MetadataSearchCriteria().sourceAddress(address)).toFuture().get().getData();
    assertMetadataList(dto, resultList);
}
Also used : MetadataPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataPage) MetadataSearchCriteria(io.nem.symbol.sdk.api.MetadataSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) Metadata(io.nem.symbol.sdk.model.metadata.Metadata) Test(org.junit.jupiter.api.Test)

Example 2 with MetadataPage

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

the class MetadataRepositoryOkHttpImplTest method getMetadataEntriesDTO.

private MetadataPage getMetadataEntriesDTO() {
    MetadataPage metadataPage = new MetadataPage();
    metadataPage.setPagination(new Pagination().pageNumber(1).pageSize(2));
    List<MetadataInfoDTO> data = new ArrayList<>();
    data.add(createMetadataDto(ConvertUtils.toSize16Hex(BigInteger.valueOf(10)), MetadataTypeEnum.NUMBER_0, null));
    data.add(createMetadataDto(ConvertUtils.toSize16Hex(BigInteger.valueOf(20)), MetadataTypeEnum.NUMBER_1, "11111"));
    data.add(createMetadataDto(ConvertUtils.toSize16Hex(BigInteger.valueOf(30)), MetadataTypeEnum.NUMBER_2, "22222"));
    metadataPage.setData(data);
    return metadataPage;
}
Also used : MetadataPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataPage) Pagination(io.nem.symbol.sdk.openapi.okhttp_gson.model.Pagination) ArrayList(java.util.ArrayList) MetadataInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataInfoDTO)

Example 3 with MetadataPage

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

the class MetadataRepositoryOkHttpImpl method search.

@Override
public Observable<Page<Metadata>> search(MetadataSearchCriteria criteria) {
    String sourceAddress = toDto(criteria.getSourceAddress());
    String targetAddress = toDto(criteria.getTargetAddress());
    String scopedMetadataKey = toDto(criteria.getScopedMetadataKey());
    String targetId = criteria.getTargetId();
    MetadataTypeEnum metadataType = criteria.getMetadataType() == null ? null : MetadataTypeEnum.fromValue(criteria.getMetadataType().getValue());
    String offset = criteria.getOffset();
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    Order order = toDto(criteria.getOrder());
    Callable<MetadataPage> callback = () -> getClient().searchMetadataEntries(sourceAddress, targetAddress, scopedMetadataKey, targetId, metadataType, pageSize, pageNumber, offset, order);
    return call(callback, page -> this.toPage(page.getPagination(), page.getData().stream().map(this::toMetadata).collect(Collectors.toList())));
}
Also used : MetadataTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataTypeEnum) BigInteger(java.math.BigInteger) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) MetadataPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataPage)

Aggregations

MetadataPage (io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataPage)3 MetadataSearchCriteria (io.nem.symbol.sdk.api.MetadataSearchCriteria)1 Address (io.nem.symbol.sdk.model.account.Address)1 Metadata (io.nem.symbol.sdk.model.metadata.Metadata)1 MetadataInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataInfoDTO)1 MetadataTypeEnum (io.nem.symbol.sdk.openapi.okhttp_gson.model.MetadataTypeEnum)1 Order (io.nem.symbol.sdk.openapi.okhttp_gson.model.Order)1 Pagination (io.nem.symbol.sdk.openapi.okhttp_gson.model.Pagination)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1