Search in sources :

Example 1 with HashLockInfo

use of io.nem.symbol.sdk.model.transaction.HashLockInfo in project nem2-sdk-java by nemtech.

the class HashLockRepositoryOkHttpImplTest method shouldGetHashLockInfo.

@Test
public void shouldGetHashLockInfo() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    HashLockEntryDTO lockHashDto = new HashLockEntryDTO();
    lockHashDto.setOwnerAddress(encodeAddress(address));
    lockHashDto.setAmount(BigInteger.ONE);
    lockHashDto.setEndHeight(BigInteger.TEN);
    lockHashDto.setVersion(1);
    lockHashDto.setHash("ABC");
    lockHashDto.setMosaicId(mosaicId.getIdAsHex());
    lockHashDto.setStatus(LockStatus.NUMBER_1);
    HashLockInfoDTO hashLockInfoDTO = new HashLockInfoDTO();
    hashLockInfoDTO.setLock(lockHashDto);
    hashLockInfoDTO.setId("123");
    mockRemoteCall(hashLockInfoDTO);
    HashLockInfo resolvedHashLockInfo = repository.getHashLock("abc").toFuture().get();
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(hashLockInfoDTO.getId(), resolvedHashLockInfo.getRecordId().get());
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(lockHashDto.getHash(), resolvedHashLockInfo.getHash());
    Assertions.assertEquals(io.nem.symbol.sdk.model.transaction.LockStatus.USED, resolvedHashLockInfo.getStatus());
    Assertions.assertEquals(mosaicId, resolvedHashLockInfo.getMosaicId());
    Assertions.assertEquals(lockHashDto.getAmount(), resolvedHashLockInfo.getAmount());
    Assertions.assertEquals(lockHashDto.getEndHeight(), resolvedHashLockInfo.getEndHeight());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) HashLockEntryDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockEntryDTO) HashLockInfo(io.nem.symbol.sdk.model.transaction.HashLockInfo) HashLockInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockInfoDTO) Test(org.junit.jupiter.api.Test)

Example 2 with HashLockInfo

use of io.nem.symbol.sdk.model.transaction.HashLockInfo in project nem2-sdk-java by nemtech.

the class HashLockRepositoryOkHttpImplTest method shouldSearch.

@Test
public void shouldSearch() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    HashLockEntryDTO lockHashDto = new HashLockEntryDTO();
    lockHashDto.setOwnerAddress(encodeAddress(address));
    lockHashDto.setAmount(BigInteger.ONE);
    lockHashDto.setEndHeight(BigInteger.TEN);
    lockHashDto.setVersion(1);
    lockHashDto.setHash("ABC");
    lockHashDto.setMosaicId(mosaicId.getIdAsHex());
    lockHashDto.setStatus(LockStatus.NUMBER_1);
    HashLockInfoDTO hashLockInfoDTO = new HashLockInfoDTO();
    hashLockInfoDTO.setLock(lockHashDto);
    hashLockInfoDTO.setId("123");
    mockRemoteCall(toPage(hashLockInfoDTO));
    List<HashLockInfo> list = repository.search(new HashLockSearchCriteria().address(address)).toFuture().get().getData();
    Assertions.assertEquals(1, list.size());
    HashLockInfo resolvedHashLockInfo = list.get(0);
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(hashLockInfoDTO.getId(), resolvedHashLockInfo.getRecordId().get());
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(lockHashDto.getHash(), resolvedHashLockInfo.getHash());
    Assertions.assertEquals(io.nem.symbol.sdk.model.transaction.LockStatus.USED, resolvedHashLockInfo.getStatus());
    Assertions.assertEquals(mosaicId, resolvedHashLockInfo.getMosaicId());
    Assertions.assertEquals(lockHashDto.getAmount(), resolvedHashLockInfo.getAmount());
    Assertions.assertEquals(lockHashDto.getEndHeight(), resolvedHashLockInfo.getEndHeight());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) HashLockEntryDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockEntryDTO) HashLockSearchCriteria(io.nem.symbol.sdk.api.HashLockSearchCriteria) HashLockInfo(io.nem.symbol.sdk.model.transaction.HashLockInfo) HashLockInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockInfoDTO) Test(org.junit.jupiter.api.Test)

