use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class RestrictionMosaicRepositoryVertxImplTest method shouldMosaicGlobalRestriction.
@Test
public void shouldMosaicGlobalRestriction() throws Exception {
MosaicId mosaicId = MapperUtils.toMosaicId("123");
MosaicGlobalRestrictionDTO dto = new MosaicGlobalRestrictionDTO();
MosaicGlobalRestrictionEntryWrapperDTO wrapperDTO = new MosaicGlobalRestrictionEntryWrapperDTO();
dto.setMosaicRestrictionEntry(wrapperDTO);
MosaicGlobalRestrictionEntryDTO entryDTO = new MosaicGlobalRestrictionEntryDTO();
entryDTO.setKey(ConvertUtils.toString(BigInteger.valueOf(1111)));
MosaicGlobalRestrictionEntryRestrictionDTO entryRestrictionDto = new MosaicGlobalRestrictionEntryRestrictionDTO();
entryRestrictionDto.setRestrictionType(MosaicRestrictionTypeEnum.NUMBER_5);
entryRestrictionDto.setReferenceMosaicId("456");
entryRestrictionDto.setRestrictionValue(BigInteger.valueOf(3333));
entryDTO.setRestriction(entryRestrictionDto);
List<MosaicGlobalRestrictionEntryDTO> restrictions = new ArrayList<>();
restrictions.add(entryDTO);
wrapperDTO.setVersion(1);
wrapperDTO.setCompositeHash("compositeHash");
wrapperDTO.setMosaicId(mosaicId.getIdAsHex());
wrapperDTO.setRestrictions(restrictions);
wrapperDTO.setEntryType(MosaicRestrictionEntryTypeEnum.NUMBER_1);
mockRemoteCall(toPage(dto));
MosaicGlobalRestriction mosaicGlobalRestriction = (MosaicGlobalRestriction) repository.search(new MosaicRestrictionSearchCriteria()).toFuture().get().getData().get(0);
Assertions.assertEquals(wrapperDTO.getCompositeHash(), mosaicGlobalRestriction.getCompositeHash());
Assertions.assertEquals(MosaicRestrictionEntryType.GLOBAL, mosaicGlobalRestriction.getEntryType());
Assertions.assertEquals(mosaicId, mosaicGlobalRestriction.getMosaicId());
Assertions.assertEquals(1, mosaicGlobalRestriction.getRestrictions().size());
Assertions.assertEquals(BigInteger.valueOf(3333), mosaicGlobalRestriction.getRestrictions().get(BigInteger.valueOf(1111)).getRestrictionValue());
Assertions.assertEquals("0000000000000456", mosaicGlobalRestriction.getRestrictions().get(BigInteger.valueOf(1111)).getReferenceMosaicId().getIdAsHex());
Assertions.assertEquals(MosaicRestrictionType.GT, mosaicGlobalRestriction.getRestrictions().get(BigInteger.valueOf((1111))).getRestrictionType());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class SecretLockRepositoryVertxImplTest method getSecretLock.
@Test
public void getSecretLock() throws Exception {
Address address = Address.generateRandom(this.networkType);
Address recipientAddress = Address.generateRandom(this.networkType);
MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
SecretLockEntryDTO lockHashDto = new SecretLockEntryDTO();
lockHashDto.setOwnerAddress(encodeAddress(address));
lockHashDto.setAmount(BigInteger.ONE);
lockHashDto.setEndHeight(BigInteger.TEN);
lockHashDto.setCompositeHash("ABC");
lockHashDto.setRecipientAddress(encodeAddress(recipientAddress));
lockHashDto.setMosaicId(mosaicId.getIdAsHex());
lockHashDto.setVersion(1);
lockHashDto.setStatus(LockStatus.NUMBER_1);
lockHashDto.setHashAlgorithm(LockHashAlgorithmEnum.NUMBER_2);
lockHashDto.setSecret("ABC");
SecretLockInfoDTO hashLockInfoDTO = new SecretLockInfoDTO();
hashLockInfoDTO.setLock(lockHashDto);
hashLockInfoDTO.setId("123");
mockRemoteCall(hashLockInfoDTO);
SecretLockInfo resolvedSecretLockInfo = repository.getSecretLock(lockHashDto.getCompositeHash()).toFuture().get();
Assertions.assertEquals(hashLockInfoDTO.getLock().getSecret(), resolvedSecretLockInfo.getSecret());
Assertions.assertEquals(address, resolvedSecretLockInfo.getOwnerAddress());
Assertions.assertEquals(hashLockInfoDTO.getId(), resolvedSecretLockInfo.getRecordId().get());
Assertions.assertEquals(address, resolvedSecretLockInfo.getOwnerAddress());
Assertions.assertEquals(recipientAddress, resolvedSecretLockInfo.getRecipientAddress());
Assertions.assertEquals(LockHashAlgorithm.HASH_256, resolvedSecretLockInfo.getHashAlgorithm());
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(lockHashDto.getAmount(), resolvedSecretLockInfo.getAmount());
Assertions.assertEquals(lockHashDto.getEndHeight(), resolvedSecretLockInfo.getEndHeight());
Assertions.assertEquals(lockHashDto.getSecret(), resolvedSecretLockInfo.getSecret());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId 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());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicRepositoryVertxImplTest method shouldGetMosaic.
@Test
public void shouldGetMosaic() throws Exception {
Address address = Address.generateRandom(this.networkType);
MosaicId mosaicId = MapperUtils.toMosaicId("481110499");
MosaicDTO mosaicDto = new MosaicDTO();
MosaicInfoDTO mosaicInfoDto = new MosaicInfoDTO();
mosaicDto.setOwnerAddress(address.encoded());
mosaicDto.setId("481110499");
mosaicDto.setRevision(123L);
mosaicDto.setVersion(1);
mosaicDto.setFlags(5);
mosaicDto.setDivisibility(6);
mosaicDto.setDuration(BigInteger.valueOf(7));
mosaicDto.supply(BigInteger.valueOf(1000));
mosaicDto.startHeight(BigInteger.valueOf(100));
mosaicInfoDto.setMosaic(mosaicDto);
mockRemoteCall(mosaicInfoDto);
MosaicInfo mosaicInfo = repository.getMosaic(mosaicId).toFuture().get();
Assertions.assertEquals(mosaicId, mosaicInfo.getMosaicId());
Assertions.assertEquals(mosaicDto.getRevision(), mosaicInfo.getRevision());
Assertions.assertEquals(mosaicDto.getOwnerAddress(), mosaicInfo.getOwnerAddress().encoded(networkType));
Assertions.assertFalse(mosaicInfo.isTransferable());
Assertions.assertEquals(6, mosaicInfo.getDivisibility());
Assertions.assertEquals(BigInteger.valueOf(7), mosaicInfo.getDuration());
Assertions.assertEquals(mosaicDto.getStartHeight(), mosaicInfo.getStartHeight());
Assertions.assertEquals(mosaicDto.getSupply(), mosaicInfo.getSupply());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicRepositoryVertxImplTest method shouldGetMosaics.
@Test
public void shouldGetMosaics() throws Exception {
Address address = Address.generateRandom(this.networkType);
MosaicId mosaicId = MapperUtils.toMosaicId("481110499AAA");
MosaicDTO mosaicDto = new MosaicDTO();
MosaicInfoDTO mosaicInfoDto = new MosaicInfoDTO();
mosaicDto.setOwnerAddress(address.encoded());
mosaicDto.setId("481110499AAA");
mosaicDto.setRevision(123L);
mosaicDto.setFlags(5);
mosaicDto.setVersion(1);
mosaicDto.setDivisibility(6);
mosaicDto.setDuration(BigInteger.valueOf(7));
mosaicDto.supply(BigInteger.valueOf(1000));
mosaicDto.startHeight(BigInteger.valueOf(100));
mosaicInfoDto.setMosaic(mosaicDto);
mockRemoteCall(Collections.singletonList(mosaicInfoDto));
List<MosaicInfo> resolvedList = repository.getMosaics(Collections.singletonList(mosaicId)).toFuture().get();
Assertions.assertEquals(1, resolvedList.size());
MosaicInfo mosaicInfo = resolvedList.get(0);
Assertions.assertEquals(mosaicId, mosaicInfo.getMosaicId());
Assertions.assertEquals(mosaicDto.getRevision(), mosaicInfo.getRevision());
Assertions.assertEquals(mosaicDto.getOwnerAddress(), mosaicInfo.getOwnerAddress().encoded(networkType));
Assertions.assertFalse(mosaicInfo.isTransferable());
Assertions.assertEquals(6, mosaicInfo.getDivisibility());
Assertions.assertEquals(BigInteger.valueOf(7), mosaicInfo.getDuration());
Assertions.assertEquals(mosaicDto.getStartHeight(), mosaicInfo.getStartHeight());
Assertions.assertEquals(mosaicDto.getSupply(), mosaicInfo.getSupply());
}
Aggregations