Search in sources :

Example 1 with MosaicPaginationStreamer

use of io.nem.symbol.sdk.api.MosaicPaginationStreamer in project nem2-sdk-java by nemtech.

the class MosaicRepositoryIntegrationTest method searchByOwnerAddressInvalid.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByOwnerAddressInvalid(RepositoryType type) {
    MosaicSearchCriteria criteria = new MosaicSearchCriteria();
    Address address = Account.generateNewAccount(getNetworkType()).getAddress();
    criteria.ownerAddress(address);
    MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(getMosaicRepository(type));
    List<MosaicInfo> mosaics = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertTrue(mosaics.isEmpty());
}
Also used : MosaicPaginationStreamer(io.nem.symbol.sdk.api.MosaicPaginationStreamer) MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) Address(io.nem.symbol.sdk.model.account.Address) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with MosaicPaginationStreamer

use of io.nem.symbol.sdk.api.MosaicPaginationStreamer in project nem2-sdk-java by nemtech.

the class MosaicRepositoryIntegrationTest method searchByOwnerAddress.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByOwnerAddress(RepositoryType type) {
    MosaicSearchCriteria criteria = new MosaicSearchCriteria();
    Address address = testAccount.getAddress();
    criteria.ownerAddress(address);
    MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(getMosaicRepository(type));
    List<MosaicInfo> mosaics = get(streamer.search(criteria).toList().toObservable());
    mosaics.forEach(m -> Assertions.assertEquals(address, m.getOwnerAddress()));
    Assertions.assertFalse(mosaics.isEmpty());
}
Also used : MosaicPaginationStreamer(io.nem.symbol.sdk.api.MosaicPaginationStreamer) MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) Address(io.nem.symbol.sdk.model.account.Address) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with MosaicPaginationStreamer

use of io.nem.symbol.sdk.api.MosaicPaginationStreamer in project nem2-sdk-java by nemtech.

the class MosaicRepositoryIntegrationTest method searchUsingOffset.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUsingOffset(RepositoryType type) {
    MosaicRepository mosaicRepository = getMosaicRepository(type);
    MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(mosaicRepository);
    MosaicSearchCriteria criteria = new MosaicSearchCriteria();
    criteria.setPageSize(10);
    int offsetIndex = 2;
    List<MosaicInfo> mosaicsWithoutOffset = get(streamer.search(criteria).toList().toObservable());
    criteria.setOffset(mosaicsWithoutOffset.get(offsetIndex).getRecordId().get());
    List<MosaicInfo> mosaicFromOffsets = get(streamer.search(criteria).toList().toObservable());
    PaginationTester.sameEntities(mosaicsWithoutOffset.stream().skip(offsetIndex + 1).collect(Collectors.toList()), mosaicFromOffsets);
}
Also used : MosaicPaginationStreamer(io.nem.symbol.sdk.api.MosaicPaginationStreamer) MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) MosaicRepository(io.nem.symbol.sdk.api.MosaicRepository) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MosaicPaginationStreamer (io.nem.symbol.sdk.api.MosaicPaginationStreamer)3 MosaicSearchCriteria (io.nem.symbol.sdk.api.MosaicSearchCriteria)3 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 Address (io.nem.symbol.sdk.model.account.Address)2 MosaicRepository (io.nem.symbol.sdk.api.MosaicRepository)1