use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class MosaicRepositoryIntegrationTest method searchByOwnerAddressInvalid.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByOwnerAddressInvalid(RepositoryType type) {
MosaicSearchCriteria criteria = new MosaicSearchCriteria();
Address address = Account.generateNewAccount(getNetworkType()).getAddress();
criteria.ownerAddress(address);
MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(getMosaicRepository(type));
List<MosaicInfo> mosaics = get(streamer.search(criteria).toList().toObservable());
Assertions.assertTrue(mosaics.isEmpty());
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class MosaicRepositoryIntegrationTest method searchByOwnerAddress.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByOwnerAddress(RepositoryType type) {
MosaicSearchCriteria criteria = new MosaicSearchCriteria();
Address address = testAccount.getAddress();
criteria.ownerAddress(address);
MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(getMosaicRepository(type));
List<MosaicInfo> mosaics = get(streamer.search(criteria).toList().toObservable());
mosaics.forEach(m -> Assertions.assertEquals(address, m.getOwnerAddress()));
Assertions.assertFalse(mosaics.isEmpty());
}
use of io.nem.symbol.sdk.model.account.Address 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);
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class TransferTransactionIntegrationTest method transferTransactionNotEnoughFundAccount.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void transferTransactionNotEnoughFundAccount(RepositoryType type) {
Address recipient = config().getTestAccount2().getAddress();
NetworkType networkType = getNetworkType();
Account account = Account.generateNewAccount(networkType);
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1000000000)))).message(new PlainMessage("")).maxFee(maxFee).build();
IllegalArgumentException exceptions = Assertions.assertThrows(IllegalArgumentException.class, () -> announceAndValidate(type, account, transferTransaction));
Assertions.assertTrue(exceptions.getMessage().contains("Failure_Core_Insufficient_Balance"));
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class TransactionRepositoryIntegrationTest method setup.
@BeforeAll
void setup() {
RepositoryType type = RepositoryType.VERTX;
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
Address recipient = getRecipient();
String message = "someMessage";
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage(message)).maxFee(maxFee).build();
TransferTransaction processed = announceAndValidate(type, config().getDefaultAccount(), transferTransaction);
Assertions.assertEquals(message, processed.getMessage().get().getText());
PublicAccount account = config().getDefaultAccount().getPublicAccount();
List<Transaction> allTransactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).order(OrderBy.DESC).signerPublicKey(account.getPublicKey()))).getData();
List<Transaction> transactions = allTransactions.stream().filter(t -> t.getType() == TransactionType.TRANSFER).collect(Collectors.toList());
Assertions.assertTrue(allTransactions.size() > 0);
Assertions.assertTrue(transactions.size() > 0);
transactionHash = transactions.get(0).getTransactionInfo().get().getHash().get();
}
Aggregations