use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method throwExceptionWhenBlockDoesNotExists.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void throwExceptionWhenBlockDoesNotExists(RepositoryType type) {
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(getBlockRepository(type).getBlockByHeight(BigInteger.valueOf(0))));
Assertions.assertEquals("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id '0'", exception.getMessage());
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method getAccountRestrictionsWhenAccountDoesNotExist.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAccountRestrictionsWhenAccountDoesNotExist(RepositoryType type) {
RestrictionAccountRepository repository = getRepositoryFactory(type).createRestrictionAccountRepository();
Address address = Address.createFromPublicKey("67F69FA4BFCD158F6E1AF1ABC82F725F5C5C4710D6E29217B12BE66397435DFB", getNetworkType());
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> get(repository.getAccountRestrictions(address)));
Assertions.assertTrue(exception.getMessage().contains("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id"));
}
use of io.nem.symbol.sdk.api.RepositoryCallException in project nem2-sdk-java by nemtech.
the class RepositoryFactoryVertxImplTest method getNetworkTypeFailWhenInvalidServer.
@Test
public void getNetworkTypeFailWhenInvalidServer() {
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 MetadataTransactionServiceTest method shouldNotCreateNamespaceMetadataTransactionFactoryWhenAnyOtherRemoteException.
@Test
void shouldNotCreateNamespaceMetadataTransactionFactoryWhenAnyOtherRemoteException() {
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(namespaceId).metadataType(MetadataType.NAMESPACE);
Mockito.when(metadataRepositoryMock.search(Mockito.eq(criteria))).thenReturn(Observable.error(expectedException));
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> ExceptionUtils.propagate(() -> service.createNamespaceMetadataTransactionFactory(targetAccount.getAddress(), metadataKey, newValue, sourceAddress, namespaceId).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 MetadataTransactionServiceTest method shouldNotCreateAccountMetadataTransactionFactoryWhenAnyOtherRemoteException.
@Test
void shouldNotCreateAccountMetadataTransactionFactoryWhenAnyOtherRemoteException() {
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).targetAddress(targetAccount.getAddress()).metadataType(MetadataType.ACCOUNT);
Mockito.when(metadataRepositoryMock.search(Mockito.eq(criteria))).thenReturn(Observable.error(expectedException));
RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> ExceptionUtils.propagate(() -> service.createAccountMetadataTransactionFactory(targetAccount.getAddress(), metadataKey, newValue, sourceAddress).toFuture().get()));
Assertions.assertEquals(expectedException, exception);
Mockito.verify(metadataRepositoryMock).search(Mockito.eq(criteria));
}
Aggregations