Search in sources :

Example 1 with MosaicSearchCriteria

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

the class MosaicRepositoryIntegrationTest method searchByOwnerAddressInvalid.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByOwnerAddressInvalid(RepositoryType type) {
    MosaicSearchCriteria criteria = new MosaicSearchCriteria();
    Address address = Account.generateNewAccount(getNetworkType()).getAddress();
    criteria.ownerAddress(address);
    MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(getMosaicRepository(type));
    List<MosaicInfo> mosaics = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertTrue(mosaics.isEmpty());
}
Also used : MosaicPaginationStreamer(io.nem.symbol.sdk.api.MosaicPaginationStreamer) MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) Address(io.nem.symbol.sdk.model.account.Address) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with MosaicSearchCriteria

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

the class MosaicRepositoryIntegrationTest method searchByOwnerAddress.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByOwnerAddress(RepositoryType type) {
    MosaicSearchCriteria criteria = new MosaicSearchCriteria();
    Address address = testAccount.getAddress();
    criteria.ownerAddress(address);
    MosaicPaginationStreamer streamer = new MosaicPaginationStreamer(getMosaicRepository(type));
    List<MosaicInfo> mosaics = get(streamer.search(criteria).toList().toObservable());
    mosaics.forEach(m -> Assertions.assertEquals(address, m.getOwnerAddress()));
    Assertions.assertFalse(mosaics.isEmpty());
}
Also used : MosaicPaginationStreamer(io.nem.symbol.sdk.api.MosaicPaginationStreamer) MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) Address(io.nem.symbol.sdk.model.account.Address) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with MosaicSearchCriteria

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

the class MosaicRepositoryVertxImplTest method shouldGetMosaicsFromAccount.

@Test
public void shouldGetMosaicsFromAccount() throws Exception {
    Address address = Address.generateRandom(this.networkType);
    PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
    MosaicId mosaicId = MapperUtils.toMosaicId("481110499AAA");
    MosaicDTO mosaicDto = new MosaicDTO();
    mosaicDto.setOwnerAddress(address.encoded());
    mosaicDto.setId("481110499AAA");
    mosaicDto.setRevision(123L);
    mosaicDto.setFlags(5);
    mosaicDto.setDivisibility(6);
    mosaicDto.setVersion(1);
    mosaicDto.setDuration(BigInteger.valueOf(7));
    mosaicDto.supply(BigInteger.valueOf(1000));
    mosaicDto.startHeight(BigInteger.valueOf(100));
    mockRemoteCall(toPage(new MosaicInfoDTO().mosaic(mosaicDto).id("ABC")));
    List<MosaicInfo> resolvedList = repository.search(new MosaicSearchCriteria().ownerAddress(publicAccount.getAddress())).toFuture().get().getData();
    Assertions.assertEquals(1, resolvedList.size());
    MosaicInfo mosaicInfo = resolvedList.get(0);
    Assertions.assertEquals(mosaicId, mosaicInfo.getMosaicId());
    Assertions.assertEquals(mosaicDto.getRevision(), mosaicInfo.getRevision());
    Assertions.assertEquals(mosaicDto.getOwnerAddress(), mosaicInfo.getOwnerAddress().encoded(NetworkType.MIJIN_TEST));
    Assertions.assertFalse(mosaicInfo.isTransferable());
    Assertions.assertEquals(6, mosaicInfo.getDivisibility());
    Assertions.assertEquals(BigInteger.valueOf(7), mosaicInfo.getDuration());
    Assertions.assertEquals(mosaicDto.getStartHeight(), mosaicInfo.getStartHeight());
    Assertions.assertEquals(mosaicDto.getSupply(), mosaicInfo.getSupply());
}
Also used : MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) Address(io.nem.symbol.sdk.model.account.Address) MosaicDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicDTO) MosaicInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicInfoDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 4 with MosaicSearchCriteria

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

the class MosaicRepositoryOkHttpImplTest method shouldGetMosaicsFromAccount.

@Test
public void shouldGetMosaicsFromAccount() throws Exception {
    PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
    MosaicId mosaicId = MapperUtils.toMosaicId("481110499AAA");
    Address ownerAddress = Account.generateNewAccount(networkType).getAddress();
    MosaicDTO mosaicDto = new MosaicDTO();
    mosaicDto.setOwnerAddress(ownerAddress.encoded());
    mosaicDto.setId("481110499AAA");
    mosaicDto.setRevision(123L);
    mosaicDto.setFlags(5);
    mosaicDto.setDivisibility(6);
    mosaicDto.setDuration(BigInteger.valueOf(7));
    mosaicDto.supply(BigInteger.valueOf(1000));
    mosaicDto.startHeight(BigInteger.valueOf(100));
    mosaicDto.setVersion(1);
    mockRemoteCall(toPage(new MosaicInfoDTO().mosaic(mosaicDto).id("ABC")));
    List<MosaicInfo> resolvedList = repository.search(new MosaicSearchCriteria().ownerAddress(publicAccount.getAddress())).toFuture().get().getData();
    Assertions.assertEquals(1, resolvedList.size());
    MosaicInfo mosaicInfo = resolvedList.get(0);
    Assertions.assertEquals(mosaicId, mosaicInfo.getMosaicId());
    Assertions.assertEquals(mosaicDto.getRevision(), mosaicInfo.getRevision());
    Assertions.assertEquals(mosaicDto.getOwnerAddress(), mosaicInfo.getOwnerAddress().encoded(networkType));
    Assertions.assertFalse(mosaicInfo.isTransferable());
    Assertions.assertEquals(6, mosaicInfo.getDivisibility());
    Assertions.assertEquals(BigInteger.valueOf(7), mosaicInfo.getDuration());
    Assertions.assertEquals(mosaicDto.getStartHeight(), mosaicInfo.getStartHeight());
    Assertions.assertEquals(mosaicDto.getSupply(), mosaicInfo.getSupply());
}
Also used : MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) Address(io.nem.symbol.sdk.model.account.Address) MosaicDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicDTO) MosaicInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicInfoDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 5 with MosaicSearchCriteria

use of io.nem.symbol.sdk.api.MosaicSearchCriteria 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));
}
Also used : RestrictionMosaicRepository(io.nem.symbol.sdk.api.RestrictionMosaicRepository) MosaicRepository(io.nem.symbol.sdk.api.MosaicRepository) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) MosaicSearchCriteria(io.nem.symbol.sdk.api.MosaicSearchCriteria)

Aggregations

MosaicSearchCriteria (io.nem.symbol.sdk.api.MosaicSearchCriteria)6 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)5 Address (io.nem.symbol.sdk.model.account.Address)4 MosaicPaginationStreamer (io.nem.symbol.sdk.api.MosaicPaginationStreamer)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 MosaicRepository (io.nem.symbol.sdk.api.MosaicRepository)2 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)2 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)2 Test (org.junit.jupiter.api.Test)2 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)1 MosaicDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicDTO)1 MosaicInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicInfoDTO)1 MosaicDTO (io.nem.symbol.sdk.openapi.vertx.model.MosaicDTO)1 MosaicInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.MosaicInfoDTO)1