use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method simulateStatement.
private void simulateStatement(BigInteger height, int primaryId, int secondaryId) {
Map<NamespaceId, Address> addressMap = new HashMap<>();
addressMap.put(addressNamespace1, address1);
addressMap.put(addressNamespace2, address2);
addressMap.put(addressNamespace3, address3);
Map<NamespaceId, MosaicId> mosaicMap = new HashMap<>();
mosaicMap.put(mosaicNamespace1, mosaicId1);
mosaicMap.put(mosaicNamespace2, mosaicId2);
mosaicMap.put(mosaicNamespace3, mosaicId3);
List<AddressResolutionStatement> addressResolutionStatements = addressMap.entrySet().stream().map(e -> new AddressResolutionStatement("abc", height, e.getKey(), Collections.singletonList(ResolutionEntry.forAddress(e.getValue(), new ReceiptSource(primaryId, secondaryId))))).collect(Collectors.toList());
List<MosaicResolutionStatement> mosaicResolutionStatements = mosaicMap.entrySet().stream().map(e -> new MosaicResolutionStatement("abc", height, e.getKey(), Collections.singletonList(ResolutionEntry.forMosaicId(e.getValue(), new ReceiptSource(primaryId, secondaryId))))).collect(Collectors.toList());
Mockito.when(receiptRepositoryMock.searchAddressResolutionStatements(Mockito.eq(new ResolutionStatementSearchCriteria().height(height)))).thenReturn(Observable.just(new Page<>(addressResolutionStatements)));
Mockito.when(receiptRepositoryMock.searchMosaicResolutionStatements(Mockito.eq(new ResolutionStatementSearchCriteria().height(height)))).thenReturn(Observable.just(new Page<>(mosaicResolutionStatements)));
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class CurrencyServiceTest method getNetworkCurrencies.
@Test
void getNetworkCurrencies() throws Exception {
NetworkConfiguration networkConfiguration = Mockito.mock(NetworkConfiguration.class);
ChainProperties chainProperties = Mockito.mock(ChainProperties.class);
String currencyMosaicIdHex = "0x62EF'46FD'6555'AAAA";
MosaicId currencyMosaicId = new MosaicId(FormatUtils.toSimpleHex(currencyMosaicIdHex));
Mockito.when(chainProperties.getCurrencyMosaicId()).thenReturn(currencyMosaicIdHex);
String harvestMosaicIdHex = "0x62EF'46FD'6555'BBBB";
MosaicId harvestMosaicId = new MosaicId(FormatUtils.toSimpleHex(harvestMosaicIdHex));
Mockito.when(chainProperties.getHarvestingMosaicId()).thenReturn(harvestMosaicIdHex);
Mockito.when(networkConfiguration.getChain()).thenReturn(chainProperties);
Mockito.when(networkRepository.getNetworkProperties()).thenReturn(Observable.just(networkConfiguration));
Address account = Address.generateRandom(NetworkType.MIJIN_TEST);
MosaicInfo currencyMosaicInfo = new MosaicInfo("abc", 1, currencyMosaicId, BigInteger.valueOf(100), BigInteger.ONE, account, 4L, MosaicFlags.create(false, true, false), 10, BigInteger.TEN);
MosaicInfo harvestMosaicInfo = new MosaicInfo("abc", 1, harvestMosaicId, BigInteger.valueOf(200), BigInteger.ONE, account, 4L, MosaicFlags.create(true, false, true), 3, BigInteger.TEN);
Mockito.when(mosaicRepository.getMosaics(Mockito.eq(Arrays.asList(currencyMosaicId, harvestMosaicId)))).thenReturn(Observable.just(Arrays.asList(currencyMosaicInfo, harvestMosaicInfo)));
Mockito.when(namespaceRepository.getMosaicsNames(Mockito.eq(Arrays.asList(currencyMosaicId, harvestMosaicId)))).thenReturn(Observable.just(Collections.emptyList()));
NetworkCurrencies networkCurrencies = service.getNetworkCurrencies().toFuture().get();
Assertions.assertEquals(currencyMosaicInfo.toCurrency(), networkCurrencies.getCurrency());
Assertions.assertEquals(harvestMosaicInfo.toCurrency(), networkCurrencies.getHarvest());
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class TransactionStatementSearchCriteriaTest method shouldBeEquals.
@Test
void shouldBeEquals() {
Address recipientAddress = Address.generateRandom(NetworkType.MIJIN_TEST);
Address targetAddress = Address.generateRandom(NetworkType.MIJIN_TEST);
Address senderAddress = Address.generateRandom(NetworkType.MIJIN_TEST);
TransactionStatementSearchCriteria criteria1 = new TransactionStatementSearchCriteria().order(OrderBy.ASC).pageSize(10).pageNumber(5).height(BigInteger.ONE);
criteria1.offset("abc");
criteria1.receiptTypes(Collections.singletonList(ReceiptType.MOSAIC_ALIAS_RESOLUTION));
criteria1.recipientAddress(recipientAddress);
criteria1.targetAddress(targetAddress);
criteria1.senderAddress(senderAddress);
criteria1.artifactId("artifactid");
TransactionStatementSearchCriteria criteria2 = new TransactionStatementSearchCriteria().order(OrderBy.ASC).pageSize(10).pageNumber(5).height(BigInteger.ONE);
criteria2.offset("abc");
criteria2.receiptTypes(Collections.singletonList(ReceiptType.MOSAIC_ALIAS_RESOLUTION));
criteria2.recipientAddress(recipientAddress);
criteria2.targetAddress(targetAddress);
criteria2.senderAddress(senderAddress);
criteria2.artifactId("artifactid");
Assertions.assertEquals(new TransactionStatementSearchCriteria(), new TransactionStatementSearchCriteria());
Assertions.assertEquals(criteria1, criteria2);
Assertions.assertEquals(criteria1, criteria1);
Assertions.assertEquals(criteria1.hashCode(), criteria2.hashCode());
criteria1.setHeight(BigInteger.TEN);
Assertions.assertNotEquals(criteria1, criteria2);
Assertions.assertNotEquals(criteria1.hashCode(), criteria2.hashCode());
Assertions.assertNotEquals("ABC", criteria2);
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class TransactionStatementSearchCriteriaTest method shouldUseBuilderMethods.
@Test
void shouldUseBuilderMethods() {
Address recipientAddress = Address.generateRandom(NetworkType.MIJIN_TEST);
Address targetAddress = Address.generateRandom(NetworkType.MIJIN_TEST);
Address senderAddress = Address.generateRandom(NetworkType.MIJIN_TEST);
TransactionStatementSearchCriteria criteria = new TransactionStatementSearchCriteria().height(BigInteger.ONE);
criteria.fromHeight(BigInteger.valueOf(2));
criteria.toHeight(BigInteger.valueOf(3));
criteria.order(OrderBy.ASC).pageSize(10).pageNumber(5);
criteria.receiptTypes(Collections.singletonList(ReceiptType.MOSAIC_ALIAS_RESOLUTION));
criteria.recipientAddress(recipientAddress);
criteria.targetAddress(targetAddress);
criteria.senderAddress(senderAddress);
criteria.artifactId("artifactid");
criteria.offset("abc");
Assertions.assertEquals(OrderBy.ASC, criteria.getOrder());
Assertions.assertEquals(10, criteria.getPageSize());
Assertions.assertEquals(5, criteria.getPageNumber());
Assertions.assertEquals(BigInteger.ONE, criteria.getHeight());
Assertions.assertEquals(BigInteger.valueOf(2), criteria.getFromHeight());
Assertions.assertEquals(BigInteger.valueOf(3), criteria.getToHeight());
Assertions.assertEquals("abc", criteria.getOffset());
Assertions.assertEquals(Collections.singletonList(ReceiptType.MOSAIC_ALIAS_RESOLUTION), criteria.getReceiptTypes());
Assertions.assertEquals("artifactid", criteria.getArtifactId());
Assertions.assertEquals(recipientAddress, criteria.getRecipientAddress());
Assertions.assertEquals(targetAddress, criteria.getTargetAddress());
Assertions.assertEquals(senderAddress, criteria.getSenderAddress());
}
use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.
the class MapperUtilsTest method toUnresolvedAddressFromAddress.
@Test
void toUnresolvedAddressFromAddress() {
Assertions.assertNull(MapperUtils.toUnresolvedAddress(null));
Address address = Address.generateRandom(networkType);
Assertions.assertEquals(address, MapperUtils.toUnresolvedAddress(address.encoded(networkType)));
}
Aggregations