Search in sources :

Example 1 with MosaicResolutionStatement

use of io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement 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 2 with MosaicResolutionStatement

use of io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement 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)

Example 3 with MosaicResolutionStatement

use of io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement 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)));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) ResolutionEntry(io.nem.symbol.sdk.model.receipt.ResolutionEntry) SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) Account(io.nem.symbol.sdk.model.account.Account) MosaicAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.MosaicAddressRestrictionTransaction) AccountAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) Map(java.util.Map) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) BigInteger(java.math.BigInteger) Listener(io.nem.symbol.sdk.api.Listener) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) MosaicDefinitionTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransactionFactory) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) AccountAddressRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionFlags) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) MosaicMetadataTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransactionFactory) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) MosaicMetadataTransaction(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AccountAddressRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransactionFactory) Collectors(java.util.stream.Collectors) StringEncoder(io.nem.symbol.core.utils.StringEncoder) Currency(io.nem.symbol.sdk.model.mosaic.Currency) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) Test(org.junit.jupiter.api.Test) List(java.util.List) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) MosaicAddressRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicAddressRestrictionTransactionFactory) ExceptionUtils(io.nem.symbol.core.utils.ExceptionUtils) AggregateTransactionFactory(io.nem.symbol.sdk.model.transaction.AggregateTransactionFactory) TransactionFactory(io.nem.symbol.sdk.model.transaction.TransactionFactory) Address(io.nem.symbol.sdk.model.account.Address) Page(io.nem.symbol.sdk.api.Page) SecretLockTransactionFactory(io.nem.symbol.sdk.model.transaction.SecretLockTransactionFactory) MosaicSupplyChangeTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransactionFactory) HashLockTransactionFactory(io.nem.symbol.sdk.model.transaction.HashLockTransactionFactory) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) AccountMosaicRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransactionFactory) HashMap(java.util.HashMap) MosaicGlobalRestrictionTransaction(io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransaction) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) ArrayList(java.util.ArrayList) AccountMosaicRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionFlags) MosaicRestrictionType(io.nem.symbol.sdk.model.transaction.MosaicRestrictionType) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) TransactionService(io.nem.symbol.sdk.api.TransactionService) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) MosaicSupplyChangeActionType(io.nem.symbol.sdk.model.mosaic.MosaicSupplyChangeActionType) Observable(io.reactivex.Observable) SecretProofTransactionFactory(io.nem.symbol.sdk.model.transaction.SecretProofTransactionFactory) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) LockHashAlgorithm(io.nem.symbol.sdk.model.transaction.LockHashAlgorithm) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) ReceiptSource(io.nem.symbol.sdk.model.receipt.ReceiptSource) ExecutionException(java.util.concurrent.ExecutionException) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) TransactionInfo(io.nem.symbol.sdk.model.transaction.TransactionInfo) Mockito(org.mockito.Mockito) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AfterEach(org.junit.jupiter.api.AfterEach) Assertions(org.junit.jupiter.api.Assertions) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) TransactionAnnounceResponse(io.nem.symbol.sdk.model.transaction.TransactionAnnounceResponse) MosaicFlags(io.nem.symbol.sdk.model.mosaic.MosaicFlags) MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) Collections(java.util.Collections) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) MosaicGlobalRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransactionFactory) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) Address(io.nem.symbol.sdk.model.account.Address) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) HashMap(java.util.HashMap) ReceiptSource(io.nem.symbol.sdk.model.receipt.ReceiptSource) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) Page(io.nem.symbol.sdk.api.Page) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId)

Example 4 with MosaicResolutionStatement

use of io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement 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()))));
}
Also used : BigInteger(java.math.BigInteger) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) Collectors(java.util.stream.Collectors) TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptType(io.nem.symbol.sdk.model.receipt.ReceiptType) TransactionStatementPage(io.nem.symbol.sdk.openapi.vertx.model.TransactionStatementPage) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) Consumer(java.util.function.Consumer) List(java.util.List) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) ReceiptRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.ReceiptRoutesApi) 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) ReceiptRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.ReceiptRoutesApiImpl) ResolutionStatementPage(io.nem.symbol.sdk.openapi.vertx.model.ResolutionStatementPage) ReceiptTypeEnum(io.nem.symbol.sdk.openapi.vertx.model.ReceiptTypeEnum) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) Page(io.nem.symbol.sdk.api.Page) BigInteger(java.math.BigInteger) Handler(io.vertx.core.Handler) ResolutionStatementPage(io.nem.symbol.sdk.openapi.vertx.model.ResolutionStatementPage)

Example 5 with MosaicResolutionStatement

use of io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement 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());
}
Also used : ResolutionStatementDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementDTO) BigInteger(java.math.BigInteger) ResolutionStatementInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.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)6 MosaicResolutionStatement (io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement)6 BigInteger (java.math.BigInteger)5 ReceiptRepository (io.nem.symbol.sdk.api.ReceiptRepository)4 Page (io.nem.symbol.sdk.api.Page)3 AddressResolutionStatement (io.nem.symbol.sdk.model.receipt.AddressResolutionStatement)3 Observable (io.reactivex.Observable)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Test (org.junit.jupiter.api.Test)3 TransactionStatementSearchCriteria (io.nem.symbol.sdk.api.TransactionStatementSearchCriteria)2 ReceiptType (io.nem.symbol.sdk.model.receipt.ReceiptType)2 TransactionStatement (io.nem.symbol.sdk.model.receipt.TransactionStatement)2 ExceptionUtils (io.nem.symbol.core.utils.ExceptionUtils)1 StringEncoder (io.nem.symbol.core.utils.StringEncoder)1 BlockRepository (io.nem.symbol.sdk.api.BlockRepository)1 Listener (io.nem.symbol.sdk.api.Listener)1 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)1 TransactionService (io.nem.symbol.sdk.api.TransactionService)1