use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImplTest method shouldGetMosaicsNamesFromPublicKeys.
@Test
public void shouldGetMosaicsNamesFromPublicKeys() throws Exception {
MosaicId mosaicId = MapperUtils.toMosaicId("99262122238339734");
MosaicNamesDTO dto = new MosaicNamesDTO();
dto.setMosaicId("99262122238339734");
dto.setNames(Collections.singletonList("accountalias"));
MosaicsNamesDTO accountsNamesDTO = new MosaicsNamesDTO();
accountsNamesDTO.setMosaicNames(Collections.singletonList(dto));
mockRemoteCall(accountsNamesDTO);
List<MosaicNames> resolvedList = repository.getMosaicsNames(Collections.singletonList(mosaicId)).toFuture().get();
Assertions.assertEquals(1, resolvedList.size());
MosaicNames accountNames = resolvedList.get(0);
Assertions.assertEquals(mosaicId, accountNames.getMosaicId());
Assertions.assertEquals("accountalias", accountNames.getNames().get(0).getName());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class RestrictionMosaicRepositoryVertxImplTest method shouldGetMosaicGlobalRestrictions.
@Test
public void shouldGetMosaicGlobalRestrictions() 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.setCompositeHash("compositeHash");
wrapperDTO.setMosaicId(mosaicId.getIdAsHex());
wrapperDTO.setRestrictions(restrictions);
wrapperDTO.setVersion(1);
wrapperDTO.setEntryType(MosaicRestrictionEntryTypeEnum.NUMBER_1);
mockRemoteCall(toPage(dto));
List<MosaicRestriction<?>> mosaicGlobalRestrictions = repository.search(new MosaicRestrictionSearchCriteria()).toFuture().get().getData();
Assertions.assertEquals(1, mosaicGlobalRestrictions.size());
MosaicGlobalRestriction mosaicGlobalRestriction = (MosaicGlobalRestriction) mosaicGlobalRestrictions.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 shouldSearch.
@Test
public void shouldSearch() 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.setStatus(LockStatus.NUMBER_1);
lockHashDto.setSecret("someSecret");
lockHashDto.setHashAlgorithm(LockHashAlgorithmEnum.NUMBER_2);
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(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());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId 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());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicRepositoryVertxImplTest method shouldGetMosaicsFromAccount.
@Test
public void shouldGetMosaicsFromAccount() throws Exception {
Address address = Address.generateRandom(this.networkType);
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
MosaicId mosaicId = MapperUtils.toMosaicId("481110499AAA");
MosaicDTO mosaicDto = new MosaicDTO();
mosaicDto.setOwnerAddress(address.encoded());
mosaicDto.setId("481110499AAA");
mosaicDto.setRevision(123L);
mosaicDto.setFlags(5);
mosaicDto.setDivisibility(6);
mosaicDto.setVersion(1);
mosaicDto.setDuration(BigInteger.valueOf(7));
mosaicDto.supply(BigInteger.valueOf(1000));
mosaicDto.startHeight(BigInteger.valueOf(100));
mockRemoteCall(toPage(new MosaicInfoDTO().mosaic(mosaicDto).id("ABC")));
List<MosaicInfo> resolvedList = repository.search(new MosaicSearchCriteria().ownerAddress(publicAccount.getAddress())).toFuture().get().getData();
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.MIJIN_TEST));
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