Search in sources :

Example 1 with AccountLinkPublicKeyDTO

use of io.nem.symbol.sdk.openapi.vertx.model.AccountLinkPublicKeyDTO 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)

Example 2 with AccountLinkPublicKeyDTO

use of io.nem.symbol.sdk.openapi.vertx.model.AccountLinkPublicKeyDTO in project nem2-sdk-java by nemtech.

the class AccountRepositoryVertxImplTest method shouldGetAccountsInfoFromAddresses.

@Test
public void shouldGetAccountsInfoFromAddresses() throws ExecutionException, InterruptedException {
    Account account = Account.generateNewAccount(this.networkType);
    Account nodeAccount = Account.generateNewAccount(this.networkType);
    Address address = account.getAddress();
    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(Collections.singletonList(accountInfoDTO));
    List<AccountInfo> resolvedAccountInfos = repository.getAccountsInfo(Collections.singletonList(address)).toFuture().get();
    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) 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)2 AccountInfo (io.nem.symbol.sdk.model.account.AccountInfo)2 Address (io.nem.symbol.sdk.model.account.Address)2 AccountDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountDTO)2 AccountInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountInfoDTO)2 AccountLinkPublicKeyDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountLinkPublicKeyDTO)2 ActivityBucketDTO (io.nem.symbol.sdk.openapi.vertx.model.ActivityBucketDTO)2 SupplementalPublicKeysDTO (io.nem.symbol.sdk.openapi.vertx.model.SupplementalPublicKeysDTO)2 BigInteger (java.math.BigInteger)2 Test (org.junit.jupiter.api.Test)2 AccountSearchCriteria (io.nem.symbol.sdk.api.AccountSearchCriteria)1