use of io.nem.symbol.sdk.model.namespace.NamespaceName in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest method shouldGetNamespaceNames.
@Test
public void shouldGetNamespaceNames() throws Exception {
NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
NamespaceNameDTO dto1 = new NamespaceNameDTO();
dto1.setName("someName1");
dto1.setId("1");
dto1.setParentId("2");
NamespaceNameDTO dto2 = new NamespaceNameDTO();
dto2.setName("someName2");
dto2.setId("3");
mockRemoteCall(Arrays.asList(dto1, dto2));
List<NamespaceName> names = repository.getNamespaceNames(Arrays.asList(namespaceId)).toFuture().get();
Assertions.assertNotNull(names);
Assertions.assertEquals(2, names.size());
Assertions.assertEquals("someName1", names.get(0).getName());
Assertions.assertEquals(BigInteger.valueOf(1L), names.get(0).getNamespaceId().getId());
Assertions.assertEquals(BigInteger.valueOf(2L), names.get(0).getParentId().orElseThrow(() -> new IllegalStateException("No parent id")).getId());
Assertions.assertEquals("someName2", names.get(1).getName());
Assertions.assertEquals(BigInteger.valueOf(3L), names.get(1).getNamespaceId().getId());
Assertions.assertFalse(names.get(1).getParentId().isPresent());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceName in project nem2-sdk-java by nemtech.
the class CurrencyServiceTest method getNetworkCurrencyFromNamespaceId.
@Test
void getNetworkCurrencyFromNamespaceId() throws Exception {
MosaicId mosaicId = new MosaicId(BigInteger.TEN);
Account account = Account.generateNewAccount(NetworkType.MAIN_NET);
BigInteger supply = BigInteger.valueOf(12);
MosaicInfo mosaicInfo = new MosaicInfo("abc", 1, mosaicId, supply, BigInteger.ONE, account.getAddress(), 4L, MosaicFlags.create(true, true, true), 10, BigInteger.TEN);
Mockito.when(mosaicRepository.getMosaic(Mockito.eq(mosaicId))).thenReturn(Observable.just(mosaicInfo));
String name = "some.alias";
NamespaceId namespaceId = NamespaceId.createFromName(name);
MosaicNames mosaicNames = new MosaicNames(mosaicId, Arrays.asList(new NamespaceName(name), new NamespaceName("some.alias2")));
Mockito.when(namespaceRepository.getLinkedMosaicId(Mockito.eq(namespaceId))).thenReturn(Observable.just(mosaicId));
Mockito.when(mosaicRepository.getMosaics(Mockito.eq(Collections.singletonList(mosaicId)))).thenReturn(Observable.just(Collections.singletonList(mosaicInfo)));
Mockito.when(namespaceRepository.getMosaicsNames(Mockito.eq(Collections.singletonList(mosaicId)))).thenReturn(Observable.just(Collections.singletonList(mosaicNames)));
Currency currency = service.getCurrencyFromNamespaceId(namespaceId).toFuture().get();
Assertions.assertEquals(10, currency.getDivisibility());
Assertions.assertEquals(mosaicId, currency.getUnresolvedMosaicId());
Assertions.assertEquals(mosaicId, currency.getMosaicId().get());
Assertions.assertEquals(namespaceId, currency.getNamespaceId().get());
Assertions.assertEquals("some.alias", currency.getNamespaceId().get().getFullName().get());
Assertions.assertTrue(currency.isTransferable());
Assertions.assertTrue(currency.isSupplyMutable());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceName in project nem2-sdk-java by nemtech.
the class MosaicNamesTest method createMosaicNames.
@Test
void createMosaicNames() {
MosaicId mosaicId = new MosaicId(new BigInteger("-3087871471161192663"));
List<NamespaceName> namespaceNames = Arrays.asList(new NamespaceName("xem"), new NamespaceName("anotheralias"));
MosaicNames names = new MosaicNames(mosaicId, namespaceNames);
assertEquals(mosaicId, names.getMosaicId());
assertEquals(namespaceNames, names.getNames());
}
Aggregations