Search in sources :

Example 1 with MosaicGlobalRestrictionEntryDTO

use of io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryDTO 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());
}
Also used : MosaicGlobalRestrictionEntryDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryDTO) MosaicGlobalRestrictionEntryRestrictionDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryRestrictionDTO) MosaicGlobalRestrictionDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) ArrayList(java.util.ArrayList) MosaicRestriction(io.nem.symbol.sdk.model.restriction.MosaicRestriction) MosaicRestrictionSearchCriteria(io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria) MosaicGlobalRestrictionEntryWrapperDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryWrapperDTO) MosaicGlobalRestriction(io.nem.symbol.sdk.model.restriction.MosaicGlobalRestriction) Test(org.junit.jupiter.api.Test)

Example 2 with MosaicGlobalRestrictionEntryDTO

use of io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryDTO 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());
}
Also used : MosaicGlobalRestrictionEntryDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryDTO) MosaicGlobalRestrictionEntryRestrictionDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryRestrictionDTO) MosaicGlobalRestrictionDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) ArrayList(java.util.ArrayList) MosaicRestrictionSearchCriteria(io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria) MosaicGlobalRestrictionEntryWrapperDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryWrapperDTO) MosaicGlobalRestriction(io.nem.symbol.sdk.model.restriction.MosaicGlobalRestriction) Test(org.junit.jupiter.api.Test)

Aggregations

MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)2 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)2 MosaicGlobalRestriction (io.nem.symbol.sdk.model.restriction.MosaicGlobalRestriction)2 MosaicGlobalRestrictionDTO (io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionDTO)2 MosaicGlobalRestrictionEntryDTO (io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryDTO)2 MosaicGlobalRestrictionEntryRestrictionDTO (io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryRestrictionDTO)2 MosaicGlobalRestrictionEntryWrapperDTO (io.nem.symbol.sdk.openapi.vertx.model.MosaicGlobalRestrictionEntryWrapperDTO)2 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 MosaicRestriction (io.nem.symbol.sdk.model.restriction.MosaicRestriction)1