Search in sources :

Example 31 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId 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 32 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId 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 33 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryVertxImplTest method shouldGetNamespaceNames.

@Test
public void shouldGetNamespaceNames() throws Exception {
    NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
    NamespaceNameDTO dto1 = new NamespaceNameDTO();
    dto1.setName("someName1");
    dto1.setId("1");
    dto1.setParentId("2");
    NamespaceNameDTO dto2 = new NamespaceNameDTO();
    dto2.setName("someName2");
    dto2.setId("3");
    mockRemoteCall(Arrays.asList(dto1, dto2));
    List<NamespaceName> names = repository.getNamespaceNames(Arrays.asList(namespaceId)).toFuture().get();
    Assertions.assertNotNull(names);
    Assertions.assertEquals(2, names.size());
    Assertions.assertEquals("someName1", names.get(0).getName());
    Assertions.assertEquals(BigInteger.valueOf(1L), names.get(0).getNamespaceId().getId());
    Assertions.assertEquals(BigInteger.valueOf(2L), names.get(0).getParentId().orElseThrow(() -> new IllegalStateException("No parent id")).getId());
    Assertions.assertEquals("someName2", names.get(1).getName());
    Assertions.assertEquals(BigInteger.valueOf(3L), names.get(1).getNamespaceId().getId());
    Assertions.assertFalse(names.get(1).getParentId().isPresent());
}
Also used : NamespaceName(io.nem.symbol.sdk.model.namespace.NamespaceName) NamespaceNameDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceNameDTO) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 34 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId 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)

Example 35 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class AddressAliasTransactionMapper method createFactory.

@Override
protected AddressAliasTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AddressAliasTransactionDTO transaction) {
    NamespaceId namespaceId = MapperUtils.toNamespaceId(transaction.getNamespaceId());
    AliasAction aliasAction = AliasAction.rawValueOf(transaction.getAliasAction().getValue().byteValue());
    return AddressAliasTransactionFactory.create(networkType, deadline, aliasAction, namespaceId, toAddress(transaction.getAddress()));
}
Also used : AliasAction(io.nem.symbol.sdk.model.namespace.AliasAction) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId)

Aggregations

NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)70 Test (org.junit.jupiter.api.Test)37 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)18 BigInteger (java.math.BigInteger)17 Account (io.nem.symbol.sdk.model.account.Account)15 Address (io.nem.symbol.sdk.model.account.Address)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 EnumSource (org.junit.jupiter.params.provider.EnumSource)14 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)10 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)9 NamespaceName (io.nem.symbol.sdk.model.namespace.NamespaceName)8 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)8 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)8 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)7 Observable (io.reactivex.Observable)7 List (java.util.List)7 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)6 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)6 TransferTransactionFactory (io.nem.symbol.sdk.model.transaction.TransferTransactionFactory)6 ArrayList (java.util.ArrayList)6