Search in sources :

Example 26 with Account

use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.

the class AccountRepositoryIntegrationTest method outgoingTransactionsById.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void outgoingTransactionsById(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    Account account = config().getDefaultAccount();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
    Assertions.assertTrue(transactions.size() > 1);
    String id = transactions.get(1).getTransactionInfo().get().getId().get();
    List<Transaction> transactions2 = get(transactionRepository.getTransactions(TransactionGroup.CONFIRMED, Arrays.asList(id)));
    Assertions.assertEquals(1, transactions2.size());
    transactions2.forEach(t -> Assertions.assertEquals(id, t.getTransactionInfo().get().getId().get()));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) 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 27 with Account

use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.

the class AccountRepositoryIntegrationTest method getTransactionById.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getTransactionById(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    Account account = config().getDefaultAccount();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
    Assertions.assertTrue(transactions.size() > 0);
    String id = transactions.get(1).getTransactionInfo().get().getId().get();
    List<Transaction> transactions2 = get(transactionRepository.getTransactions(TransactionGroup.CONFIRMED, Arrays.asList(id)));
    Assertions.assertEquals(1, transactions2.size());
    transactions2.forEach(t -> Assertions.assertEquals(id, t.getTransactionInfo().get().getId().get()));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) 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 28 with Account

use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.

the class AAASetupIntegrationTest method createRootAndChild.

@Test
@Order(1)
void createRootAndChild() {
    Account account = config().getNemesisAccount();
    NamespaceRegistrationTransaction root = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), "root", helper.getDuration()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, root);
    NamespaceRegistrationTransaction child = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 29 with Account

use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.

the class AAASetupIntegrationTest method createNamespces.

@Test
@Order(1)
void createNamespces() {
    Account account = config().getNemesisAccount();
    NamespaceRegistrationTransaction root = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), "root3", helper.getDuration()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, root);
    NamespaceRegistrationTransaction child1 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child1", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child1);
    NamespaceRegistrationTransaction subchild1 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "subchild1", child1.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, subchild1);
    NamespaceRegistrationTransaction subchild2 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "subchild2", child1.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, subchild2);
    NamespaceRegistrationTransaction child2 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child2", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child2);
    NamespaceRegistrationTransaction child3 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child3", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child3);
    NamespaceRegistrationTransaction subchild3 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "subchild3", child1.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, subchild3);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 30 with Account

use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.

the class AccountRepositoryVertxImplTest method search.

@Test
public void search() throws Exception {
    Account account = Account.generateNewAccount(this.networkType);
    Address address = account.getAddress();
    Account nodeAccount = Account.generateNewAccount(this.networkType);
    AccountDTO accountDTO = new AccountDTO();
    accountDTO.setVersion(1);
    accountDTO.setAccountType(AccountTypeEnum.NUMBER_1);
    accountDTO.setAddress(encodeAddress(address));
    accountDTO.setAddressHeight(BigInteger.TEN);
    accountDTO.setPublicKeyHeight(BigInteger.valueOf(20));
    accountDTO.setPublicKey(account.getPublicAccount().getPublicKey().toHex());
    accountDTO.setImportance(BigInteger.valueOf(5));
    accountDTO.setImportanceHeight(BigInteger.valueOf(10));
    accountDTO.setSupplementalPublicKeys(new SupplementalPublicKeysDTO().node(new AccountLinkPublicKeyDTO().publicKey(nodeAccount.getPublicKey())));
    AccountInfoDTO accountInfoDTO = new AccountInfoDTO();
    accountInfoDTO.setAccount(accountDTO);
    BigInteger startHeight = BigInteger.ONE;
    BigInteger totalFeesPaid = BigInteger.valueOf(2);
    long beneficiaryCount = 3;
    BigInteger rawScore = BigInteger.valueOf(4);
    accountDTO.addActivityBucketsItem(new ActivityBucketDTO().startHeight(startHeight).totalFeesPaid(totalFeesPaid).beneficiaryCount(beneficiaryCount).rawScore(rawScore));
    mockRemoteCall(toPage(accountInfoDTO));
    List<AccountInfo> resolvedAccountInfos = repository.search(new AccountSearchCriteria().orderBy(AccountOrderBy.BALANCE)).toFuture().get().getData();
    Assertions.assertEquals(1, resolvedAccountInfos.size());
    AccountInfo resolvedAccountInfo = resolvedAccountInfos.get(0);
    Assertions.assertEquals(address, resolvedAccountInfo.getAddress());
    Assertions.assertEquals(AccountType.MAIN, resolvedAccountInfo.getAccountType());
    Assertions.assertEquals(nodeAccount.getPublicKey(), resolvedAccountInfo.getSupplementalAccountKeys().getNode().get().toHex());
    Assertions.assertEquals(1, resolvedAccountInfo.getActivityBuckets().size());
    Assertions.assertEquals(startHeight, resolvedAccountInfo.getActivityBuckets().get(0).getStartHeight());
    Assertions.assertEquals(totalFeesPaid, resolvedAccountInfo.getActivityBuckets().get(0).getTotalFeesPaid());
    Assertions.assertEquals(beneficiaryCount, resolvedAccountInfo.getActivityBuckets().get(0).getBeneficiaryCount());
    Assertions.assertEquals(rawScore, resolvedAccountInfo.getActivityBuckets().get(0).getRawScore());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) AccountLinkPublicKeyDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountLinkPublicKeyDTO) AccountInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountInfoDTO) AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) BigInteger(java.math.BigInteger) SupplementalPublicKeysDTO(io.nem.symbol.sdk.openapi.vertx.model.SupplementalPublicKeysDTO) AccountDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountDTO) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) ActivityBucketDTO(io.nem.symbol.sdk.openapi.vertx.model.ActivityBucketDTO) Test(org.junit.jupiter.api.Test)

Aggregations

Account (io.nem.symbol.sdk.model.account.Account)83 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)39 EnumSource (org.junit.jupiter.params.provider.EnumSource)36 Test (org.junit.jupiter.api.Test)29 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)26 BigInteger (java.math.BigInteger)21 Address (io.nem.symbol.sdk.model.account.Address)20 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)18 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)17 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)17 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)15 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)15 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)14 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)13 AccountInfo (io.nem.symbol.sdk.model.account.AccountInfo)11 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)9 Currency (io.nem.symbol.sdk.model.mosaic.Currency)9 NamespaceRegistrationTransaction (io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)9 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)8 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)7