use of io.nem.symbol.sdk.model.receipt.AddressResolutionStatement in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryOkHttpImplTest method searchAddressResolutionStatements.
@Test
public void searchAddressResolutionStatements() throws Exception {
ResolutionStatementInfoDTO addressResolutionStatement = new ResolutionStatementInfoDTO();
Address address = Address.generateRandom(this.networkType);
ResolutionStatementDTO statement1 = new ResolutionStatementDTO();
addressResolutionStatement.setStatement(statement1);
statement1.setUnresolved(address.encoded());
statement1.setHeight(BigInteger.valueOf(6L));
mockRemoteCall(toPage(addressResolutionStatement));
BigInteger height = BigInteger.valueOf(10L);
List<AddressResolutionStatement> addressResolutionStatements = repository.searchAddressResolutionStatements(new ResolutionStatementSearchCriteria().height(height)).toFuture().get().getData();
Assertions.assertEquals(1, addressResolutionStatements.size());
Assertions.assertEquals(BigInteger.valueOf(6L), addressResolutionStatements.get(0).getHeight());
Assertions.assertEquals(address, addressResolutionStatements.get(0).getUnresolved());
}
use of io.nem.symbol.sdk.model.receipt.AddressResolutionStatement in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method getMerkleReceiptsFromAddresses.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMerkleReceiptsFromAddresses(RepositoryType type) {
Pair<Account, NamespaceId> testAccount = helper().getTestAccount(type);
helper().basicSendMosaicFromNemesis(type, testAccount.getRight());
BlockRepository blockRepository = getBlockRepository(type);
ReceiptRepository receiptRepository = getRepositoryFactory(type).createReceiptRepository();
PaginationStreamer<AddressResolutionStatement, ResolutionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.addresses(receiptRepository);
List<AddressResolutionStatement> list = get(streamer.search(new ResolutionStatementSearchCriteria()).take(5).toList().toObservable());
Assertions.assertFalse(list.isEmpty());
list.forEach(s -> {
String hash = s.generateHash(getNetworkType());
MerkleProofInfo merkleProofInfo = get(blockRepository.getMerkleReceipts(s.getHeight(), hash));
Assertions.assertFalse(merkleProofInfo.getMerklePath().isEmpty());
});
}
use of io.nem.symbol.sdk.model.receipt.AddressResolutionStatement in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method simulateStatement.
private void simulateStatement(BigInteger height, int primaryId, int secondaryId) {
Map<NamespaceId, Address> addressMap = new HashMap<>();
addressMap.put(addressNamespace1, address1);
addressMap.put(addressNamespace2, address2);
addressMap.put(addressNamespace3, address3);
Map<NamespaceId, MosaicId> mosaicMap = new HashMap<>();
mosaicMap.put(mosaicNamespace1, mosaicId1);
mosaicMap.put(mosaicNamespace2, mosaicId2);
mosaicMap.put(mosaicNamespace3, mosaicId3);
List<AddressResolutionStatement> addressResolutionStatements = addressMap.entrySet().stream().map(e -> new AddressResolutionStatement("abc", height, e.getKey(), Collections.singletonList(ResolutionEntry.forAddress(e.getValue(), new ReceiptSource(primaryId, secondaryId))))).collect(Collectors.toList());
List<MosaicResolutionStatement> mosaicResolutionStatements = mosaicMap.entrySet().stream().map(e -> new MosaicResolutionStatement("abc", height, e.getKey(), Collections.singletonList(ResolutionEntry.forMosaicId(e.getValue(), new ReceiptSource(primaryId, secondaryId))))).collect(Collectors.toList());
Mockito.when(receiptRepositoryMock.searchAddressResolutionStatements(Mockito.eq(new ResolutionStatementSearchCriteria().height(height)))).thenReturn(Observable.just(new Page<>(addressResolutionStatements)));
Mockito.when(receiptRepositoryMock.searchMosaicResolutionStatements(Mockito.eq(new ResolutionStatementSearchCriteria().height(height)))).thenReturn(Observable.just(new Page<>(mosaicResolutionStatements)));
}
use of io.nem.symbol.sdk.model.receipt.AddressResolutionStatement in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryVertxImpl method searchAddressResolutionStatements.
@Override
public Observable<Page<AddressResolutionStatement>> searchAddressResolutionStatements(ResolutionStatementSearchCriteria criteria) {
BigInteger height = criteria.getHeight();
Integer pageSize = criteria.getPageSize();
Integer pageNumber = criteria.getPageNumber();
String offset = criteria.getOffset();
Order order = toDto(criteria.getOrder());
Consumer<Handler<AsyncResult<ResolutionStatementPage>>> callback = (handler) -> getClient().searchAddressResolutionStatements(height, pageSize, pageNumber, offset, order, handler);
return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createAddressResolutionStatementFromDto).collect(Collectors.toList()))));
}
use of io.nem.symbol.sdk.model.receipt.AddressResolutionStatement in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryOkHttpImpl method searchAddressResolutionStatements.
@Override
public Observable<Page<AddressResolutionStatement>> searchAddressResolutionStatements(ResolutionStatementSearchCriteria criteria) {
BigInteger height = criteria.getHeight();
Integer pageSize = criteria.getPageSize();
Integer pageNumber = criteria.getPageNumber();
String offset = criteria.getOffset();
Order order = toDto(criteria.getOrder());
Callable<ResolutionStatementPage> callback = () -> getClient().searchAddressResolutionStatements(height, pageSize, pageNumber, offset, order);
return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createAddressResolutionStatementFromDto).collect(Collectors.toList()))));
}
Aggregations