use of io.nem.symbol.sdk.model.restriction.MosaicGlobalRestriction 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.restriction.MosaicGlobalRestriction in project nem2-sdk-java by nemtech.
the class RestrictionMosaicRepositoryIntegrationTest method searchGlobalRestriction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchGlobalRestriction(RepositoryType type) {
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
RestrictionMosaicRepository repository = repositoryFactory.createRestrictionMosaicRepository();
MosaicRestrictionEntryType entryType = MosaicRestrictionEntryType.GLOBAL;
Page<MosaicRestriction<?>> page = get(repository.search(new MosaicRestrictionSearchCriteria().entryType(entryType)));
System.out.println(page.getData().size());
page.getData().forEach(restriction -> {
Assertions.assertTrue(restriction instanceof MosaicGlobalRestriction);
Assertions.assertEquals(entryType, restriction.getEntryType());
Assertions.assertNotNull(restriction.getMosaicId());
Assertions.assertNotNull(restriction.getCompositeHash());
Assertions.assertFalse(restriction.getRestrictions().isEmpty());
});
}
Aggregations