use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class RestrictionMosaicRepositoryOkHttpImplTest method shouldGetMosaicAddressRestrictions.
@Test
public void shouldGetMosaicAddressRestrictions() throws Exception {
Address address = Address.generateRandom(this.networkType);
MosaicId mosaicId = MapperUtils.toMosaicId("123");
MosaicAddressRestrictionDTO dto = new MosaicAddressRestrictionDTO();
MosaicAddressRestrictionEntryWrapperDTO wrapperDTO = new MosaicAddressRestrictionEntryWrapperDTO();
dto.setMosaicRestrictionEntry(wrapperDTO);
MosaicAddressRestrictionEntryDTO entryDTO = new MosaicAddressRestrictionEntryDTO();
entryDTO.setKey(ConvertUtils.toString(BigInteger.valueOf(1111)));
entryDTO.setValue("2222");
List<MosaicAddressRestrictionEntryDTO> restrictions = new ArrayList<>();
restrictions.add(entryDTO);
wrapperDTO.setCompositeHash("compositeHash");
wrapperDTO.setMosaicId(mosaicId.getIdAsHex());
wrapperDTO.setRestrictions(restrictions);
wrapperDTO.setEntryType(MosaicRestrictionEntryTypeEnum.NUMBER_0);
wrapperDTO.setTargetAddress(address.encoded());
wrapperDTO.setVersion(1);
mockRemoteCall(toPage(dto));
List<MosaicRestriction<?>> mosaicAddressRestrictions = repository.search(new MosaicRestrictionSearchCriteria()).toFuture().get().getData();
Assertions.assertEquals(1, mosaicAddressRestrictions.size());
MosaicAddressRestriction mosaicAddressRestriction = (MosaicAddressRestriction) mosaicAddressRestrictions.get(0);
Assertions.assertEquals(wrapperDTO.getCompositeHash(), mosaicAddressRestriction.getCompositeHash());
Assertions.assertEquals(MosaicRestrictionEntryType.ADDRESS, mosaicAddressRestriction.getEntryType());
Assertions.assertEquals(mosaicId, mosaicAddressRestriction.getMosaicId());
Assertions.assertEquals(address, mosaicAddressRestriction.getTargetAddress());
Assertions.assertEquals(1, mosaicAddressRestriction.getRestrictions().size());
Assertions.assertEquals(BigInteger.valueOf(2222), mosaicAddressRestriction.getRestrictions().get(BigInteger.valueOf(1111)));
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class RestrictionAccountRepositoryOkHttpImplTest method shouldGetAccountRestrictions.
@Test
public void shouldGetAccountRestrictions() throws Exception {
Address address = Address.generateRandom(networkType);
AccountRestrictionsDTO dto = new AccountRestrictionsDTO();
dto.setAddress(address.encoded());
AccountRestrictionDTO restriction = new AccountRestrictionDTO();
restriction.setRestrictionFlags(AccountRestrictionFlagsEnum.NUMBER_32770);
restriction.setValues(Arrays.asList("9636553580561478212"));
dto.setRestrictions(Collections.singletonList(restriction));
dto.setVersion(1);
AccountRestrictionsInfoDTO info = new AccountRestrictionsInfoDTO();
info.setAccountRestrictions(dto);
mockRemoteCall(info);
AccountRestrictions accountRestrictions = repository.getAccountRestrictions(address).toFuture().get();
Assertions.assertEquals(address, accountRestrictions.getAddress());
Assertions.assertEquals(1, accountRestrictions.getRestrictions().size());
Assertions.assertEquals(AccountMosaicRestrictionFlags.BLOCK_MOSAIC, accountRestrictions.getRestrictions().get(0).getRestrictionFlags());
Assertions.assertEquals(Arrays.asList(MapperUtils.toMosaicId("9636553580561478212")), accountRestrictions.getRestrictions().get(0).getValues());
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class RestrictionAccountRepositoryOkHttpImplTest method getAccountRestrictionsMerkle.
@Test
public void getAccountRestrictionsMerkle() throws Exception {
Address address = Address.generateRandom(this.networkType);
mockRemoteCall(new MerkleStateInfoDTO().raw("abc"));
MerkleStateInfo merkle = repository.getAccountRestrictionsMerkle(address).toFuture().get();
Assertions.assertEquals("abc", merkle.getRaw());
}
use of io.nem.symbol.sdk.model.account.Address 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());
}
use of io.nem.symbol.sdk.model.account.Address 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());
}
Aggregations