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"));
}
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());
}
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());
}
Aggregations