Search in sources :

Example 1 with ResolutionStatementSearchCriteria

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

the class TransactionServiceTest method lastAssert.

@AfterEach
void lastAssert() {
    Mockito.verify(receiptRepositoryMock, Mockito.atMost(1)).searchAddressResolutionStatements(Mockito.eq(new ResolutionStatementSearchCriteria().height(height)));
    Mockito.verify(receiptRepositoryMock, Mockito.atMost(1)).searchMosaicResolutionStatements(Mockito.eq(new ResolutionStatementSearchCriteria().height(height)));
}
Also used : ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) AfterEach(org.junit.jupiter.api.AfterEach)

Example 2 with ResolutionStatementSearchCriteria

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

the class ReceiptRepositoryOkHttpImpl 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());
    Callable<ResolutionStatementPage> callback = () -> getClient().searchMosaicResolutionStatements(height, pageSize, pageNumber, offset, order);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createMosaicResolutionStatementFromDto).collect(Collectors.toList()))));
}
Also used : BigInteger(java.math.BigInteger) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementPage) ReceiptTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.ReceiptTypeEnum) ReceiptRoutesApi(io.nem.symbol.sdk.openapi.okhttp_gson.api.ReceiptRoutesApi) ApiClient(io.nem.symbol.sdk.openapi.okhttp_gson.invoker.ApiClient) Callable(java.util.concurrent.Callable) Collectors(java.util.stream.Collectors) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptType(io.nem.symbol.sdk.model.receipt.ReceiptType) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) ResolutionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementPage) List(java.util.List) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Page(io.nem.symbol.sdk.api.Page) BigInteger(java.math.BigInteger) ResolutionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementPage)

Example 3 with ResolutionStatementSearchCriteria

use of io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria 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());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) ResolutionStatementDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementDTO) BigInteger(java.math.BigInteger) ResolutionStatementInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementInfoDTO) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 4 with ResolutionStatementSearchCriteria

use of io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria 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());
    });
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) BlockRepository(io.nem.symbol.sdk.api.BlockRepository) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ResolutionStatementSearchCriteria

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

the class ReceiptRepositoryVertxImplTest 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());
}
Also used : ResolutionStatementDTO(io.nem.symbol.sdk.openapi.vertx.model.ResolutionStatementDTO) BigInteger(java.math.BigInteger) ResolutionStatementInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.ResolutionStatementInfoDTO) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) Test(org.junit.jupiter.api.Test)

Aggregations

ResolutionStatementSearchCriteria (io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria)12 BigInteger (java.math.BigInteger)9 AddressResolutionStatement (io.nem.symbol.sdk.model.receipt.AddressResolutionStatement)8 MosaicResolutionStatement (io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement)8 ReceiptRepository (io.nem.symbol.sdk.api.ReceiptRepository)7 Page (io.nem.symbol.sdk.api.Page)5 Observable (io.reactivex.Observable)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 Test (org.junit.jupiter.api.Test)5 TransactionStatementSearchCriteria (io.nem.symbol.sdk.api.TransactionStatementSearchCriteria)4 ReceiptType (io.nem.symbol.sdk.model.receipt.ReceiptType)4 TransactionStatement (io.nem.symbol.sdk.model.receipt.TransactionStatement)4 Address (io.nem.symbol.sdk.model.account.Address)3 BlockRepository (io.nem.symbol.sdk.api.BlockRepository)2 Account (io.nem.symbol.sdk.model.account.Account)2 MerkleProofInfo (io.nem.symbol.sdk.model.blockchain.MerkleProofInfo)2 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)2 ReceiptRoutesApi (io.nem.symbol.sdk.openapi.vertx.api.ReceiptRoutesApi)2 ReceiptRoutesApiImpl (io.nem.symbol.sdk.openapi.vertx.api.ReceiptRoutesApiImpl)2