Search in sources :

Example 66 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class CurrencyTest method createMosaicWithIntegers.

@Test
void createMosaicWithIntegers() {
    NamespaceId namespaceId = NamespaceId.createFromName("mycurrency");
    Currency currency = new CurrencyBuilder(namespaceId, 3).withSupplyMutable(false).withTransferable(true).build();
    Mosaic mosaic1 = currency.createRelative(15);
    Mosaic mosaic2 = currency.createRelative(BigInteger.valueOf(15));
    Mosaic mosaic3 = currency.createAbsolute(15000);
    Assertions.assertEquals(mosaic1, mosaic2);
    Assertions.assertEquals(mosaic1, mosaic3);
}
Also used : NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 67 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class CurrencyTest method assertCreatedUsingNamespaceIdAndSettingMosaicId.

@Test
void assertCreatedUsingNamespaceIdAndSettingMosaicId() {
    MosaicId mosaicId = new MosaicId(BigInteger.TEN);
    NamespaceId namespaceId = NamespaceId.createFromName("mycurrency");
    Currency currency = new CurrencyBuilder(namespaceId, 6).withSupplyMutable(false).withTransferable(true).withMosaicId(mosaicId).build();
    Assertions.assertEquals(namespaceId, currency.getNamespaceId().get());
    Assertions.assertEquals(namespaceId, currency.getUnresolvedMosaicId());
    assertEquals(mosaicId, currency.getMosaicId().get());
}
Also used : NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 68 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class NetworkHarvestCatHarvestTest method shouldCompareNamespaceIdsForEquality.

@Test
void shouldCompareNamespaceIdsForEquality() {
    NamespaceId namespaceId = NamespaceId.createFromId(BigInteger.valueOf(-7776984613647210212L));
    assertEquals(-7776984613647210212L, namespaceId.getIdAsLong());
    assertEquals(currency.getNamespaceId().get().getIdAsLong(), namespaceId.getIdAsLong());
    assertEquals(currency.getNamespaceId().get().getIdAsHex(), namespaceId.getIdAsHex());
}
Also used : NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 69 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class CurrencyCatCurrencyTest method shouldCompareNamespaceIdsForEquality.

@Test
void shouldCompareNamespaceIdsForEquality() {
    NamespaceId namespaceId = NamespaceId.createFromId(BigInteger.valueOf(-8810190493148073404L));
    assertEquals(-8810190493148073404L, namespaceId.getIdAsLong());
    assertEquals(currency.getNamespaceId().get().getIdAsLong(), namespaceId.getIdAsLong());
    assertEquals(currency.getNamespaceId().get().getIdAsHex(), namespaceId.getIdAsHex());
// Note:
// BigInteger decimal generated from namespace path vs generated using Lower and
// Higher
// integers
// Using namespace path: 9636553580561478212 (Decimal number)
// Using Lower and Higher: -8810190493148073404 (Decimal from signed 2's
// complement)
// In Hexadecimal: 85bbea6cc462b244 (same for both)
}
Also used : NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 70 with NamespaceId

use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class CurrencySymbolXymTest method shouldCompareNamespaceIdsForEquality.

@Test
void shouldCompareNamespaceIdsForEquality() {
    NamespaceId namespaceId = NamespaceId.createFromId(BigInteger.valueOf(-1780160202445377554L));
    assertEquals(-1780160202445377554L, namespaceId.getIdAsLong());
    assertEquals(currency.getNamespaceId().get().getIdAsLong(), namespaceId.getIdAsLong());
    assertEquals(currency.getNamespaceId().get().getIdAsHex(), namespaceId.getIdAsHex());
// Note:
// BigInteger decimal generated from namespace path vs generated using Lower and
// Higher
// integers
// Using namespace path: 9636553580561478212 (Decimal number)
// Using Lower and Higher: -8810190493148073404 (Decimal from signed 2's
// complement)
// In Hexadecimal: 85bbea6cc462b244 (same for both)
}
Also used : NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Aggregations

NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)70 Test (org.junit.jupiter.api.Test)37 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)18 BigInteger (java.math.BigInteger)17 Account (io.nem.symbol.sdk.model.account.Account)15 Address (io.nem.symbol.sdk.model.account.Address)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 EnumSource (org.junit.jupiter.params.provider.EnumSource)14 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)10 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)9 NamespaceName (io.nem.symbol.sdk.model.namespace.NamespaceName)8 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)8 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)8 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)7 Observable (io.reactivex.Observable)7 List (java.util.List)7 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)6 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)6 TransferTransactionFactory (io.nem.symbol.sdk.model.transaction.TransferTransactionFactory)6 ArrayList (java.util.ArrayList)6