use of io.nem.symbol.sdk.api.MosaicRepository in project nem2-sdk-java by nemtech.
the class CurrencyServiceTest method setup.
@BeforeEach
void setup() {
RepositoryFactory factory = mock(RepositoryFactory.class);
namespaceRepository = mock(NamespaceRepository.class);
when(factory.createNamespaceRepository()).thenReturn(namespaceRepository);
mosaicRepository = mock(MosaicRepository.class);
when(factory.createMosaicRepository()).thenReturn(mosaicRepository);
networkRepository = mock(NetworkRepository.class);
when(factory.createNetworkRepository()).thenReturn(networkRepository);
service = new CurrencyServiceImpl(factory);
}
use of io.nem.symbol.sdk.api.MosaicRepository in project nem2-sdk-java by nemtech.
the class StateProofServiceTest method mosaic.
@Test
void mosaic() throws Exception {
MosaicRepository repository = mock(MosaicRepository.class);
when(factory.createMosaicRepository()).thenReturn(repository);
MosaicId id = new MosaicId(BigInteger.ONE);
MosaicInfo state = Mockito.mock(MosaicInfo.class);
when(state.getMosaicId()).thenReturn(id);
when(state.serialize()).thenReturn(ConvertUtils.fromHexToBytes(serialized));
when(repository.getMosaic(eq(id))).thenReturn(Observable.just(state));
when(repository.getMosaicMerkle(eq(id))).thenReturn(Observable.just(tree));
StateMerkleProof<MosaicInfo> proof = service.mosaic(id).toFuture().get();
Assertions.assertTrue(proof.isValid());
Assertions.assertEquals(state, proof.getState());
}
use of io.nem.symbol.sdk.api.MosaicRepository in project nem2-sdk-java by nemtech.
the class MerkleLoaderIntegrationTest method mosaics.
public List<Arguments> mosaics() {
RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
MosaicRepository repository = repositoryFactory.createMosaicRepository();
return getArguments(repository, new MosaicSearchCriteria().order(ORDER_BY));
}
use of io.nem.symbol.sdk.api.MosaicRepository in project nem2-sdk-java by nemtech.
the class MosaicRepositoryIntegrationTest method searchUsingOffset.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUsingOffset(RepositoryType type) {
MosaicRepository mosaicRepository = getMosaicRepository(type);
MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(mosaicRepository);
MosaicSearchCriteria criteria = new MosaicSearchCriteria();
criteria.setPageSize(10);
int offsetIndex = 2;
List<MosaicInfo> mosaicsWithoutOffset = get(streamer.search(criteria).toList().toObservable());
criteria.setOffset(mosaicsWithoutOffset.get(offsetIndex).getRecordId().get());
List<MosaicInfo> mosaicFromOffsets = get(streamer.search(criteria).toList().toObservable());
PaginationTester.sameEntities(mosaicsWithoutOffset.stream().skip(offsetIndex + 1).collect(Collectors.toList()), mosaicFromOffsets);
}
Aggregations