use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class MetadataTransactionServiceTest method shouldNotCreateMosaicMetadataTransactionFactoryWhenAnyOtherRemoteException.
@Test
void shouldNotCreateMosaicMetadataTransactionFactoryWhenAnyOtherRemoteException() {
BigInteger metadataKey = BigInteger.valueOf(10);
String newValue = "the new Message";
RepositoryCallException expectedException = new RepositoryCallException("Some other problem.", 500, null);
MetadataSearchCriteria criteria = new MetadataSearchCriteria().sourceAddress(sourceAddress).scopedMetadataKey(metadataKey).targetId(mosaicId).metadataType(MetadataType.MOSAIC);
Mockito.when(metadataRepositoryMock.search(Mockito.eq(criteria))).thenReturn(Observable.error(expectedException));
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> ExceptionUtils.propagate(() -> service.createMosaicMetadataTransactionFactory(targetAccount.getAddress(), metadataKey, newValue, sourceAddress, mosaicId).toFuture().get()));
Assertions.assertEquals(expectedException, exception);
Mockito.verify(metadataRepositoryMock).search(criteria);
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class RepositoryFactoryOkHttpImplTest method getGenerationHashFailWhenInvalidServer.
@Test
public void getGenerationHashFailWhenInvalidServer() {
String baseUrl = "https://localhost:1934/path";
RepositoryCallException e = Assertions.assertThrows(RepositoryCallException.class, () -> GeneratorUtils.propagate(() -> new RepositoryFactoryOkHttpImpl(baseUrl).getGenerationHash().toFuture().get()));
Assertions.assertTrue(e.getMessage().contains("ApiException: java.net.ConnectException: Failed to connect"));
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class RepositoryFactoryOkHttpImplTest method getNetworkTypeFailWhenInvalidServer.
@Test
public void getNetworkTypeFailWhenInvalidServer() {
String baseUrl = "https://localhost:1934/path";
RepositoryCallException e = Assertions.assertThrows(RepositoryCallException.class, () -> GeneratorUtils.propagate(() -> new RepositoryFactoryOkHttpImpl(baseUrl).getNetworkType().toFuture().get()));
Assertions.assertTrue(e.getMessage().contains("ApiException: java.net.ConnectException: Failed to connect"));
}
use of io.nem.symbol.sdk.api.RepositoryCallException 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());
}
use of io.nem.symbol.sdk.api.RepositoryCallException 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());
}
Aggregations