use of io.nem.symbol.sdk.model.network.ChainProperties in project nem2-sdk-java by nemtech.
the class CurrencyServiceTest method getNetworkCurrencies.
@Test
void getNetworkCurrencies() throws Exception {
NetworkConfiguration networkConfiguration = Mockito.mock(NetworkConfiguration.class);
ChainProperties chainProperties = Mockito.mock(ChainProperties.class);
String currencyMosaicIdHex = "0x62EF'46FD'6555'AAAA";
MosaicId currencyMosaicId = new MosaicId(FormatUtils.toSimpleHex(currencyMosaicIdHex));
Mockito.when(chainProperties.getCurrencyMosaicId()).thenReturn(currencyMosaicIdHex);
String harvestMosaicIdHex = "0x62EF'46FD'6555'BBBB";
MosaicId harvestMosaicId = new MosaicId(FormatUtils.toSimpleHex(harvestMosaicIdHex));
Mockito.when(chainProperties.getHarvestingMosaicId()).thenReturn(harvestMosaicIdHex);
Mockito.when(networkConfiguration.getChain()).thenReturn(chainProperties);
Mockito.when(networkRepository.getNetworkProperties()).thenReturn(Observable.just(networkConfiguration));
Address account = Address.generateRandom(NetworkType.MIJIN_TEST);
MosaicInfo currencyMosaicInfo = new MosaicInfo("abc", 1, currencyMosaicId, BigInteger.valueOf(100), BigInteger.ONE, account, 4L, MosaicFlags.create(false, true, false), 10, BigInteger.TEN);
MosaicInfo harvestMosaicInfo = new MosaicInfo("abc", 1, harvestMosaicId, BigInteger.valueOf(200), BigInteger.ONE, account, 4L, MosaicFlags.create(true, false, true), 3, BigInteger.TEN);
Mockito.when(mosaicRepository.getMosaics(Mockito.eq(Arrays.asList(currencyMosaicId, harvestMosaicId)))).thenReturn(Observable.just(Arrays.asList(currencyMosaicInfo, harvestMosaicInfo)));
Mockito.when(namespaceRepository.getMosaicsNames(Mockito.eq(Arrays.asList(currencyMosaicId, harvestMosaicId)))).thenReturn(Observable.just(Collections.emptyList()));
NetworkCurrencies networkCurrencies = service.getNetworkCurrencies().toFuture().get();
Assertions.assertEquals(currencyMosaicInfo.toCurrency(), networkCurrencies.getCurrency());
Assertions.assertEquals(harvestMosaicInfo.toCurrency(), networkCurrencies.getHarvest());
}
Aggregations