use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class RepositoryFactoryConfigurationExamplesIntegrationTest method bootAppUsingLegacyHardcodedCurrencies.
@Test
void bootAppUsingLegacyHardcodedCurrencies() throws ExecutionException, InterruptedException {
// Option 3) Client app boot time relaying on some of the rest configuration.
// User uses the
// legacy hardcoded sdk currencies
RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration("http://localhost:3000");
configuration.withNetworkCurrencies(new NetworkCurrencies(Currency.CAT_CURRENCY, Currency.CAT_HARVEST));
try (RepositoryFactory repositoryFactory = new RepositoryFactoryVertxImpl(configuration)) {
appDoSomeStuff(repositoryFactory);
}
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class RepositoryFactoryConfigurationExamplesIntegrationTest method bootAppFullyOffline.
@Test
void bootAppFullyOffline() throws ExecutionException, InterruptedException {
// Option 1) Client app boot time. The clients defines the configuration to work
// offline.
RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration("http://localhost:3000");
configuration.withNetworkType(NetworkType.MAIN_NET);
configuration.withGenerationHash("abc");
Currency currency = new CurrencyBuilder(NamespaceId.createFromName("my.custom.currency"), 6).build();
Currency harvest = new CurrencyBuilder(NamespaceId.createFromName("my.custom.harvest"), 3).build();
configuration.withNetworkCurrencies(new NetworkCurrencies(currency, harvest));
try (RepositoryFactory repositoryFactory = new RepositoryFactoryVertxImpl(configuration)) {
appDoSomeStuff(repositoryFactory);
}
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class RestrictionMosaicRepositoryIntegrationTest method searchAddressRestriction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchAddressRestriction(RepositoryType type) {
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
RestrictionMosaicRepository repository = repositoryFactory.createRestrictionMosaicRepository();
MosaicRestrictionEntryType entryType = MosaicRestrictionEntryType.ADDRESS;
Page<MosaicRestriction<?>> page = get(repository.search(new MosaicRestrictionSearchCriteria().entryType(entryType)));
System.out.println(page.getData().size());
page.getData().forEach(restriction -> {
Assertions.assertTrue(restriction instanceof MosaicAddressRestriction);
Assertions.assertEquals(entryType, restriction.getEntryType());
Assertions.assertNotNull(restriction.getMosaicId());
Assertions.assertNotNull(restriction.getCompositeHash());
Assertions.assertFalse(restriction.getRestrictions().isEmpty());
Assertions.assertNotNull(((MosaicAddressRestriction) restriction).getTargetAddress());
});
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class RepositoryFactoryOkHttpImplTest method getRestProvidedNetworkCurrencies.
@Test
public void getRestProvidedNetworkCurrencies() throws Exception {
String baseUrl = "https://localhost:1934/path";
RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration(baseUrl);
configuration.withGenerationHash("abc");
configuration.withNetworkType(NetworkType.MAIN_NET);
RepositoryFactory factory = new RepositoryFactoryOkHttpImpl(configuration) {
@Override
protected Observable<NetworkCurrencies> loadNetworkCurrencies() {
return Observable.just(new NetworkCurrencies(Currency.CAT_CURRENCY, Currency.CAT_HARVEST));
}
};
Assertions.assertEquals(configuration.getNetworkType(), factory.getNetworkType().toFuture().get());
Assertions.assertEquals(configuration.getGenerationHash(), factory.getGenerationHash().toFuture().get());
Assertions.assertEquals(Currency.CAT_HARVEST, factory.getHarvestCurrency().toFuture().get());
Assertions.assertEquals(Currency.CAT_CURRENCY, factory.getNetworkCurrency().toFuture().get());
}
use of io.nem.symbol.sdk.api.RepositoryFactory in project nem2-sdk-java by nemtech.
the class RepositoryFactoryOkHttpImplTest method shouldCreateRepositories.
@Test
public void shouldCreateRepositories() {
String baseUrl = "https://nem.com:3000/path";
RepositoryFactory factory = new RepositoryFactoryOkHttpImpl(baseUrl);
Assertions.assertNotNull(factory.createAccountRepository());
Assertions.assertNotNull(factory.createBlockRepository());
Assertions.assertNotNull(factory.createReceiptRepository());
Assertions.assertNotNull(factory.createChainRepository());
Assertions.assertNotNull(factory.createListener());
Assertions.assertNotNull(factory.createMosaicRepository());
Assertions.assertNotNull(factory.createNamespaceRepository());
Assertions.assertNotNull(factory.createNetworkRepository());
Assertions.assertNotNull(factory.createNodeRepository());
Assertions.assertNotNull(factory.createTransactionRepository());
Assertions.assertNotNull(factory.createTransactionStatusRepository());
Assertions.assertNotNull(factory.createMetadataRepository());
Assertions.assertNotNull(factory.createRestrictionAccountRepository());
Assertions.assertNotNull(factory.createRestrictionMosaicRepository());
Assertions.assertNotNull(factory.createHashLockRepository());
Assertions.assertNotNull(factory.createSecretLockRepository());
Assertions.assertNotNull(factory.createMultisigRepository());
Assertions.assertNotNull(factory.createFinalizationRepository());
Assertions.assertNotNull(factory.createJsonSerialization());
factory.close();
factory.close();
factory.close();
}
Aggregations