use of io.nem.symbol.sdk.model.network.NetworkConfiguration in project nem2-sdk-java by nemtech.
the class NetworkRepositoryVertxImplTest method getNetworkProperties.
@Test
void getNetworkProperties() throws Exception {
NetworkConfigurationDTO dto = TestHelperVertx.loadResource("network-configuration.json", NetworkConfigurationDTO.class);
Assertions.assertNotNull(dto);
ObjectNode plain = TestHelperVertx.loadResource("network-configuration.json", ObjectNode.class);
Assertions.assertNotNull(plain);
Assertions.assertEquals(jsonHelper.prettyPrint(dto), jsonHelper.prettyPrint(plain));
mockRemoteCall(dto);
NetworkConfiguration configuration = repository.getNetworkProperties().toFuture().get();
Assertions.assertNotNull(configuration);
Map sorted = TestHelperVertx.loadResource("network-configuration.json", Map.class);
Assertions.assertNotNull(sorted);
((Map) sorted.get("network")).put("nodeEqualityStrategy", "PUBLIC_KEY");
Assertions.assertEquals(jsonHelper.prettyPrint(sorted), jsonHelper.prettyPrint(configuration));
}
use of io.nem.symbol.sdk.model.network.NetworkConfiguration in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceTest method getNetworkMaxCosignaturesPerAggregateWhenValidInvalid.
@Test
void getNetworkMaxCosignaturesPerAggregateWhenValidInvalid() {
NetworkConfiguration configuration = Mockito.mock(NetworkConfiguration.class);
PluginsProperties pluginsProperties = Mockito.mock(PluginsProperties.class);
AggregateNetworkProperties aggregateNetworkProperties = Mockito.mock(AggregateNetworkProperties.class);
Mockito.when(pluginsProperties.getAggregate()).thenReturn(aggregateNetworkProperties);
Mockito.when(configuration.getPlugins()).thenReturn(pluginsProperties);
Mockito.when(networkRepository.getNetworkProperties()).thenReturn(Observable.just(configuration));
IllegalStateException exception = Assertions.assertThrows(IllegalStateException.class, () -> ExceptionUtils.propagate(() -> service.getNetworkMaxCosignaturesPerAggregate().toFuture().get()));
Assertions.assertEquals("Cannot get maxCosignaturesPerAggregate from network properties.", exception.getMessage());
}
use of io.nem.symbol.sdk.model.network.NetworkConfiguration in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceTest method getNetworkMaxCosignaturesPerAggregateWhenValid.
@Test
void getNetworkMaxCosignaturesPerAggregateWhenValid() throws ExecutionException, InterruptedException {
NetworkConfiguration configuration = Mockito.mock(NetworkConfiguration.class);
PluginsProperties pluginsProperties = Mockito.mock(PluginsProperties.class);
AggregateNetworkProperties aggregateNetworkProperties = Mockito.mock(AggregateNetworkProperties.class);
Mockito.when(aggregateNetworkProperties.getMaxCosignaturesPerAggregate()).thenReturn("25");
Mockito.when(pluginsProperties.getAggregate()).thenReturn(aggregateNetworkProperties);
Mockito.when(configuration.getPlugins()).thenReturn(pluginsProperties);
Mockito.when(networkRepository.getNetworkProperties()).thenReturn(Observable.just(configuration));
Integer maxCosignaturesPerAggregate = service.getNetworkMaxCosignaturesPerAggregate().toFuture().get();
Assertions.assertEquals(25, maxCosignaturesPerAggregate);
}
use of io.nem.symbol.sdk.model.network.NetworkConfiguration 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());
}
use of io.nem.symbol.sdk.model.network.NetworkConfiguration in project nem2-sdk-java by nemtech.
the class NetworkRepositoryOkHttpImplTest method getNetworkProperties.
@Test
void getNetworkProperties() throws Exception {
NetworkConfigurationDTO dto = TestHelperOkHttp.loadResource("network-configuration.json", NetworkConfigurationDTO.class);
Assertions.assertNotNull(dto);
JsonObject plain = TestHelperOkHttp.loadResource("network-configuration.json", JsonObject.class);
Assertions.assertNotNull(plain);
Assertions.assertEquals(jsonHelper.prettyPrint(dto), jsonHelper.prettyPrint(plain));
mockRemoteCall(dto);
NetworkConfiguration configuration = repository.getNetworkProperties().toFuture().get();
Assertions.assertNotNull(configuration);
plain.get("network").getAsJsonObject().addProperty("nodeEqualityStrategy", "PUBLIC_KEY");
Assertions.assertEquals(jsonHelper.prettyPrint(plain), jsonHelper.prettyPrint(configuration));
}
Aggregations