use of io.nem.symbol.sdk.api.BlockPaginationStreamer in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchOrderByHeightAsc.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchOrderByHeightAsc(RepositoryType type) {
BlockSearchCriteria criteria = new BlockSearchCriteria();
criteria.setOrderBy(BlockOrderBy.HEIGHT);
criteria.setOrder(OrderBy.ASC);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(getBlockRepository(type));
List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
List<BlockInfo> sorted = blocks.stream().sorted(Comparator.comparing(BlockInfo::getHeight)).collect(Collectors.toList());
Assertions.assertEquals(blocks, sorted);
}
use of io.nem.symbol.sdk.api.BlockPaginationStreamer in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchByBeneficiaryAddressWhenInvalid.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByBeneficiaryAddressWhenInvalid(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
BlockSearchCriteria criteria = new BlockSearchCriteria();
Address expectedBeneficiaryAddress = Account.generateNewAccount(getNetworkType()).getAddress();
criteria.setBeneficiaryAddress(expectedBeneficiaryAddress);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
Assertions.assertTrue(blocks.isEmpty());
}
use of io.nem.symbol.sdk.api.BlockPaginationStreamer in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchBySignerPublicKeyWhenInvalid.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyWhenInvalid(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
BlockSearchCriteria criteria = new BlockSearchCriteria();
PublicKey expectedSignerPublicKey = PublicKey.generateRandom();
criteria.setSignerPublicKey(expectedSignerPublicKey);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
Assertions.assertTrue(blocks.isEmpty());
}
use of io.nem.symbol.sdk.api.BlockPaginationStreamer in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchByBeneficiaryAddress.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByBeneficiaryAddress(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
BlockInfo block1 = get(blockRepository.getBlockByHeight(BigInteger.ONE));
BlockSearchCriteria criteria = new BlockSearchCriteria();
Address expectedBeneficiaryAddress = block1.getBeneficiaryAddress();
criteria.setBeneficiaryAddress(expectedBeneficiaryAddress);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
blocks.forEach(b -> Assertions.assertEquals(expectedBeneficiaryAddress, b.getBeneficiaryAddress()));
Assertions.assertFalse(blocks.isEmpty());
}
use of io.nem.symbol.sdk.api.BlockPaginationStreamer in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchBySignerPublicKey.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKey(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
BlockInfo block1 = get(blockRepository.getBlockByHeight(BigInteger.ONE));
BlockSearchCriteria criteria = new BlockSearchCriteria();
PublicKey expectedSignerPublicKey = block1.getSignerPublicAccount().getPublicKey();
criteria.setSignerPublicKey(expectedSignerPublicKey);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
blocks.forEach(b -> Assertions.assertEquals(expectedSignerPublicKey, b.getSignerPublicAccount().getPublicKey()));
Assertions.assertFalse(blocks.isEmpty());
}
Aggregations