Search in sources :

Example 61 with EnumSource

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

the class AccountRepositoryIntegrationTest method outgoingTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void outgoingTransactions(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    PublicAccount recipient = this.helper().getTestAccount(type).getLeft().getPublicAccount();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.TRANSFER)).recipientAddress(recipient.getAddress()))).getData();
    System.out.println(transactions.size());
    transactions.forEach(transaction -> {
        assertTransaction(transaction, null);
        TransferTransaction transferTransaction = (TransferTransaction) transaction;
        Assertions.assertEquals(recipient.getAddress(), transferTransaction.getRecipient());
    });
}
Also used : Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 62 with EnumSource

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

the class AccountRepositoryIntegrationTest method getAccountInfoNotExisting.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAccountInfoNotExisting(RepositoryType type) {
    AccountRepository accountHttp = getRepositoryFactory(type).createAccountRepository();
    Address addressObject = Address.createFromPublicKey("67F69FA4BFCD158F6E1AF1ABC82F725F5C5C4710D6E29217B12BE66397435DFB", getNetworkType());
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(accountHttp.getAccountInfo(addressObject)));
    Assertions.assertTrue(exception.getMessage().contains("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id"));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 63 with EnumSource

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

the class AccountRepositoryIntegrationTest method getMultipleTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMultipleTransactions(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    Account account = config().getDefaultAccount();
    List<TransactionType> transactionTypes = Arrays.asList(TransactionType.TRANSFER, TransactionType.AGGREGATE_COMPLETE, TransactionType.NAMESPACE_METADATA);
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).transactionTypes(transactionTypes))).getData();
    Assertions.assertFalse(transactions.isEmpty());
    transactions.forEach(t -> Assertions.assertTrue(transactionTypes.contains(t.getType())));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 64 with EnumSource

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

the class AccountSearchRepositoryIntegrationTest method searchMosaicIdProvided.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchMosaicIdProvided(RepositoryType type) {
    AccountPaginationStreamer streamer = new AccountPaginationStreamer(this.getAccountRepository(type));
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    NamespaceId networkCurrencyId = get(repositoryFactory.getNetworkCurrency()).getNamespaceId().get();
    Assertions.assertTrue(networkCurrencyId.getFullName().isPresent());
    MosaicId mosaicId = get(repositoryFactory.createNamespaceRepository().getLinkedMosaicId(networkCurrencyId));
    AccountSearchCriteria criteria = new AccountSearchCriteria().mosaicId(mosaicId);
    List<AccountInfo> accounts = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertFalse(accounts.isEmpty());
    System.out.println(toJson(accounts));
    accounts.forEach(a -> {
        Assertions.assertTrue(a.getMosaics().stream().filter(m -> m.getId().equals(mosaicId)).findFirst().get().getAmount().longValue() > 0);
    });
}
Also used : AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) AccountPaginationStreamer(io.nem.symbol.sdk.api.AccountPaginationStreamer) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 65 with EnumSource

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

the class AccountSearchRepositoryIntegrationTest method searchNoMosaicIdProvided.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchNoMosaicIdProvided(RepositoryType type) {
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(this.getAccountRepository(type).search(new AccountSearchCriteria().orderBy(AccountOrderBy.BALANCE))));
    Assertions.assertEquals("ApiException: Conflict - 409 - InvalidArgument - mosaicId must be provided when sorting by balance", exception.getMessage());
}
Also used : AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)1634 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1629 Objs (io.github.mianalysis.mia.object.Objs)238 Obj (io.github.mianalysis.mia.object.Obj)232 SpatCal (io.github.sjcross.common.object.volume.SpatCal)174 Workspace (io.github.mianalysis.mia.object.Workspace)112 Workspaces (io.github.mianalysis.mia.object.Workspaces)112 JavaFileObject (javax.tools.JavaFileObject)108 Compilation (io.jbock.testing.compile.Compilation)102 Point (io.github.sjcross.common.object.Point)88 ArrayList (java.util.ArrayList)85 ImagePlus (ij.ImagePlus)84 Objects3D (io.github.mianalysis.mia.expectedobjects.Objects3D)82 Image (io.github.mianalysis.mia.object.Image)82 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)58 Path (java.nio.file.Path)44 HashMap (java.util.HashMap)43 Account (io.nem.symbol.sdk.model.account.Account)40 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)38 List (java.util.List)38