use of io.nem.symbol.sdk.model.restriction.MosaicRestriction 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.model.restriction.MosaicRestriction in project nem2-sdk-java by nemtech.
the class StateProofServiceTest method mosaicRestriction.
@Test
void mosaicRestriction() throws Exception {
RestrictionMosaicRepository repository = mock(RestrictionMosaicRepository.class);
when(factory.createRestrictionMosaicRepository()).thenReturn(repository);
String id = "hash";
MosaicRestriction<?> state = Mockito.mock(MosaicRestriction.class);
when(state.getCompositeHash()).thenReturn(id);
when(state.serialize()).thenReturn(ConvertUtils.fromHexToBytes(serialized));
when(repository.getMosaicRestrictions(eq(id))).thenReturn(Observable.just(state));
when(repository.getMosaicRestrictionsMerkle(eq(id))).thenReturn(Observable.just(tree));
StateMerkleProof<MosaicRestriction<?>> proof = service.mosaicRestriction(id).toFuture().get();
Assertions.assertTrue(proof.isValid());
Assertions.assertEquals(state, proof.getState());
}
Aggregations