use of io.nem.symbol.sdk.model.mosaic.Currency in project nem2-sdk-java by nemtech.
the class CurrencyServiceTest method getNetworkCurrencyFromMosaicIdWhenNoNamespace.
@Test
void getNetworkCurrencyFromMosaicIdWhenNoNamespace() throws Exception {
MosaicId mosaicId = new MosaicId(BigInteger.TEN);
Account account = Account.generateNewAccount(NetworkType.MAIN_NET);
BigInteger supply = BigInteger.valueOf(12);
MosaicInfo mosaicInfo = new MosaicInfo("abc", 1, mosaicId, supply, BigInteger.ONE, account.getAddress(), 4L, MosaicFlags.create(true, true, true), 10, BigInteger.TEN);
Mockito.when(mosaicRepository.getMosaics(Mockito.eq(Arrays.asList(mosaicId)))).thenReturn(Observable.just(Arrays.asList(mosaicInfo)));
Mockito.when(namespaceRepository.getMosaicsNames(Mockito.eq(Collections.singletonList(mosaicId)))).thenReturn(Observable.just(Collections.emptyList()));
Currency currency = service.getCurrency(mosaicId).toFuture().get();
Assertions.assertEquals(10, currency.getDivisibility());
Assertions.assertEquals(mosaicId, currency.getUnresolvedMosaicId());
Assertions.assertEquals(mosaicId, currency.getMosaicId().get());
Assertions.assertFalse(currency.getNamespaceId().isPresent());
Assertions.assertTrue(currency.isTransferable());
Assertions.assertTrue(currency.isSupplyMutable());
}
use of io.nem.symbol.sdk.model.mosaic.Currency 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.Currency 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