Search in sources :

Example 1 with AccountPaginationStreamer

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

the class AccountSearchRepositoryIntegrationTest method searchMosaicIdProvided.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchMosaicIdProvided(RepositoryType type) {
    AccountPaginationStreamer streamer = new AccountPaginationStreamer(this.getAccountRepository(type));
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    NamespaceId networkCurrencyId = get(repositoryFactory.getNetworkCurrency()).getNamespaceId().get();
    Assertions.assertTrue(networkCurrencyId.getFullName().isPresent());
    MosaicId mosaicId = get(repositoryFactory.createNamespaceRepository().getLinkedMosaicId(networkCurrencyId));
    AccountSearchCriteria criteria = new AccountSearchCriteria().mosaicId(mosaicId);
    List<AccountInfo> accounts = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertFalse(accounts.isEmpty());
    System.out.println(toJson(accounts));
    accounts.forEach(a -> {
        Assertions.assertTrue(a.getMosaics().stream().filter(m -> m.getId().equals(mosaicId)).findFirst().get().getAmount().longValue() > 0);
    });
}
Also used : AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) AccountPaginationStreamer(io.nem.symbol.sdk.api.AccountPaginationStreamer) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AccountPaginationStreamer (io.nem.symbol.sdk.api.AccountPaginationStreamer)1 AccountSearchCriteria (io.nem.symbol.sdk.api.AccountSearchCriteria)1 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 AccountInfo (io.nem.symbol.sdk.model.account.AccountInfo)1 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)1 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1