use of io.nem.symbol.sdk.api.HashLockSearchCriteria 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());
}
use of io.nem.symbol.sdk.api.HashLockSearchCriteria 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);
}
use of io.nem.symbol.sdk.api.HashLockSearchCriteria in project nem2-sdk-java by nemtech.
the class MerkleLoaderIntegrationTest method hashLocks.
public List<Arguments> hashLocks() {
RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
HashLockRepository repository = repositoryFactory.createHashLockRepository();
return getArguments(repository, new HashLockSearchCriteria());
}
use of io.nem.symbol.sdk.api.HashLockSearchCriteria in project nem2-sdk-java by nemtech.
the class HashLockRepositoryIntegrationTest method searchWhenInvalidAddress.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchWhenInvalidAddress(RepositoryType type) {
HashLockRepository repository = getRepositoryFactory(type).createHashLockRepository();
Address address = Address.generateRandom(getNetworkType());
Page<HashLockInfo> page = get(repository.search(new HashLockSearchCriteria().address(address)));
Assertions.assertTrue(page.isLast());
Assertions.assertTrue(page.getData().isEmpty());
Assertions.assertEquals(20, page.getPageSize());
}
use of io.nem.symbol.sdk.api.HashLockSearchCriteria 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());
}
Aggregations