Search in sources :

Example 1 with MosaicRestrictionEntryType

use of io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType in project nem2-sdk-java by nemtech.

the class RestrictionMosaicRepositoryIntegrationTest method searchAddressRestriction.

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

Example 2 with MosaicRestrictionEntryType

use of io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType in project nem2-sdk-java by nemtech.

the class MosaicRestrictionSearchCriteriaTest method shouldSetValues.

@Test
void shouldSetValues() {
    Address address = Address.generateRandom(NetworkType.TEST_NET);
    MosaicRestrictionEntryType entryType = MosaicRestrictionEntryType.GLOBAL;
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    MosaicRestrictionSearchCriteria criteria = new MosaicRestrictionSearchCriteria();
    criteria.setOrder(OrderBy.DESC);
    criteria.setPageSize(10);
    criteria.setPageNumber(5);
    criteria.setOffset("abc");
    criteria.setMosaicId(mosaicId);
    criteria.setTargetAddress(address);
    criteria.setEntryType(entryType);
    Assertions.assertEquals(OrderBy.DESC, criteria.getOrder());
    Assertions.assertEquals(10, criteria.getPageSize());
    Assertions.assertEquals(5, criteria.getPageNumber());
    Assertions.assertEquals("abc", criteria.getOffset());
    Assertions.assertEquals(mosaicId, criteria.getMosaicId());
    Assertions.assertEquals(address, criteria.getTargetAddress());
    Assertions.assertEquals(entryType, criteria.getEntryType());
}
Also used : MosaicRestrictionEntryType(io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType) Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Test(org.junit.jupiter.api.Test)

Example 3 with MosaicRestrictionEntryType

use of io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType in project nem2-sdk-java by nemtech.

the class MosaicRestrictionSearchCriteriaTest method shouldBeEquals.

@Test
void shouldBeEquals() {
    Address address = Address.generateRandom(NetworkType.TEST_NET);
    MosaicRestrictionEntryType entryType = MosaicRestrictionEntryType.GLOBAL;
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    MosaicRestrictionSearchCriteria criteria1 = new MosaicRestrictionSearchCriteria();
    criteria1.order(OrderBy.DESC);
    criteria1.pageSize(10);
    criteria1.pageNumber(5);
    criteria1.offset("abc");
    criteria1.mosaicId(mosaicId);
    criteria1.targetAddress(address);
    criteria1.entryType(entryType);
    MosaicRestrictionSearchCriteria criteria2 = new MosaicRestrictionSearchCriteria();
    criteria2.setOrder(OrderBy.DESC);
    criteria2.setPageSize(10);
    criteria2.setPageNumber(5);
    criteria2.setOffset("abc");
    criteria2.setMosaicId(mosaicId);
    criteria2.setTargetAddress(address);
    criteria2.setEntryType(entryType);
    Assertions.assertEquals(new MosaicRestrictionSearchCriteria(), new MosaicRestrictionSearchCriteria());
    Assertions.assertEquals(criteria1, criteria2);
    Assertions.assertEquals(criteria1, criteria1);
    Assertions.assertEquals(criteria1.hashCode(), criteria2.hashCode());
    criteria1.pageNumber(30);
    Assertions.assertNotEquals(criteria1, criteria2);
    Assertions.assertNotEquals(criteria1.hashCode(), criteria2.hashCode());
    criteria2.pageNumber(100);
    Assertions.assertNotEquals(criteria1, criteria2);
    Assertions.assertNotEquals(criteria1.hashCode(), criteria2.hashCode());
    Assertions.assertNotEquals("ABC", criteria2);
    Assertions.assertNotEquals(criteria2, "ABC");
}
Also used : MosaicRestrictionEntryType(io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType) Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Test(org.junit.jupiter.api.Test)

Example 4 with MosaicRestrictionEntryType

use of io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType in project nem2-sdk-java by nemtech.

the class MosaicRestrictionSearchCriteriaTest method shouldUseBuilderMethods.

@Test
void shouldUseBuilderMethods() {
    Address address = Address.generateRandom(NetworkType.TEST_NET);
    MosaicRestrictionEntryType entryType = MosaicRestrictionEntryType.GLOBAL;
    MosaicId mosaicId = MosaicId.createFromNonce(MosaicNonce.createRandom(), address);
    MosaicRestrictionSearchCriteria criteria = new MosaicRestrictionSearchCriteria();
    criteria.order(OrderBy.DESC);
    criteria.pageSize(10);
    criteria.pageNumber(5);
    criteria.offset("abc");
    criteria.mosaicId(mosaicId);
    criteria.targetAddress(address);
    criteria.entryType(entryType);
    Assertions.assertEquals(OrderBy.DESC, criteria.getOrder());
    Assertions.assertEquals(10, criteria.getPageSize());
    Assertions.assertEquals(5, criteria.getPageNumber());
    Assertions.assertEquals("abc", criteria.getOffset());
    Assertions.assertEquals(mosaicId, criteria.getMosaicId());
    Assertions.assertEquals(address, criteria.getTargetAddress());
    Assertions.assertEquals(entryType, criteria.getEntryType());
}
Also used : MosaicRestrictionEntryType(io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType) Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Test(org.junit.jupiter.api.Test)

Example 5 with MosaicRestrictionEntryType

use of io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType 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)

Aggregations

MosaicRestrictionEntryType (io.nem.symbol.sdk.model.restriction.MosaicRestrictionEntryType)5 Address (io.nem.symbol.sdk.model.account.Address)3 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)3 Test (org.junit.jupiter.api.Test)3 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)2 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)2 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)2 MosaicRestriction (io.nem.symbol.sdk.model.restriction.MosaicRestriction)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 MosaicAddressRestriction (io.nem.symbol.sdk.model.restriction.MosaicAddressRestriction)1 MosaicGlobalRestriction (io.nem.symbol.sdk.model.restriction.MosaicGlobalRestriction)1