Example 3 with HashLockInfo

use of io.nem.symbol.sdk.model.transaction.HashLockInfo in project nem2-sdk-java by nemtech.

the class HashLockRepositoryVertxImplTest method shouldGetHashLockInfo.

@Test
public void shouldGetHashLockInfo() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    HashLockEntryDTO lockHashDto = new HashLockEntryDTO();
    lockHashDto.setOwnerAddress(encodeAddress(address));
    lockHashDto.setVersion(1);
    lockHashDto.setAmount(BigInteger.ONE);
    lockHashDto.setEndHeight(BigInteger.TEN);
    lockHashDto.setHash("ABC");
    lockHashDto.setMosaicId(mosaicId.getIdAsHex());
    lockHashDto.setStatus(LockStatus.NUMBER_1);
    HashLockInfoDTO hashLockInfoDTO = new HashLockInfoDTO();
    hashLockInfoDTO.setLock(lockHashDto);
    hashLockInfoDTO.setId("123");
    mockRemoteCall(hashLockInfoDTO);
    HashLockInfo resolvedHashLockInfo = repository.getHashLock("abc").toFuture().get();
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(hashLockInfoDTO.getId(), resolvedHashLockInfo.getRecordId().get());
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(lockHashDto.getHash(), resolvedHashLockInfo.getHash());
    Assertions.assertEquals(io.nem.symbol.sdk.model.transaction.LockStatus.USED, resolvedHashLockInfo.getStatus());
    Assertions.assertEquals(mosaicId, resolvedHashLockInfo.getMosaicId());
    Assertions.assertEquals(lockHashDto.getAmount(), resolvedHashLockInfo.getAmount());
    Assertions.assertEquals(lockHashDto.getEndHeight(), resolvedHashLockInfo.getEndHeight());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) HashLockEntryDTO(io.nem.symbol.sdk.openapi.vertx.model.HashLockEntryDTO) HashLockInfo(io.nem.symbol.sdk.model.transaction.HashLockInfo) HashLockInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.HashLockInfoDTO) Test(org.junit.jupiter.api.Test)

Example 4 with HashLockInfo

use of io.nem.symbol.sdk.model.transaction.HashLockInfo in project nem2-sdk-java by nemtech.

the class HashLockRepositoryVertxImplTest method shouldSearch.

@Test
public void shouldSearch() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    HashLockEntryDTO lockHashDto = new HashLockEntryDTO();
    lockHashDto.setOwnerAddress(encodeAddress(address));
    lockHashDto.setAmount(BigInteger.ONE);
    lockHashDto.setEndHeight(BigInteger.TEN);
    lockHashDto.setVersion(1);
    lockHashDto.setHash("ABC");
    lockHashDto.setMosaicId(mosaicId.getIdAsHex());
    lockHashDto.setStatus(LockStatus.NUMBER_1);
    HashLockInfoDTO hashLockInfoDTO = new HashLockInfoDTO();
    hashLockInfoDTO.setLock(lockHashDto);
    hashLockInfoDTO.setId("123");
    mockRemoteCall(toPage(hashLockInfoDTO));
    List<HashLockInfo> list = repository.search(new HashLockSearchCriteria().address(address)).toFuture().get().getData();
    Assertions.assertEquals(1, list.size());
    HashLockInfo resolvedHashLockInfo = list.get(0);
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(hashLockInfoDTO.getId(), resolvedHashLockInfo.getRecordId().get());
    Assertions.assertEquals(address, resolvedHashLockInfo.getOwnerAddress());
    Assertions.assertEquals(lockHashDto.getHash(), resolvedHashLockInfo.getHash());
    Assertions.assertEquals(io.nem.symbol.sdk.model.transaction.LockStatus.USED, resolvedHashLockInfo.getStatus());
    Assertions.assertEquals(mosaicId, resolvedHashLockInfo.getMosaicId());
    Assertions.assertEquals(lockHashDto.getAmount(), resolvedHashLockInfo.getAmount());
    Assertions.assertEquals(lockHashDto.getEndHeight(), resolvedHashLockInfo.getEndHeight());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) HashLockEntryDTO(io.nem.symbol.sdk.openapi.vertx.model.HashLockEntryDTO) HashLockSearchCriteria(io.nem.symbol.sdk.api.HashLockSearchCriteria) HashLockInfo(io.nem.symbol.sdk.model.transaction.HashLockInfo) HashLockInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.HashLockInfoDTO) Test(org.junit.jupiter.api.Test)

