Search in sources :

Example 1 with RestrictionAccountRepository

use of io.nem.symbol.sdk.api.RestrictionAccountRepository 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"));
}
Also used : UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) Address(io.nem.symbol.sdk.model.account.Address) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) RestrictionAccountRepository(io.nem.symbol.sdk.api.RestrictionAccountRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with RestrictionAccountRepository

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

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

the class StateProofServiceTest method accountRestrictions.

@Test
void accountRestrictions() throws Exception {
    RestrictionAccountRepository repository = mock(RestrictionAccountRepository.class);
    when(factory.createRestrictionAccountRepository()).thenReturn(repository);
    Address id = Address.generateRandom(NetworkType.MIJIN_TEST);
    AccountRestrictions state = Mockito.mock(AccountRestrictions.class);
    when(state.getAddress()).thenReturn(id);
    when(state.serialize()).thenReturn(ConvertUtils.fromHexToBytes(serialized));
    when(repository.getAccountRestrictions(eq(id))).thenReturn(Observable.just(state));
    when(repository.getAccountRestrictionsMerkle(eq(id))).thenReturn(Observable.just(tree));
    StateMerkleProof<AccountRestrictions> proof = service.accountRestrictions(id).toFuture().get();
    Assertions.assertTrue(proof.isValid());
    Assertions.assertEquals(state, proof.getState());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) RestrictionAccountRepository(io.nem.symbol.sdk.api.RestrictionAccountRepository) AccountRestrictions(io.nem.symbol.sdk.model.account.AccountRestrictions) Test(org.junit.jupiter.api.Test)

Aggregations

RestrictionAccountRepository (io.nem.symbol.sdk.api.RestrictionAccountRepository)3 Address (io.nem.symbol.sdk.model.account.Address)2 AccountRestrictionSearchCriteria (io.nem.symbol.sdk.api.AccountRestrictionSearchCriteria)1 RepositoryCallException (io.nem.symbol.sdk.api.RepositoryCallException)1 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 AccountRestrictions (io.nem.symbol.sdk.model.account.AccountRestrictions)1 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1