Search in sources :

Example 11 with Currency

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());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Currency(io.nem.symbol.sdk.model.mosaic.Currency) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test)

Example 12 with Currency

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());
}
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 13 with Currency

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

Currency (io.nem.symbol.sdk.model.mosaic.Currency)13 Test (org.junit.jupiter.api.Test)8 Account (io.nem.symbol.sdk.model.account.Account)7 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)6 BigInteger (java.math.BigInteger)6 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)5 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)4 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)3 CurrencyBuilder (io.nem.symbol.sdk.model.mosaic.CurrencyBuilder)3 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)3 MosaicNames (io.nem.symbol.sdk.model.mosaic.MosaicNames)3 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)3 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)3 Duration (java.time.Duration)3 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)2 NamespaceName (io.nem.symbol.sdk.model.namespace.NamespaceName)2 ArrayList (java.util.ArrayList)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 KeyPair (io.nem.symbol.core.crypto.KeyPair)1 ConvertUtils (io.nem.symbol.core.utils.ConvertUtils)1