Search in sources :

Example 6 with NamespaceRepository

use of io.nem.symbol.sdk.api.NamespaceRepository in project nem2-sdk-java by nemtech.

the class MetadataTransactionServiceTest method setup.

@BeforeEach
void setup() {
    targetAccount = Account.generateNewAccount(networkType).getPublicAccount();
    sourceAddress = Account.generateNewAccount(networkType).getAddress();
    mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), targetAccount);
    namespaceId = NamespaceId.createFromId(BigInteger.TEN);
    RepositoryFactory factory = Mockito.mock(RepositoryFactory.class);
    metadataRepositoryMock = Mockito.mock(MetadataRepository.class);
    NamespaceRepository namespaceRepository = mock(NamespaceRepository.class);
    Mockito.when(factory.createMetadataRepository()).thenReturn(metadataRepositoryMock);
    Mockito.when(factory.getNetworkType()).thenReturn(Observable.just(networkType));
    Mockito.when(factory.getEpochAdjustment()).thenReturn(Observable.just(Duration.ofSeconds(100L)));
    when(factory.createNamespaceRepository()).thenReturn(namespaceRepository);
    service = new MetadataTransactionServiceImpl(factory);
    when(namespaceRepository.getNamespace(mosaicAlias)).thenReturn(Observable.just(createAlias(mosaicId)));
}
Also used : NamespaceRepository(io.nem.symbol.sdk.api.NamespaceRepository) MetadataRepository(io.nem.symbol.sdk.api.MetadataRepository) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with NamespaceRepository

use of io.nem.symbol.sdk.api.NamespaceRepository in project nem2-sdk-java by nemtech.

the class AliasServiceTest method setup.

@BeforeEach
void setup() {
    RepositoryFactory factory = mock(RepositoryFactory.class);
    namespaceRepository = mock(NamespaceRepository.class);
    when(factory.createNamespaceRepository()).thenReturn(namespaceRepository);
    when(factory.getNetworkType()).thenReturn(Observable.just(networkType));
    service = new AliasServiceImpl(factory);
    when(namespaceRepository.getNamespace(Mockito.any())).thenReturn(Observable.error(new IllegalStateException("Alias does not exist")));
    when(namespaceRepository.getNamespace(accountAlias1)).thenReturn(Observable.just(createAlias(account1.getAddress())));
    when(namespaceRepository.getNamespace(accountAlias2)).thenReturn(Observable.just(createAlias(account2.getAddress())));
    when(namespaceRepository.getNamespace(mosaicAlias1)).thenReturn(Observable.just(createAlias(mosaicId1)));
    when(namespaceRepository.getNamespace(mosaicAlias2)).thenReturn(Observable.just(createAlias(mosaicId2)));
}
Also used : NamespaceRepository(io.nem.symbol.sdk.api.NamespaceRepository) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

NamespaceRepository (io.nem.symbol.sdk.api.NamespaceRepository)7 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)6 BeforeEach (org.junit.jupiter.api.BeforeEach)4 NamespaceSearchCriteria (io.nem.symbol.sdk.api.NamespaceSearchCriteria)2 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)2 NamespaceInfo (io.nem.symbol.sdk.model.namespace.NamespaceInfo)2 Hashes (io.nem.symbol.core.crypto.Hashes)1 ConvertUtils (io.nem.symbol.core.utils.ConvertUtils)1 MetadataRepository (io.nem.symbol.sdk.api.MetadataRepository)1 MosaicRepository (io.nem.symbol.sdk.api.MosaicRepository)1 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)1 NetworkRepository (io.nem.symbol.sdk.api.NetworkRepository)1 Page (io.nem.symbol.sdk.api.Page)1 PaginationStreamer (io.nem.symbol.sdk.api.PaginationStreamer)1 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)1 StateProofService (io.nem.symbol.sdk.api.StateProofService)1 AccountInfo (io.nem.symbol.sdk.model.account.AccountInfo)1 AccountRestrictions (io.nem.symbol.sdk.model.account.AccountRestrictions)1 Address (io.nem.symbol.sdk.model.account.Address)1 MultisigAccountInfo (io.nem.symbol.sdk.model.account.MultisigAccountInfo)1