Search in sources :

Example 1 with CurrencyService

use of io.nem.symbol.sdk.api.CurrencyService 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())));
}
Also used : NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CurrencyService(io.nem.symbol.sdk.api.CurrencyService) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CurrencyService

use of io.nem.symbol.sdk.api.CurrencyService in project nem2-sdk-java by nemtech.

the class CurrencyServiceIntegrationTest method testNetworkCurrencyInvalidNamespaceId.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void testNetworkCurrencyInvalidNamespaceId(RepositoryType type) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    CurrencyService service = new CurrencyServiceImpl(repositoryFactory);
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> {
        get(service.getCurrencyFromNamespaceId(NamespaceId.createFromName("invalid.currency")));
    });
    Assertions.assertEquals("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id 'C1DF8A076D934A50'", exception.getMessage());
}
Also used : RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CurrencyService(io.nem.symbol.sdk.api.CurrencyService) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with CurrencyService

use of io.nem.symbol.sdk.api.CurrencyService in project nem2-sdk-java by nemtech.

the class CurrencyServiceIntegrationTest method testNetworkCurrencyInvaliMosaicId.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void testNetworkCurrencyInvaliMosaicId(RepositoryType type) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    CurrencyService service = new CurrencyServiceImpl(repositoryFactory);
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> {
        get(service.getCurrency(new MosaicId(BigInteger.TEN)));
    });
    Assertions.assertEquals("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id '000000000000000A'", exception.getMessage());
}
Also used : RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CurrencyService(io.nem.symbol.sdk.api.CurrencyService) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CurrencyService (io.nem.symbol.sdk.api.CurrencyService)3 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 RepositoryCallException (io.nem.symbol.sdk.api.RepositoryCallException)2 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)1 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)1