Search in sources :

Example 1 with RepositoryFactoryConfiguration

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);
    }
}
Also used : NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) RepositoryFactoryConfiguration(io.nem.symbol.sdk.api.RepositoryFactoryConfiguration) RepositoryFactoryVertxImpl(io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl) Test(org.junit.jupiter.api.Test)

Example 2 with RepositoryFactoryConfiguration

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);
    }
}
Also used : CurrencyBuilder(io.nem.symbol.sdk.model.mosaic.CurrencyBuilder) Currency(io.nem.symbol.sdk.model.mosaic.Currency) NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) RepositoryFactoryConfiguration(io.nem.symbol.sdk.api.RepositoryFactoryConfiguration) RepositoryFactoryVertxImpl(io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl) Test(org.junit.jupiter.api.Test)

Example 3 with RepositoryFactoryConfiguration

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());
}
Also used : NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) RepositoryFactoryConfiguration(io.nem.symbol.sdk.api.RepositoryFactoryConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with RepositoryFactoryConfiguration

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());
}
Also used : RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) RepositoryFactoryConfiguration(io.nem.symbol.sdk.api.RepositoryFactoryConfiguration) Test(org.junit.jupiter.api.Test)

Example 5 with RepositoryFactoryConfiguration

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());
}
Also used : RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) RepositoryFactoryConfiguration(io.nem.symbol.sdk.api.RepositoryFactoryConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)6 RepositoryFactoryConfiguration (io.nem.symbol.sdk.api.RepositoryFactoryConfiguration)6 Test (org.junit.jupiter.api.Test)6 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)4 RepositoryFactoryVertxImpl (io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl)2 Currency (io.nem.symbol.sdk.model.mosaic.Currency)1 CurrencyBuilder (io.nem.symbol.sdk.model.mosaic.CurrencyBuilder)1