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())));
}
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());
}
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());
}
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());
}
Aggregations