use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicRepositoryOkHttpImplTest method shouldGetMosaic.
@Test
public void shouldGetMosaic() throws Exception {
MosaicId mosaicId = MapperUtils.toMosaicId("481110499AAA");
Address ownerAddress = Account.generateNewAccount(networkType).getAddress();
MosaicDTO mosaicDto = new MosaicDTO();
MosaicInfoDTO mosaicInfoDto = new MosaicInfoDTO();
mosaicDto.setOwnerAddress(ownerAddress.encoded());
mosaicDto.setId("481110499AAA");
mosaicDto.setRevision(123L);
mosaicDto.setFlags(5);
mosaicDto.setDivisibility(6);
mosaicDto.setDuration(BigInteger.valueOf(7));
mosaicDto.supply(BigInteger.valueOf(1000));
mosaicDto.startHeight(BigInteger.valueOf(100));
mosaicDto.setVersion(1);
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 MosaicRepositoryOkHttpImplTest method shouldGetMosaics.
@Test
public void shouldGetMosaics() throws Exception {
MosaicId mosaicId = MapperUtils.toMosaicId("481110499AAA");
Address ownerAddress = Account.generateNewAccount(networkType).getAddress();
MosaicDTO mosaicDto = new MosaicDTO();
MosaicInfoDTO mosaicInfoDto = new MosaicInfoDTO();
mosaicDto.setOwnerAddress(ownerAddress.encoded());
mosaicDto.setId("481110499AAA");
mosaicDto.setRevision(123L);
mosaicDto.setFlags(5);
mosaicDto.setDivisibility(6);
mosaicDto.setDuration(BigInteger.valueOf(7));
mosaicDto.supply(BigInteger.valueOf(1000));
mosaicDto.startHeight(BigInteger.valueOf(100));
mosaicDto.setVersion(1);
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());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class MosaicRepositoryOkHttpImplTest method getMetadataMerkle.
@Test
public void getMetadataMerkle() throws Exception {
MosaicId mosaicId = MapperUtils.toMosaicId("481110499");
mockRemoteCall(new MerkleStateInfoDTO().raw("abc"));
MerkleStateInfo merkle = repository.getMosaicMerkle(mosaicId).toFuture().get();
Assertions.assertEquals("abc", merkle.getRaw());
}
use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest 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 RestrictionMosaicRepositoryOkHttpImplTest 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.setCompositeHash("compositeHash");
wrapperDTO.setMosaicId(mosaicId.getIdAsHex());
wrapperDTO.setRestrictions(restrictions);
wrapperDTO.setEntryType(MosaicRestrictionEntryTypeEnum.NUMBER_1);
wrapperDTO.setVersion(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());
}
Aggregations