Search in sources :

Example 1 with RepositoryCallException

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

the class MosaicRepositoryIntegrationTest method throwExceptionWhenMosaicDoesNotExists.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void throwExceptionWhenMosaicDoesNotExists(RepositoryType type) {
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(getMosaicRepository(type).getMosaic(new MosaicId("AAAAAE18BE375DA2"))));
    Assertions.assertEquals("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id 'AAAAAE18BE375DA2'", exception.getMessage());
}
Also used : RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with RepositoryCallException

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

the class HashLockRepositoryIntegrationTest method getHashLockWhenDoesNotExist.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getHashLockWhenDoesNotExist(RepositoryType type) {
    HashLockRepository HashLockRepository = getRepositoryFactory(type).createHashLockRepository();
    String hash = "671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96";
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(HashLockRepository.getHashLock(hash)));
    Assertions.assertTrue(exception.getMessage().contains("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id"));
}
Also used : RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) HashLockRepository(io.nem.symbol.sdk.api.HashLockRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with RepositoryCallException

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

the class HashLockRepositoryIntegrationTest method getHashLockWhenInvalid.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getHashLockWhenInvalid(RepositoryType type) {
    HashLockRepository HashLockRepository = getRepositoryFactory(type).createHashLockRepository();
    String hash = "invalid!";
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(HashLockRepository.getHashLock(hash)));
    Assertions.assertEquals("ApiException: Conflict - 409 - InvalidArgument - hash has an invalid format", exception.getMessage());
}
Also used : RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) HashLockRepository(io.nem.symbol.sdk.api.HashLockRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with RepositoryCallException

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

the class AccountRepositoryIntegrationTest method getAccountInfoNotExisting.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAccountInfoNotExisting(RepositoryType type) {
    AccountRepository accountHttp = getRepositoryFactory(type).createAccountRepository();
    Address addressObject = Address.createFromPublicKey("67F69FA4BFCD158F6E1AF1ABC82F725F5C5C4710D6E29217B12BE66397435DFB", getNetworkType());
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(accountHttp.getAccountInfo(addressObject)));
    Assertions.assertTrue(exception.getMessage().contains("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id"));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with RepositoryCallException

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

the class AccountSearchRepositoryIntegrationTest method searchNoMosaicIdProvided.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchNoMosaicIdProvided(RepositoryType type) {
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(this.getAccountRepository(type).search(new AccountSearchCriteria().orderBy(AccountOrderBy.BALANCE))));
    Assertions.assertEquals("ApiException: Conflict - 409 - InvalidArgument - mosaicId must be provided when sorting by balance", exception.getMessage());
}
Also used : AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RepositoryCallException (io.nem.symbol.sdk.api.RepositoryCallException)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 EnumSource (org.junit.jupiter.params.provider.EnumSource)13 Test (org.junit.jupiter.api.Test)10 BigInteger (java.math.BigInteger)4 MetadataSearchCriteria (io.nem.symbol.sdk.api.MetadataSearchCriteria)3 Address (io.nem.symbol.sdk.model.account.Address)3 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)3 AccountRepository (io.nem.symbol.sdk.api.AccountRepository)2 CurrencyService (io.nem.symbol.sdk.api.CurrencyService)2 HashLockRepository (io.nem.symbol.sdk.api.HashLockRepository)2 MultisigRepository (io.nem.symbol.sdk.api.MultisigRepository)2 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)2 TestHelperVertx.loadTransactionInfoDTO (io.nem.symbol.sdk.infrastructure.vertx.TestHelperVertx.loadTransactionInfoDTO)2 MultisigAccountInfo (io.nem.symbol.sdk.model.account.MultisigAccountInfo)2 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)2 AnnounceTransactionInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO)2 TransactionInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO)2 TransactionMetaDTO (io.nem.symbol.sdk.openapi.vertx.model.TransactionMetaDTO)2 AccountSearchCriteria (io.nem.symbol.sdk.api.AccountSearchCriteria)1