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