Search in sources :

Example 1 with HashLockInfoDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockInfoDTO 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 HashLockInfoDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockInfoDTO 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)

Aggregations

Address (io.nem.symbol.sdk.model.account.Address)2 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)2 HashLockInfo (io.nem.symbol.sdk.model.transaction.HashLockInfo)2 HashLockEntryDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockEntryDTO)2 HashLockInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.HashLockInfoDTO)2 Test (org.junit.jupiter.api.Test)2 HashLockSearchCriteria (io.nem.symbol.sdk.api.HashLockSearchCriteria)1