use of io.nem.symbol.sdk.api.RepositoryFactoryConfiguration 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.RepositoryFactoryConfiguration 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.RepositoryFactoryConfiguration 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.RepositoryFactoryConfiguration 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.RepositoryFactoryConfiguration in project nem2-sdk-java by nemtech.
the class RepositoryFactoryOkHttpImplTest 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 RepositoryFactoryOkHttpImpl(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());
}
Aggregations