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());
}
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);
}
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());
}
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());
}
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);
}
Aggregations