Search in sources :

Example 26 with RepositoryFactory

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

the class MerkleLoaderIntegrationTest method accountRestrictions.

public List<Arguments> accountRestrictions() {
    RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
    RestrictionAccountRepository repository = repositoryFactory.createRestrictionAccountRepository();
    return getArguments(repository, new AccountRestrictionSearchCriteria());
}
Also used : AccountRestrictionSearchCriteria(io.nem.symbol.sdk.api.AccountRestrictionSearchCriteria) RestrictionAccountRepository(io.nem.symbol.sdk.api.RestrictionAccountRepository) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory)

Example 27 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory 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 28 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory 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 29 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory 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)

Example 30 with RepositoryFactory

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

the class FinalizationRepositoryIntegrationTest method getFinalizationProofAtCurrentFinalizedHeight.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getFinalizationProofAtCurrentFinalizedHeight(RepositoryType type) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    FinalizedBlock finalizedBlock = get(repositoryFactory.createChainRepository().getChainInfo()).getLatestFinalizedBlock();
    FinalizationRepository repository = repositoryFactory.createFinalizationRepository();
    FinalizationProof finalizationProof = get(repository.getFinalizationProofAtHeight(finalizedBlock.getHeight()));
    Assertions.assertEquals(finalizationProof.getFinalizationEpoch(), finalizationProof.getFinalizationEpoch());
    Assertions.assertEquals(finalizationProof.getFinalizationPoint(), finalizationProof.getFinalizationPoint());
    Assertions.assertEquals(finalizationProof.getHeight(), finalizationProof.getHeight());
    Assertions.assertEquals(1, finalizationProof.getVersion());
}
Also used : FinalizationProof(io.nem.symbol.sdk.model.finalization.FinalizationProof) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) FinalizedBlock(io.nem.symbol.sdk.model.blockchain.FinalizedBlock) FinalizationRepository(io.nem.symbol.sdk.api.FinalizationRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)44 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 EnumSource (org.junit.jupiter.params.provider.EnumSource)16 Test (org.junit.jupiter.api.Test)11 BeforeEach (org.junit.jupiter.api.BeforeEach)7 RepositoryFactoryConfiguration (io.nem.symbol.sdk.api.RepositoryFactoryConfiguration)6 Account (io.nem.symbol.sdk.model.account.Account)6 BigInteger (java.math.BigInteger)6 Listener (io.nem.symbol.sdk.api.Listener)5 MetadataRepository (io.nem.symbol.sdk.api.MetadataRepository)5 NamespaceRepository (io.nem.symbol.sdk.api.NamespaceRepository)5 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)5 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)5 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)4 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)4 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)4 CurrencyService (io.nem.symbol.sdk.api.CurrencyService)3 MetadataTransactionService (io.nem.symbol.sdk.api.MetadataTransactionService)3 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)3 TransactionService (io.nem.symbol.sdk.api.TransactionService)3