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)));
}
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)));
}
Aggregations