Search in sources :

Example 6 with NetworkCurrencies

use of io.nem.symbol.sdk.model.mosaic.NetworkCurrencies in project nem2-sdk-java by nemtech.

the class CurrencyServiceIntegrationTest method getNetworkCurrencies.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getNetworkCurrencies(RepositoryType type) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    CurrencyService service = new CurrencyServiceImpl(repositoryFactory);
    NetworkCurrencies networkCurrencies = get(service.getNetworkCurrencies());
    Assertions.assertNotNull(networkCurrencies.getCurrency());
    Assertions.assertEquals(networkCurrencies.getCurrency().getUnresolvedMosaicId(), networkCurrencies.getCurrency().getMosaicId().get());
    Assertions.assertNotNull(networkCurrencies.getCurrency().getMosaicId().get());
    Assertions.assertEquals(networkCurrencies.getCurrency(), (get(repositoryFactory.getNetworkCurrency())));
    Assertions.assertNotNull(networkCurrencies.getHarvest());
    Assertions.assertEquals(networkCurrencies.getHarvest().getUnresolvedMosaicId(), networkCurrencies.getHarvest().getMosaicId().get());
    Assertions.assertNotNull(networkCurrencies.getHarvest().getMosaicId().get());
    Assertions.assertEquals(networkCurrencies.getHarvest(), (get(repositoryFactory.getHarvestCurrency())));
}
Also used : NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CurrencyService(io.nem.symbol.sdk.api.CurrencyService) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with NetworkCurrencies

use of io.nem.symbol.sdk.model.mosaic.NetworkCurrencies in project nem2-sdk-java by nemtech.

the class RepositoryFactoryVertxImplTest 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 RepositoryFactoryVertxImpl(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 8 with NetworkCurrencies

use of io.nem.symbol.sdk.model.mosaic.NetworkCurrencies in project nem2-sdk-java by nemtech.

the class RepositoryFactoryConfigurationTest method constructorAndSet.

@Test
void constructorAndSet() {
    RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration("http://localhost:3000");
    configuration.setNetworkType(NetworkType.MAIN_NET);
    configuration.setGenerationHash("abc");
    Currency currency = new CurrencyBuilder(NamespaceId.createFromName("my.custom.currency"), 6).build();
    Duration epochAdjustment = Duration.ofMillis(100L);
    configuration.setEpochAdjustment(epochAdjustment);
    Currency harvest = new CurrencyBuilder(NamespaceId.createFromName("my.custom.harvest"), 3).build();
    configuration.setNetworkCurrencies(new NetworkCurrencies(currency, harvest));
    Assertions.assertEquals(Duration.ofMillis(100L), configuration.getEpochAdjustment());
    Assertions.assertEquals("http://localhost:3000", configuration.getBaseUrl());
    Assertions.assertEquals("abc", configuration.getGenerationHash());
    Assertions.assertEquals(NetworkType.MAIN_NET, configuration.getNetworkType());
    Assertions.assertEquals(currency, configuration.getNetworkCurrencies().getCurrency());
    Assertions.assertEquals(harvest, configuration.getNetworkCurrencies().getHarvest());
}
Also used : CurrencyBuilder(io.nem.symbol.sdk.model.mosaic.CurrencyBuilder) Currency(io.nem.symbol.sdk.model.mosaic.Currency) Duration(java.time.Duration) NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) Test(org.junit.jupiter.api.Test)

Example 9 with NetworkCurrencies

use of io.nem.symbol.sdk.model.mosaic.NetworkCurrencies in project nem2-sdk-java by nemtech.

the class RepositoryFactoryConfigurationTest method constructorAndWith.

@Test
void constructorAndWith() {
    RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration("http://localhost:3000");
    configuration.withNetworkType(NetworkType.MAIN_NET);
    configuration.withGenerationHash("abc");
    Duration epochAdjustment = Duration.ofMillis(100L);
    configuration.withEpochAdjustment(epochAdjustment);
    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));
    Assertions.assertEquals(epochAdjustment, configuration.getEpochAdjustment());
    Assertions.assertEquals("http://localhost:3000", configuration.getBaseUrl());
    Assertions.assertEquals("abc", configuration.getGenerationHash());
    Assertions.assertEquals(NetworkType.MAIN_NET, configuration.getNetworkType());
    Assertions.assertEquals(currency, configuration.getNetworkCurrencies().getCurrency());
    Assertions.assertEquals(harvest, configuration.getNetworkCurrencies().getHarvest());
}
Also used : CurrencyBuilder(io.nem.symbol.sdk.model.mosaic.CurrencyBuilder) Currency(io.nem.symbol.sdk.model.mosaic.Currency) Duration(java.time.Duration) NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) Test(org.junit.jupiter.api.Test)

Aggregations

NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)9 Test (org.junit.jupiter.api.Test)7 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)5 RepositoryFactoryConfiguration (io.nem.symbol.sdk.api.RepositoryFactoryConfiguration)4 Currency (io.nem.symbol.sdk.model.mosaic.Currency)4 CurrencyBuilder (io.nem.symbol.sdk.model.mosaic.CurrencyBuilder)3 RepositoryFactoryVertxImpl (io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl)2 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)2 Duration (java.time.Duration)2 CurrencyService (io.nem.symbol.sdk.api.CurrencyService)1 Address (io.nem.symbol.sdk.model.account.Address)1 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)1 UnresolvedMosaicId (io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)1 ChainProperties (io.nem.symbol.sdk.model.network.ChainProperties)1 NetworkConfiguration (io.nem.symbol.sdk.model.network.NetworkConfiguration)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1