Search in sources :

Example 11 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryIntegrationTest method getNamespacesFromAccount.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getNamespacesFromAccount(RepositoryType type) {
    Account account = config().getDefaultAccount();
    List<NamespaceInfo> namespacesInfo = get(getNamespaceRepository(type).search(new NamespaceSearchCriteria().ownerAddress(account.getAddress()))).getData();
    namespacesInfo.forEach(n -> {
        Assertions.assertEquals(account.getAddress(), n.getOwnerAddress());
    });
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceSearchCriteria(io.nem.symbol.sdk.api.NamespaceSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchBySignerPublicKeyInvalid.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyInvalid(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
    PublicKey expectedSignerPublicKey = Account.generateNewAccount(getNetworkType()).getPublicAccount().getPublicKey();
    criteria.setSignerPublicKey(expectedSignerPublicKey);
    List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertTrue(transactions.isEmpty());
    helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) PublicKey(io.nem.symbol.core.crypto.PublicKey) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchUnconfirmed.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUnconfirmed(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    Address recipient = getRecipient();
    TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("")).maxFee(maxFee).build();
    Account signer = config().getDefaultAccount();
    SignedTransaction signedTransaction = transferTransaction.signWith(signer, getGenerationHash());
    get(transactionRepository.announce(signedTransaction));
    get(getListener(type).unconfirmedAdded(signer.getAddress(), signedTransaction.getHash()).take(1));
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionGroup group = TransactionGroup.UNCONFIRMED;
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(group);
    criteria.transactionTypes(Collections.singletonList(TransactionType.TRANSFER));
    List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
    transactions.forEach(b -> Assertions.assertEquals(TransactionType.TRANSFER, b.getType()));
    Assertions.assertTrue(transactions.stream().filter(t -> t.getTransactionInfo().get().getHash().get().equals(signedTransaction.getHash())).findAny().isPresent());
    helper.assertById(transactionRepository, group, transactions);
}
Also used : TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) Arrays(java.util.Arrays) Account(io.nem.symbol.sdk.model.account.Account) ConvertUtils(io.nem.symbol.core.utils.ConvertUtils) EnumSource(org.junit.jupiter.params.provider.EnumSource) ArrayList(java.util.ArrayList) TestInstance(org.junit.jupiter.api.TestInstance) Message(io.nem.symbol.sdk.model.message.Message) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) Collectors(java.util.stream.Collectors) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) PublicKey(io.nem.symbol.core.crypto.PublicKey) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) Assertions(org.junit.jupiter.api.Assertions) Address(io.nem.symbol.sdk.model.account.Address) Collections(java.util.Collections) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) Account(io.nem.symbol.sdk.model.account.Account) Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchUsingOffset.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUsingOffset(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
    criteria.setPageSize(10);
    int offsetIndex = 2;
    List<Transaction> transactionsWithoutOffset = get(streamer.search(criteria).toList().toObservable());
    criteria.setOffset(transactionsWithoutOffset.get(offsetIndex).getRecordId().get());
    List<Transaction> transactionFromOffsets = get(streamer.search(criteria).toList().toObservable());
    PaginationTester.sameEntities(transactionsWithoutOffset.stream().skip(offsetIndex + 1).collect(Collectors.toList()), transactionFromOffsets);
    helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactionFromOffsets);
    helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactionsWithoutOffset);
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchByTransactionHeight.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByTransactionHeight(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
    criteria.height(BigInteger.ONE);
    criteria.embedded(true);
    List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
    transactions.forEach(b -> Assertions.assertEquals(BigInteger.ONE, b.getTransactionInfo().get().getHeight()));
    Assertions.assertFalse(transactions.isEmpty());
    helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)397 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)393 Account (io.nem.symbol.sdk.model.account.Account)40 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)38 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)34 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)34 Address (io.nem.symbol.sdk.model.account.Address)30 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)27 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)26 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)26 BigInteger (java.math.BigInteger)25 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)23 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)23 EntityUpdates (org.neo4j.storageengine.api.EntityUpdates)21 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)19 Path (java.nio.file.Path)18 ArrayList (java.util.ArrayList)16 Listener (io.nem.symbol.sdk.api.Listener)15 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)15 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)14