Example 5 with HashLockInfo

use of io.nem.symbol.sdk.model.transaction.HashLockInfo in project nem2-sdk-java by nemtech.

the class HashLockRepositoryVertxImpl method search.

@Override
public Observable<Page<HashLockInfo>> search(HashLockSearchCriteria 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<HashLockPage>>> handlerConsumer = (h) -> getClient().searchHashLock(address, pageSize, pageNumber, offset, order, h);
    return this.call(handlerConsumer, this::toPage);
}
Also used : Order(io.nem.symbol.sdk.openapi.vertx.model.Order) MapperUtils(io.nem.symbol.core.utils.MapperUtils) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) HashLockPage(io.nem.symbol.sdk.openapi.vertx.model.HashLockPage) HashLockRepository(io.nem.symbol.sdk.api.HashLockRepository) HashLockRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.HashLockRoutesApi) LockStatus(io.nem.symbol.sdk.model.transaction.LockStatus) HashLockSearchCriteria(io.nem.symbol.sdk.api.HashLockSearchCriteria) HashLockRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.HashLockRoutesApiImpl) Collectors(java.util.stream.Collectors) HashLockInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.HashLockInfoDTO) HashLockEntryDTO(io.nem.symbol.sdk.openapi.vertx.model.HashLockEntryDTO) Consumer(java.util.function.Consumer) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) ObjectUtils(org.apache.commons.lang3.ObjectUtils) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) HashLockInfo(io.nem.symbol.sdk.model.transaction.HashLockInfo) Observable(io.reactivex.Observable) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) Page(io.nem.symbol.sdk.api.Page) HashLockPage(io.nem.symbol.sdk.openapi.vertx.model.HashLockPage) Handler(io.vertx.core.Handler)

Aggregations

HashLockInfo (io.nem.symbol.sdk.model.transaction.HashLockInfo)8 Address (io.nem.symbol.sdk.model.account.Address)6 HashLockSearchCriteria (io.nem.symbol.sdk.api.HashLockSearchCriteria)5 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)5 Test (org.junit.jupiter.api.Test)5 HashLockRepository (io.nem.symbol.sdk.api.HashLockRepository)4 HashLockEntryDTO (io.nem.symbol.sdk.openapi.vertx.model.HashLockEntryDTO)3 HashLockInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.HashLockInfoDTO)3 Page (io.nem.symbol.sdk.api.Page)2 LockStatus (io.nem.symbol.sdk.model.transaction.LockStatus)2 HashLockEntryDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockEntryDTO)2 HashLockInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockInfoDTO)2 Observable (io.reactivex.Observable)2 Collectors (java.util.stream.Collectors)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ExceptionUtils (io.nem.symbol.core.utils.ExceptionUtils)1 MapperUtils (io.nem.symbol.core.utils.MapperUtils)1 AccountRepository (io.nem.symbol.sdk.api.AccountRepository)1 Listener (io.nem.symbol.sdk.api.Listener)1 MultisigRepository (io.nem.symbol.sdk.api.MultisigRepository)1