Search in sources :

Example 1 with NamespaceInfo

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

the class NamespaceRepositoryIntegrationTest method getNamespace.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getNamespace(RepositoryType type) {
    NamespaceInfo namespaceInfo = get(getNamespaceRepository(type).getNamespace(namespaceId));
    assertEquals(new BigInteger("1"), namespaceInfo.getStartHeight());
    assertEquals(namespaceId, namespaceInfo.getId());
    assertEquals(namespaceId, namespaceInfo.getLevels().get(1));
}
Also used : BigInteger(java.math.BigInteger) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with NamespaceInfo

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

the class NamespaceRepositoryIntegrationTest method getNamespacesFromAccount.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getNamespacesFromAccount(RepositoryType type) {
    Account account = config().getDefaultAccount();
    List<NamespaceInfo> namespacesInfo = get(getNamespaceRepository(type).search(new NamespaceSearchCriteria().ownerAddress(account.getAddress()))).getData();
    namespacesInfo.forEach(n -> {
        Assertions.assertEquals(account.getAddress(), n.getOwnerAddress());
    });
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceSearchCriteria(io.nem.symbol.sdk.api.NamespaceSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with NamespaceInfo

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

the class MerkleLoaderIntegrationTest method namespacesMerkles.

@ParameterizedTest
@MethodSource("namespaces")
void namespacesMerkles(NamespaceInfo state, RepositoryType repositoryType) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(repositoryType);
    StateProofServiceImpl service = new StateProofServiceImpl(repositoryFactory);
    StateMerkleProof<NamespaceInfo> proof = get(service.namespace(state));
    Assertions.assertTrue(proof.isValid(), "Invalid proof " + proof.getState().getId().getIdAsHex());
}
Also used : RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with NamespaceInfo

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

the class NamespaceRegistrationIntegrationTest method standaloneSubNamespaceRegisterNamespaceTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneSubNamespaceRegisterNamespaceTransaction(RepositoryType type) {
    this.standaloneRootRegisterNamespaceTransaction(type);
    String namespaceName = "test-sub-namespace-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
    NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), namespaceName, this.rootNamespaceId).maxFee(maxFee).build();
    announceAndValidate(type, this.account, namespaceRegistrationTransaction);
    sleep(1000);
    NamespaceInfo namespaceInfo = get(getRepositoryFactory(type).createNamespaceRepository().getNamespace(namespaceRegistrationTransaction.getNamespaceId()));
    Assertions.assertEquals(this.account.getAddress(), namespaceInfo.getOwnerAddress());
    Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceId(), namespaceInfo.getId());
}
Also used : NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with NamespaceInfo

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

the class NamespaceRegistrationIntegrationTest method aggregateRootRegisterNamespaceTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateRootRegisterNamespaceTransaction(RepositoryType type) {
    String namespaceName = "test-root-namespace-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
    NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, helper().getDuration()).maxFee(maxFee).build();
    announceAggregateAndValidate(type, namespaceRegistrationTransaction, this.account);
    rootNamespaceId = namespaceRegistrationTransaction.getNamespaceId();
    sleep(1000);
    NamespaceInfo namespaceInfo = get(getRepositoryFactory(type).createNamespaceRepository().getNamespace(namespaceRegistrationTransaction.getNamespaceId()));
    Assertions.assertEquals(this.account.getAddress(), namespaceInfo.getOwnerAddress());
    Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceId(), namespaceInfo.getId());
}
Also used : NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

NamespaceInfo (io.nem.symbol.sdk.model.namespace.NamespaceInfo)15 Address (io.nem.symbol.sdk.model.account.Address)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 NamespaceSearchCriteria (io.nem.symbol.sdk.api.NamespaceSearchCriteria)6 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)6 EnumSource (org.junit.jupiter.params.provider.EnumSource)6 Test (org.junit.jupiter.api.Test)5 NamespaceRepository (io.nem.symbol.sdk.api.NamespaceRepository)4 NamespaceRegistrationTransaction (io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)4 Page (io.nem.symbol.sdk.api.Page)3 MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)3 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)3 NamespaceRegistrationType (io.nem.symbol.sdk.model.namespace.NamespaceRegistrationType)3 NamespaceDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceDTO)3 NamespaceInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceInfoDTO)3 NamespaceDTO (io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO)3 NamespaceInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.NamespaceInfoDTO)3 Observable (io.reactivex.Observable)3 MapperUtils (io.nem.symbol.core.utils.MapperUtils)2 MapperUtils.toNamespaceId (io.nem.symbol.core.utils.MapperUtils.toNamespaceId)2