use of io.nem.symbol.sdk.api.RepositoryFactory 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);
});
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnAggregateBondedAddedTransactionViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnAggregateBondedAddedTransactionViaListener(RepositoryType type) {
Listener listener = getListener(type);
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
Pair<SignedTransaction, SignedTransaction> pair = this.createAggregateBondedTransaction(type);
System.out.println("Announcing HashLock transaction " + pair.getRight().getHash());
get(transactionService.announce(listener, pair.getRight()));
SignedTransaction signedTransaction = pair.getLeft();
System.out.println("Announcing Aggregate transaction " + signedTransaction.getHash());
AggregateTransaction aggregateTransaction = get(transactionService.announceAggregateBonded(listener, signedTransaction).take(1));
assertEquals(signedTransaction.getHash(), aggregateTransaction.getTransactionInfo().get().getHash().get());
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class BlockServiceIntegrationTest method isValidTransactionInBlock.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void isValidTransactionInBlock(RepositoryType type) {
BigInteger height = BigInteger.ONE;
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).height(height).pageNumber(1))).getData();
BlockService service = new BlockServiceImpl(repositoryFactory);
transactions.forEach(t -> {
String hash = t.getTransactionInfo().get().getHash().get();
Assertions.assertNotNull(hash);
Boolean valid = get(service.isValidTransactionInBlock(height, hash));
Assertions.assertTrue(valid);
});
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class RepositoryFactoryVertxImplTest method getUserProvidedConfiguration.
@Test
public void getUserProvidedConfiguration() throws Exception {
String baseUrl = "https://localhost:1934/path";
RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration(baseUrl);
configuration.withGenerationHash("abc");
configuration.withNetworkType(NetworkType.MAIN_NET);
configuration.withNetworkCurrencies(NetworkCurrencies.PUBLIC);
RepositoryFactory factory = new RepositoryFactoryVertxImpl(configuration);
Assertions.assertEquals(configuration.getNetworkType(), factory.getNetworkType().toFuture().get());
Assertions.assertEquals(configuration.getGenerationHash(), factory.getGenerationHash().toFuture().get());
Assertions.assertEquals(configuration.getNetworkCurrencies().getHarvest(), factory.getHarvestCurrency().toFuture().get());
Assertions.assertEquals(configuration.getNetworkCurrencies().getCurrency(), factory.getNetworkCurrency().toFuture().get());
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method setup.
@BeforeEach
void setup() {
account = Account.generateNewAccount(networkType);
RepositoryFactory factory = Mockito.mock(RepositoryFactory.class);
transactionRepositoryMock = Mockito.mock(TransactionRepository.class);
Mockito.when(factory.createTransactionRepository()).thenReturn(transactionRepositoryMock);
receiptRepositoryMock = Mockito.mock(ReceiptRepository.class);
Mockito.when(factory.createReceiptRepository()).thenReturn(receiptRepositoryMock);
listener = Mockito.mock(Listener.class);
service = new TransactionServiceImpl(factory);
}
Aggregations