use of io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria 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.api.ResolutionStatementSearchCriteria 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.api.ResolutionStatementSearchCriteria in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryVertxImpl method searchMosaicResolutionStatements.
@Override
public Observable<Page<MosaicResolutionStatement>> searchMosaicResolutionStatements(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().searchMosaicResolutionStatements(height, pageSize, pageNumber, offset, order, handler);
return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createMosaicResolutionStatementFromDto).collect(Collectors.toList()))));
}
use of io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryOkHttpImplTest method searchMosaicResolutionStatements.
@Test
public void searchMosaicResolutionStatements() throws Exception {
ResolutionStatementDTO statement2 = new ResolutionStatementDTO();
ResolutionStatementInfoDTO mosaicResolutionStatement = new ResolutionStatementInfoDTO();
mosaicResolutionStatement.setStatement(statement2);
statement2.setUnresolved("9");
statement2.setHeight(BigInteger.valueOf(7L));
mockRemoteCall(toPage(mosaicResolutionStatement));
BigInteger height = BigInteger.valueOf(10L);
List<MosaicResolutionStatement> mosaicResolutionStatements = repository.searchMosaicResolutionStatements(new ResolutionStatementSearchCriteria().height(height)).toFuture().get().getData();
Assertions.assertEquals(1, mosaicResolutionStatements.size());
Assertions.assertEquals(BigInteger.valueOf(7L), mosaicResolutionStatements.get(0).getHeight());
Assertions.assertEquals(BigInteger.valueOf(9L), mosaicResolutionStatements.get(0).getUnresolved().getId());
}
use of io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria 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