use of io.nem.symbol.sdk.model.namespace.NamespaceName in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method getAllMultisigAddressesAndAliasesWhenBasic.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenBasic(RepositoryType type) {
Account testAccount = this.helper().getTestAccount(type).getKey();
Set<NamespaceId> cosignatoryAccount1aliases = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(testAccount.getAddress()))).stream().flatMap(a -> a.getNames().stream().map(NamespaceName::getNamespaceId)).collect(Collectors.toSet());
Listener listener = getRepositoryFactory(type).createListener();
final Set<UnresolvedAddress> unresolvedAddresses = get(listener.getAllMultisigAddressesAndAliases(testAccount.getAddress()));
final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(testAccount.getAddress());
expectedAddresees.addAll(cosignatoryAccount1aliases);
Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
use of io.nem.symbol.sdk.model.namespace.NamespaceName in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImpl method getNamespaceNames.
@Override
public Observable<List<NamespaceName>> getNamespaceNames(List<NamespaceId> namespaceIds) {
NamespaceIds ids = new NamespaceIds().namespaceIds(namespaceIds.stream().map(NamespaceId::getIdAsHex).collect(Collectors.toList()));
Consumer<Handler<AsyncResult<List<NamespaceNameDTO>>>> callback = handler -> client.getNamespacesNames(ids, handler);
return exceptionHandling(call(callback).flatMapIterable(item -> item).map(this::toNamespaceName).toList().toObservable());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceName in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImplTest 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 getNetworkCurrencyFromMosaicIdWhenNamespaceIsPresent.
@Test
void getNetworkCurrencyFromMosaicIdWhenNamespaceIsPresent() 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.getMosaics(Mockito.eq(Arrays.asList(mosaicId)))).thenReturn(Observable.just(Arrays.asList(mosaicInfo)));
String name = "some.alias";
NamespaceId namespaceId = NamespaceId.createFromName(name);
MosaicNames mosaicNames = new MosaicNames(mosaicId, Arrays.asList(new NamespaceName(name), new NamespaceName("some.alias2")));
MosaicNames mosaicNames2 = new MosaicNames(mosaicId, Arrays.asList(new NamespaceName("some.alias2"), new NamespaceName("some.alias3")));
Mockito.when(namespaceRepository.getMosaicsNames(Mockito.eq(Collections.singletonList(mosaicId)))).thenReturn(Observable.just(Arrays.asList(mosaicNames, mosaicNames2)));
Currency currency = service.getCurrency(mosaicId).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 AccountNamesTest method createAccountNames.
@Test
void createAccountNames() {
Address address = Address.generateRandom(NetworkType.MIJIN_TEST);
List<NamespaceName> namespaceNames = Arrays.asList(new NamespaceName("accountalias"), new NamespaceName("anotheralias"));
AccountNames names = new AccountNames(address, namespaceNames);
assertEquals(address, names.getAddress());
assertEquals(namespaceNames, names.getNames());
}
Aggregations