Search in sources :

Example 1 with SecretLockInfoDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.SecretLockInfoDTO in project nem2-sdk-java by nemtech.

the class SecretLockRepositoryOkHttpImplTest method shouldSearch.

@Test
public void shouldSearch() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    Address recipientAddress = Address.generateRandom(this.networkType);
    SecretLockEntryDTO lockHashDto = new SecretLockEntryDTO();
    lockHashDto.setOwnerAddress(encodeAddress(address));
    lockHashDto.setAmount(BigInteger.ONE);
    lockHashDto.setEndHeight(BigInteger.TEN);
    lockHashDto.setCompositeHash("ABC");
    lockHashDto.setMosaicId(mosaicId.getIdAsHex());
    lockHashDto.setRecipientAddress(encodeAddress(recipientAddress));
    lockHashDto.setHashAlgorithm(LockHashAlgorithmEnum.NUMBER_2);
    lockHashDto.setStatus(LockStatus.NUMBER_1);
    lockHashDto.setSecret("someSecret");
    lockHashDto.setVersion(1);
    SecretLockInfoDTO hashLockInfoDTO = new SecretLockInfoDTO();
    hashLockInfoDTO.setLock(lockHashDto);
    hashLockInfoDTO.setId("123");
    mockRemoteCall(toPage(hashLockInfoDTO));
    List<SecretLockInfo> list = repository.search(new SecretLockSearchCriteria().address(address)).toFuture().get().getData();
    Assertions.assertEquals(1, list.size());
    SecretLockInfo resolvedSecretLockInfo = list.get(0);
    Assertions.assertEquals(address, resolvedSecretLockInfo.getOwnerAddress());
    Assertions.assertEquals(recipientAddress, resolvedSecretLockInfo.getRecipientAddress());
    Assertions.assertEquals(hashLockInfoDTO.getId(), resolvedSecretLockInfo.getRecordId().get());
    Assertions.assertEquals(address, resolvedSecretLockInfo.getOwnerAddress());
    Assertions.assertEquals(lockHashDto.getCompositeHash(), resolvedSecretLockInfo.getCompositeHash());
    Assertions.assertEquals(io.nem.symbol.sdk.model.transaction.LockStatus.USED, resolvedSecretLockInfo.getStatus());
    Assertions.assertEquals(mosaicId, resolvedSecretLockInfo.getMosaicId());
    Assertions.assertEquals(LockHashAlgorithm.HASH_256, resolvedSecretLockInfo.getHashAlgorithm());
    Assertions.assertEquals(lockHashDto.getAmount(), resolvedSecretLockInfo.getAmount());
    Assertions.assertEquals(lockHashDto.getEndHeight(), resolvedSecretLockInfo.getEndHeight());
    Assertions.assertEquals(lockHashDto.getSecret(), resolvedSecretLockInfo.getSecret());
}
Also used : SecretLockSearchCriteria(io.nem.symbol.sdk.api.SecretLockSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) SecretLockInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.SecretLockInfoDTO) SecretLockInfo(io.nem.symbol.sdk.model.transaction.SecretLockInfo) SecretLockEntryDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.SecretLockEntryDTO) Test(org.junit.jupiter.api.Test)

Aggregations

SecretLockSearchCriteria (io.nem.symbol.sdk.api.SecretLockSearchCriteria)1 Address (io.nem.symbol.sdk.model.account.Address)1 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)1 SecretLockInfo (io.nem.symbol.sdk.model.transaction.SecretLockInfo)1 SecretLockEntryDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.SecretLockEntryDTO)1 SecretLockInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.SecretLockInfoDTO)1 Test (org.junit.jupiter.api.Test)1