Search in sources :

Example 1 with AccountMosaicRestrictionTransaction

use of io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction in project nem2-sdk-java by nemtech.

the class TransactionMapperVertxTest method shouldCreateAccountMosaicRestriction.

@Test
public void shouldCreateAccountMosaicRestriction() throws Exception {
    TransactionInfoDTO transactionInfoDTO = TestHelperVertx.loadTransactionInfoDTO("accountMosaicRestrictionTransaction.json");
    AccountMosaicRestrictionTransaction transaction = (AccountMosaicRestrictionTransaction) map(transactionInfoDTO);
    validateStandaloneTransaction(transaction, transactionInfoDTO);
    Assertions.assertEquals(AccountMosaicRestrictionFlags.ALLOW_INCOMING_MOSAIC, transaction.getRestrictionFlags());
    Assertions.assertEquals(1, transaction.getRestrictionAdditions().size());
    Assertions.assertEquals("00003646934825AA", transaction.getRestrictionAdditions().get(0).getIdAsHex());
}
Also used : AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) Test(org.junit.jupiter.api.Test)

Example 2 with AccountMosaicRestrictionTransaction

use of io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction in project nem2-sdk-java by nemtech.

the class TransactionMapperOkHttpTest method shouldCreateAccountMosaicRestriction.

@Test
public void shouldCreateAccountMosaicRestriction() throws Exception {
    TransactionInfoDTO transactionInfoDTO = TestHelperOkHttp.loadTransactionInfoDTO("accountMosaicRestrictionTransaction.json");
    AccountMosaicRestrictionTransaction transaction = (AccountMosaicRestrictionTransaction) map(transactionInfoDTO);
    validateStandaloneTransaction(transaction, transactionInfoDTO);
    Assertions.assertEquals(AccountMosaicRestrictionFlags.ALLOW_INCOMING_MOSAIC, transaction.getRestrictionFlags());
    Assertions.assertEquals(1, transaction.getRestrictionAdditions().size());
    Assertions.assertEquals("00003646934825AA", transaction.getRestrictionAdditions().get(0).getIdAsHex());
}
Also used : AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) TransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO) Test(org.junit.jupiter.api.Test)

Example 3 with AccountMosaicRestrictionTransaction

use of io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction in project nem2-sdk-java by nemtech.

the class AccountRestrictionIntegrationTest method sendAccountRestrictionMosaic.

private void sendAccountRestrictionMosaic(RepositoryType type, UnresolvedMosaicId unresolvedMosaicId, boolean add, AccountMosaicRestrictionFlags accountRestrictionFlags) {
    List<UnresolvedMosaicId> additions = add ? Collections.singletonList(unresolvedMosaicId) : Collections.emptyList();
    List<UnresolvedMosaicId> deletions = !add ? Collections.singletonList(unresolvedMosaicId) : Collections.emptyList();
    AccountMosaicRestrictionTransaction transaction = AccountMosaicRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), accountRestrictionFlags, additions, deletions).maxFee(maxFee).build();
    AccountMosaicRestrictionTransaction processedTransaction = announceAndValidate(type, testAccount, transaction);
    Assertions.assertEquals(accountRestrictionFlags, processedTransaction.getRestrictionFlags());
    Assertions.assertEquals(additions, processedTransaction.getRestrictionAdditions());
    Assertions.assertEquals(deletions, processedTransaction.getRestrictionDeletions());
}
Also used : AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 4 with AccountMosaicRestrictionTransaction

use of io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction in project nem2-sdk-java by nemtech.

the class TransactionServiceTest method accountMosaicRestrictionTransactionResolveAlias.

@Test
void accountMosaicRestrictionTransactionResolveAlias() throws ExecutionException, InterruptedException {
    String transactionHash = "aaaa";
    TransactionFactory<AccountMosaicRestrictionTransaction> factory = AccountMosaicRestrictionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), AccountMosaicRestrictionFlags.ALLOW_INCOMING_MOSAIC, Arrays.asList(mosaicNamespace1, mosaicId2, mosaicNamespace2), Arrays.asList(mosaicNamespace2, mosaicNamespace3, mosaicId3)).transactionInfo(TransactionInfo.create(height, 4, "ABC", transactionHash, ""));
    AccountMosaicRestrictionTransaction transaction = factory.build();
    simulateStatement(height, 5, 0);
    List<String> hashes = Collections.singletonList(transactionHash);
    Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
    AccountMosaicRestrictionTransaction resolvedTransaction = (AccountMosaicRestrictionTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
    Assertions.assertEquals(Arrays.asList(mosaicId1, mosaicId2, mosaicId2), resolvedTransaction.getRestrictionAdditions());
    Assertions.assertEquals(Arrays.asList(mosaicId2, mosaicId3, mosaicId3), resolvedTransaction.getRestrictionDeletions());
}
Also used : AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) Test(org.junit.jupiter.api.Test)

Aggregations

AccountMosaicRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction)4 Test (org.junit.jupiter.api.Test)3 UnresolvedMosaicId (io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)1 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)1 TransactionInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO)1 TransactionInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO)1