Search in sources :

Example 1 with NamespaceDTO

use of io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryVertxImplTest method shouldGetLinkedMosaicId.

@Test
public void shouldGetLinkedMosaicId() throws Exception {
    NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
    Address ownerAddress = Account.generateNewAccount(networkType).getAddress();
    NamespaceInfoDTO dto = new NamespaceInfoDTO();
    NamespaceMetaDTO meta = new NamespaceMetaDTO();
    meta.setActive(true);
    dto.setId("SomeId");
    meta.setIndex(123);
    dto.setMeta(meta);
    NamespaceDTO namespace = new NamespaceDTO();
    namespace.setDepth(111);
    namespace.setRegistrationType(NamespaceRegistrationTypeEnum.NUMBER_0);
    namespace.setOwnerAddress(ownerAddress.encoded());
    AliasDTO alias = new AliasDTO();
    alias.setType(AliasTypeEnum.NUMBER_1);
    alias.setMosaicId("528280977531");
    namespace.setAlias(alias);
    dto.setNamespace(namespace);
    mockRemoteCall(dto);
    MosaicId linkedMosaicId = repository.getLinkedMosaicId(namespaceId).toFuture().get();
    Assertions.assertNotNull(linkedMosaicId);
    Assertions.assertEquals("0000528280977531", linkedMosaicId.getIdAsHex());
}
Also used : NamespaceDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO) Address(io.nem.symbol.sdk.model.account.Address) NamespaceMetaDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceMetaDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceInfoDTO) AliasDTO(io.nem.symbol.sdk.openapi.vertx.model.AliasDTO) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 2 with NamespaceDTO

use of io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryVertxImplTest method search.

@Test
public void search() throws Exception {
    Address address = Address.generateRandom(networkType);
    Address ownerAccount = Account.generateNewAccount(NetworkType.MIJIN_TEST).getAddress();
    NamespaceInfoDTO dto = new NamespaceInfoDTO();
    NamespaceMetaDTO meta = new NamespaceMetaDTO();
    meta.setActive(true);
    dto.setId("SomeId");
    meta.setIndex(123);
    dto.setMeta(meta);
    NamespaceDTO namespace = new NamespaceDTO();
    namespace.setDepth(111);
    namespace.setVersion(1);
    namespace.setStartHeight(BigInteger.valueOf(4));
    namespace.setEndHeight(BigInteger.valueOf(5));
    namespace.setRegistrationType(NamespaceRegistrationTypeEnum.NUMBER_1);
    namespace.setOwnerAddress(ownerAccount.encoded());
    AliasDTO alias = new AliasDTO();
    alias.setType(AliasTypeEnum.NUMBER_2);
    alias.setAddress(address.encoded());
    namespace.setAlias(alias);
    dto.setNamespace(namespace);
    mockRemoteCall(toPage(dto));
    NamespaceInfo info = repository.search(new NamespaceSearchCriteria().ownerAddress(address)).toFuture().get().getData().get(0);
    Assertions.assertNotNull(info);
    Assertions.assertEquals(NamespaceRegistrationType.SUB_NAMESPACE, info.getRegistrationType());
    Assertions.assertEquals(dto.getId(), info.getRecordId().get());
    Assertions.assertEquals(meta.getIndex(), info.getIndex());
    Assertions.assertEquals(meta.getActive(), info.isActive());
    Assertions.assertEquals(BigInteger.valueOf(4), info.getStartHeight());
    Assertions.assertEquals(BigInteger.valueOf(5), info.getEndHeight());
}
Also used : NamespaceDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO) Address(io.nem.symbol.sdk.model.account.Address) NamespaceMetaDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceMetaDTO) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceInfoDTO) AliasDTO(io.nem.symbol.sdk.openapi.vertx.model.AliasDTO) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceSearchCriteria(io.nem.symbol.sdk.api.NamespaceSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 3 with NamespaceDTO

use of io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryVertxImplTest method shouldGetLinkedAddress.

@Test
public void shouldGetLinkedAddress() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    Address ownerAddress = Account.generateNewAccount(networkType).getAddress();
    NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
    NamespaceInfoDTO dto = new NamespaceInfoDTO();
    NamespaceMetaDTO meta = new NamespaceMetaDTO();
    meta.setActive(true);
    dto.setId("SomeId");
    meta.setIndex(123);
    dto.setMeta(meta);
    NamespaceDTO namespace = new NamespaceDTO();
    namespace.setDepth(111);
    namespace.setVersion(1);
    namespace.setRegistrationType(NamespaceRegistrationTypeEnum.NUMBER_0);
    namespace.setOwnerAddress(ownerAddress.encoded());
    AliasDTO alias = new AliasDTO();
    alias.setType(AliasTypeEnum.NUMBER_2);
    alias.setAddress(address.encoded());
    namespace.setAlias(alias);
    dto.setNamespace(namespace);
    mockRemoteCall(dto);
    Address linkedAddress = repository.getLinkedAddress(namespaceId).toFuture().get();
    Assertions.assertNotNull(linkedAddress);
    Assertions.assertEquals(address, linkedAddress);
}
Also used : NamespaceDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO) Address(io.nem.symbol.sdk.model.account.Address) NamespaceMetaDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceMetaDTO) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceInfoDTO) AliasDTO(io.nem.symbol.sdk.openapi.vertx.model.AliasDTO) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 4 with NamespaceDTO

