Search in sources :

Example 1 with AccountRestrictionSearchCriteria

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

the class RestrictionAccountRepositoryVertxImpl method search.

@Override
public Observable<Page<AccountRestrictions>> search(AccountRestrictionSearchCriteria criteria) {
    String address = toDto(criteria.getAddress());
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    Consumer<Handler<AsyncResult<AccountRestrictionsPage>>> handlerConsumer = (h) -> getClient().searchAccountRestrictions(address, pageSize, pageNumber, offset, order, h);
    return this.call(handlerConsumer, this::toPage);
}
Also used : Order(io.nem.symbol.sdk.openapi.vertx.model.Order) AccountRestrictionsPage(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionsPage) RestrictionAccountRepository(io.nem.symbol.sdk.api.RestrictionAccountRepository) MapperUtils(io.nem.symbol.core.utils.MapperUtils) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) RestrictionAccountRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.RestrictionAccountRoutesApi) AccountRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountRestrictionFlags) AccountRestrictionDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionDTO) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Consumer(java.util.function.Consumer) AccountRestrictionSearchCriteria(io.nem.symbol.sdk.api.AccountRestrictionSearchCriteria) AccountRestrictionsPage(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionsPage) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) AccountRestrictions(io.nem.symbol.sdk.model.account.AccountRestrictions) ObjectUtils(org.apache.commons.lang3.ObjectUtils) AccountRestriction(io.nem.symbol.sdk.model.account.AccountRestriction) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) Observable(io.reactivex.Observable) AccountRestrictionsInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionsInfoDTO) AsyncResult(io.vertx.core.AsyncResult) Address(io.nem.symbol.sdk.model.account.Address) RestrictionAccountRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.RestrictionAccountRoutesApiImpl) Handler(io.vertx.core.Handler) Page(io.nem.symbol.sdk.api.Page) Handler(io.vertx.core.Handler)

Example 2 with AccountRestrictionSearchCriteria

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

the class RestrictionAccountRepositoryOkHttpImplTest method search.

@Test
public void search() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    AccountRestrictionsDTO dto = new AccountRestrictionsDTO();
    dto.setAddress(address.encoded());
    AccountRestrictionDTO restriction = new AccountRestrictionDTO();
    restriction.setRestrictionFlags(AccountRestrictionFlagsEnum.NUMBER_32770);
    restriction.setValues(Collections.singletonList("9636553580561478212"));
    dto.setRestrictions(Collections.singletonList(restriction));
    dto.setVersion(1);
    AccountRestrictionsInfoDTO info = new AccountRestrictionsInfoDTO();
    info.setAccountRestrictions(dto);
    mockRemoteCall(toPage(info));
    AccountRestrictions accountRestrictions = repository.search(new AccountRestrictionSearchCriteria()).toFuture().get().getData().get(0);
    Assertions.assertEquals(address, accountRestrictions.getAddress());
    Assertions.assertEquals(1, accountRestrictions.getRestrictions().size());
    Assertions.assertEquals(AccountMosaicRestrictionFlags.BLOCK_MOSAIC, accountRestrictions.getRestrictions().get(0).getRestrictionFlags());
    Assertions.assertEquals(Collections.singletonList(MapperUtils.toMosaicId("9636553580561478212")), accountRestrictions.getRestrictions().get(0).getValues());
}
Also used : AccountRestrictionDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionDTO) AccountRestrictionSearchCriteria(io.nem.symbol.sdk.api.AccountRestrictionSearchCriteria) AccountRestrictionsDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionsDTO) Address(io.nem.symbol.sdk.model.account.Address) AccountRestrictionsInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionsInfoDTO) AccountRestrictions(io.nem.symbol.sdk.model.account.AccountRestrictions) Test(org.junit.jupiter.api.Test)

Example 3 with AccountRestrictionSearchCriteria

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

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

the class RestrictionAccountRepositoryVertxImplTest method search.

@Test
public void search() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    AccountRestrictionsDTO dto = new AccountRestrictionsDTO();
    dto.setAddress(address.encoded());
    AccountRestrictionDTO restriction = new AccountRestrictionDTO();
    restriction.setRestrictionFlags(AccountRestrictionFlagsEnum.NUMBER_32770);
    restriction.setValues(Collections.singletonList("9636553580561478212"));
    dto.setRestrictions(Collections.singletonList(restriction));
    dto.setVersion(1);
    AccountRestrictionsInfoDTO info = new AccountRestrictionsInfoDTO();
    info.setAccountRestrictions(dto);
    mockRemoteCall(toPage(info));
    AccountRestrictions accountRestrictions = repository.search(new AccountRestrictionSearchCriteria()).toFuture().get().getData().get(0);
    Assertions.assertEquals(address, accountRestrictions.getAddress());
    Assertions.assertEquals(1, accountRestrictions.getRestrictions().size());
    Assertions.assertEquals(AccountMosaicRestrictionFlags.BLOCK_MOSAIC, accountRestrictions.getRestrictions().get(0).getRestrictionFlags());
    Assertions.assertEquals(Collections.singletonList(MapperUtils.toMosaicId("9636553580561478212")), accountRestrictions.getRestrictions().get(0).getValues());
}
Also used : AccountRestrictionDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionDTO) AccountRestrictionSearchCriteria(io.nem.symbol.sdk.api.AccountRestrictionSearchCriteria) AccountRestrictionsDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionsDTO) Address(io.nem.symbol.sdk.model.account.Address) AccountRestrictionsInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionsInfoDTO) AccountRestrictions(io.nem.symbol.sdk.model.account.AccountRestrictions) Test(org.junit.jupiter.api.Test)

Aggregations

AccountRestrictionSearchCriteria (io.nem.symbol.sdk.api.AccountRestrictionSearchCriteria)4 AccountRestrictions (io.nem.symbol.sdk.model.account.AccountRestrictions)3 Address (io.nem.symbol.sdk.model.account.Address)3 RestrictionAccountRepository (io.nem.symbol.sdk.api.RestrictionAccountRepository)2 AccountRestrictionDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionDTO)2 AccountRestrictionsInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionsInfoDTO)2 Test (org.junit.jupiter.api.Test)2 MapperUtils (io.nem.symbol.core.utils.MapperUtils)1 Page (io.nem.symbol.sdk.api.Page)1 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 AccountRestriction (io.nem.symbol.sdk.model.account.AccountRestriction)1 MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)1 AccountRestrictionFlags (io.nem.symbol.sdk.model.transaction.AccountRestrictionFlags)1 AccountRestrictionDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionDTO)1 AccountRestrictionsDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionsDTO)1 AccountRestrictionsInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionsInfoDTO)1 RestrictionAccountRoutesApi (io.nem.symbol.sdk.openapi.vertx.api.RestrictionAccountRoutesApi)1 RestrictionAccountRoutesApiImpl (io.nem.symbol.sdk.openapi.vertx.api.RestrictionAccountRoutesApiImpl)1 ApiClient (io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient)1 AccountRestrictionsDTO (io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionsDTO)1