Search in sources :

Example 41 with RepositoryFactory

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

the class RestrictionMosaicRepositoryIntegrationTest method searchGlobalRestriction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchGlobalRestriction(RepositoryType type) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    RestrictionMosaicRepository repository = repositoryFactory.createRestrictionMosaicRepository();
    MosaicRestrictionEntryType entryType = MosaicRestrictionEntryType.GLOBAL;
    Page<MosaicRestriction<?>> page = get(repository.search(new MosaicRestrictionSearchCriteria().entryType(entryType)));
    System.out.println(page.getData().size());
    page.getData().forEach(restriction -> {
        Assertions.assertTrue(restriction instanceof MosaicGlobalRestriction);
        Assertions.assertEquals(entryType, restriction.getEntryType());
        Assertions.assertNotNull(restriction.getMosaicId());
        Assertions.assertNotNull(restriction.getCompositeHash());
        Assertions.assertFalse(restriction.getRestrictions().isEmpty());
    });
}
Also used : MosaicRestrictionEntryType(io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType) RestrictionMosaicRepository(io.nem.symbol.sdk.api.RestrictionMosaicRepository) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) MosaicRestriction(io.nem.symbol.sdk.model.restriction.MosaicRestriction) MosaicRestrictionSearchCriteria(io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria) MosaicGlobalRestriction(io.nem.symbol.sdk.model.restriction.MosaicGlobalRestriction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 42 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory 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 43 with RepositoryFactory

use of io.nem.symbol.sdk.api.RepositoryFactory 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)

Example 44 with RepositoryFactory

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

the class BlockServiceTest method setup.

@BeforeEach
void setup() {
    RepositoryFactory factory = Mockito.mock(RepositoryFactory.class);
    blockRepositoryMock = Mockito.mock(BlockRepository.class);
    Mockito.when(factory.createBlockRepository()).thenReturn(blockRepositoryMock);
    service = new BlockServiceImpl(factory);
}
Also used : BlockRepository(io.nem.symbol.sdk.api.BlockRepository) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)44 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 EnumSource (org.junit.jupiter.params.provider.EnumSource)16 Test (org.junit.jupiter.api.Test)11 BeforeEach (org.junit.jupiter.api.BeforeEach)7 RepositoryFactoryConfiguration (io.nem.symbol.sdk.api.RepositoryFactoryConfiguration)6 Account (io.nem.symbol.sdk.model.account.Account)6 BigInteger (java.math.BigInteger)6 Listener (io.nem.symbol.sdk.api.Listener)5 MetadataRepository (io.nem.symbol.sdk.api.MetadataRepository)5 NamespaceRepository (io.nem.symbol.sdk.api.NamespaceRepository)5 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)5 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)5 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)4 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)4 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)4 CurrencyService (io.nem.symbol.sdk.api.CurrencyService)3 MetadataTransactionService (io.nem.symbol.sdk.api.MetadataTransactionService)3 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)3 TransactionService (io.nem.symbol.sdk.api.TransactionService)3