use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method throwExceptionWhenAddressDoesNotExist.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void throwExceptionWhenAddressDoesNotExist(RepositoryType type) {
Address address = Address.generateRandom(getNetworkType());
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(this.getAccountRepository(type).getAccountInfo(address)));
Assertions.assertEquals("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id '" + address.plain() + "'", exception.getMessage());
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class RepositoryFactoryVertxImplTest method getGenerationHashFailWhenInvalidServer.
@Test
public void getGenerationHashFailWhenInvalidServer() {
String baseUrl = "https://localhost:1934/path";
RepositoryCallException e = Assertions.assertThrows(RepositoryCallException.class, () -> GeneratorUtils.propagate(() -> new RepositoryFactoryVertxImpl(baseUrl).getNetworkType().toFuture().get()));
Assertions.assertTrue(e.getMessage().contains("ApiException: Connection refused"));
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method exceptionWhenRestCallFails.
@Test
public void exceptionWhenRestCallFails() {
TransactionInfoDTO transactionInfoDTO = new TransactionInfoDTO();
TransactionMetaDTO meta = new TransactionMetaDTO();
meta.setHash("ABC");
transactionInfoDTO.setMeta(meta);
mockErrorCode(400, "The error message");
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> {
ExceptionUtils.propagateVoid(() -> {
repository.getTransaction(TransactionGroup.CONFIRMED, meta.getHash()).toFuture().get();
});
});
Assertions.assertTrue(exception.getMessage().contains("The error message"));
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method exceptionWhenMapperFails.
@Test
public void exceptionWhenMapperFails() {
TransactionInfoDTO transactionInfoDTO = new TransactionInfoDTO();
TransactionMetaDTO meta = new TransactionMetaDTO();
String hash = "ABC";
meta.setHash(hash);
transactionInfoDTO.setMeta(meta);
mockRemoteCall(transactionInfoDTO);
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> {
ExceptionUtils.propagateVoid(() -> {
repository.getTransaction(TransactionGroup.CONFIRMED, hash).toFuture().get();
});
});
Assertions.assertTrue(exception.getMessage().contains("Transaction cannot be mapped, object does not not have transaction type."));
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class TransactionRepositoryIntegrationTest method throwExceptionWhenTransactionStatusOfATransactionDoesNotExists.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void throwExceptionWhenTransactionStatusOfATransactionDoesNotExists(RepositoryType type) {
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(getTransactionStatusRepository(type).getTransactionStatus(invalidTransactionHash)));
Assertions.assertEquals("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id '" + invalidTransactionHash + "'", exception.getMessage());
}
Aggregations