Search in sources :

Example 86 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class CurrencyServiceIntegrationTest method testNetworkCurrencyInvaliMosaicId.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void testNetworkCurrencyInvaliMosaicId(RepositoryType type) {
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    CurrencyService service = new CurrencyServiceImpl(repositoryFactory);
    RepositoryCallException exception = Assertions.assertThrows(RepositoryCallException.class, () -> {
        get(service.getCurrency(new MosaicId(BigInteger.TEN)));
    });
    Assertions.assertEquals("ApiException: Not Found - 404 - ResourceNotFound - no resource exists with id '000000000000000A'", exception.getMessage());
}
Also used : RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CurrencyService(io.nem.symbol.sdk.api.CurrencyService) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 87 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class CreatingAnEscrowContractWithAggregateBondedTransactionIntegrationTest method executeTransfer.

@Test
@Disabled
void executeTransfer() {
    Account ticketDistributorAccount = this.config().getTestAccount();
    Account aliceAccount = this.config().getTestAccount2();
    RepositoryType type = DEFAULT_REPOSITORY_TYPE;
    MosaicId mosaicId = createMosaic(ticketDistributorAccount, type, BigInteger.ZERO, null);
    TransferTransaction aliceToTicketDistributorTx = TransferTransactionFactory.create(getNetworkType(), getDeadline(), ticketDistributorAccount.getAddress(), Collections.singletonList(getNetworkCurrency().createRelative(BigInteger.valueOf(100)))).message(new PlainMessage("send 100 cat.currency to distributor")).maxFee(maxFee).build();
    TransferTransaction ticketDistributorToAliceTx = TransferTransactionFactory.create(getNetworkType(), getDeadline(), aliceAccount.getAddress(), Collections.singletonList(new Mosaic(mosaicId, BigInteger.ONE))).message(new PlainMessage("send 1 museum ticket to alice")).maxFee(maxFee).build();
    /* end block 01 */
    /* start block 02 */
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createBonded(getNetworkType(), getDeadline(), Arrays.asList(aliceToTicketDistributorTx.toAggregate(aliceAccount.getPublicAccount()), ticketDistributorToAliceTx.toAggregate(ticketDistributorAccount.getPublicAccount()))).maxFee(maxFee).build();
    String networkGenerationHash = getGenerationHash();
    SignedTransaction signedTransaction = aliceAccount.sign(aggregateTransaction, networkGenerationHash);
    System.out.println("Aggregate Transaction Hash: " + signedTransaction.getHash());
    /* end block 02 */
    /* start block 03 */
    HashLockTransaction hashLockTransaction = HashLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.TEN), BigInteger.valueOf(480), signedTransaction).maxFee(maxFee).build();
    SignedTransaction signedHashLockTransaction = aliceAccount.sign(hashLockTransaction, networkGenerationHash);
    System.out.println("Hash Transaction Hash: " + hashLockTransaction.getHash());
    TransactionService transactionService = getTransactionService(type);
    Transaction transaction = get(transactionService.announceHashLockAggregateBonded(getListener(type), signedHashLockTransaction, signedTransaction));
    Assertions.assertNotNull(transaction);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) TransactionService(io.nem.symbol.sdk.api.TransactionService) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 88 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicAddressRestrictionIntegrationTest method getMosaicAddressRestrictionWhenMosaicDoesNotExist.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMosaicAddressRestrictionWhenMosaicDoesNotExist(RepositoryType type) {
    RestrictionMosaicRepository repository = getRepositoryFactory(type).createRestrictionMosaicRepository();
    Address address = Address.createFromPublicKey("67F69FA4BFCD158F6E1AF1ABC82F725F5C5C4710D6E29217B12BE66397435DFB", getNetworkType());
    Page<MosaicRestriction<?>> page = get(repository.search(new MosaicRestrictionSearchCriteria().mosaicId(new MosaicId(BigInteger.valueOf(888888))).targetAddress(address).entryType(MosaicRestrictionEntryType.ADDRESS)));
    Assertions.assertTrue(page.getData().isEmpty());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) RestrictionMosaicRepository(io.nem.symbol.sdk.api.RestrictionMosaicRepository) 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 89 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicDefinitionTransactionIntegrationTest method standaloneMosaicDefinitionTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneMosaicDefinitionTransaction(RepositoryType type) {
    MosaicId mosaicId = createMosaic(type);
    sleep(1000);
    MosaicInfo mosaicInfo = get(getRepositoryFactory(type).createMosaicRepository().getMosaic(mosaicId));
    Assertions.assertEquals(mosaicId, mosaicInfo.getMosaicId());
    Assertions.assertEquals(4, mosaicInfo.getDivisibility());
    Assertions.assertTrue(mosaicInfo.isTransferable());
    Assertions.assertTrue(mosaicInfo.isSupplyMutable());
    Assertions.assertTrue(mosaicInfo.isRestrictable());
    Assertions.assertEquals(100, mosaicInfo.getDuration().intValue());
}
Also used : MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 90 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicDefinitionTransactionIntegrationTest method standaloneMosaicSupplyChangeTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneMosaicSupplyChangeTransaction(RepositoryType type) {
    MosaicId mosaicId = createMosaic(type);
    MosaicSupplyChangeTransaction mosaicSupplyChangeTransaction = MosaicSupplyChangeTransactionFactory.create(getNetworkType(), getDeadline(), mosaicId, MosaicSupplyChangeActionType.INCREASE, BigInteger.valueOf(11)).maxFee(maxFee).build();
    announceAndValidate(type, account, mosaicSupplyChangeTransaction);
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)138 Test (org.junit.jupiter.api.Test)92 Address (io.nem.symbol.sdk.model.account.Address)53 BigInteger (java.math.BigInteger)53 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 EnumSource (org.junit.jupiter.params.provider.EnumSource)23 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)19 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)18 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)17 Account (io.nem.symbol.sdk.model.account.Account)16 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)15 ArrayList (java.util.ArrayList)13 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)12 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)10 MosaicGlobalRestrictionTransaction (io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransaction)10 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)10 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)7 Currency (io.nem.symbol.sdk.model.mosaic.Currency)7 MosaicNames (io.nem.symbol.sdk.model.mosaic.MosaicNames)7 MosaicNonce (io.nem.symbol.sdk.model.mosaic.MosaicNonce)7