use of io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryVertxImplTest method shouldGetNamespace.

@Test
public void shouldGetNamespace() throws Exception {
    Address ownerAddress = Account.generateNewAccount(networkType).getAddress();
    NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
    NamespaceInfoDTO dto = new NamespaceInfoDTO();
    dto.setId("SomeId");
    NamespaceMetaDTO meta = new NamespaceMetaDTO();
    meta.setActive(true);
    meta.setIndex(123);
    dto.setMeta(meta);
    NamespaceDTO namespace = new NamespaceDTO();
    namespace.setDepth(111);
    namespace.setVersion(1);
    namespace.setStartHeight(BigInteger.valueOf(4));
    namespace.setEndHeight(BigInteger.valueOf(5));
    namespace.setRegistrationType(NamespaceRegistrationTypeEnum.NUMBER_1);
    namespace.setOwnerAddress(ownerAddress.encoded());
    AliasDTO alias = new AliasDTO();
    alias.setType(AliasTypeEnum.NUMBER_1);
    alias.setMosaicId("123");
    namespace.setAlias(alias);
    dto.setNamespace(namespace);
    mockRemoteCall(dto);
    NamespaceInfo info = repository.getNamespace(namespaceId).toFuture().get();
    Assertions.assertNotNull(info);
    Assertions.assertEquals(NamespaceRegistrationType.SUB_NAMESPACE, info.getRegistrationType());
    Assertions.assertEquals(dto.getId(), info.getRecordId().get());
    Assertions.assertEquals(meta.getIndex(), info.getIndex());
    Assertions.assertEquals(meta.getActive(), info.isActive());
    Assertions.assertEquals(BigInteger.valueOf(4), info.getStartHeight());
    Assertions.assertEquals(BigInteger.valueOf(5), info.getEndHeight());
}
Also used : NamespaceDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO) Address(io.nem.symbol.sdk.model.account.Address) NamespaceMetaDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceMetaDTO) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceInfoDTO) AliasDTO(io.nem.symbol.sdk.openapi.vertx.model.AliasDTO) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) Test(org.junit.jupiter.api.Test)

Aggregations

Address (io.nem.symbol.sdk.model.account.Address)4 AliasDTO (io.nem.symbol.sdk.openapi.vertx.model.AliasDTO)4 NamespaceDTO (io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO)4 NamespaceInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.NamespaceInfoDTO)4 NamespaceMetaDTO (io.nem.symbol.sdk.openapi.vertx.model.NamespaceMetaDTO)4 Test (org.junit.jupiter.api.Test)4 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)3 NamespaceInfo (io.nem.symbol.sdk.model.namespace.NamespaceInfo)2 NamespaceSearchCriteria (io.nem.symbol.sdk.api.NamespaceSearchCriteria)1 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)1