use of io.nem.symbol.sdk.api.MetadataSearchCriteria in project nem2-sdk-java by nemtech.
the class MetadataRepositoryOkHttpImplTest method search.
@Test
public void search() throws Exception {
Address address = Address.generateRandom(networkType);
MetadataPage dto = getMetadataEntriesDTO();
mockRemoteCall(dto);
List<Metadata> resultList = repository.search(new MetadataSearchCriteria().sourceAddress(address)).toFuture().get().getData();
assertMetadataList(dto, resultList);
}
use of io.nem.symbol.sdk.api.MetadataSearchCriteria in project nem2-sdk-java by nemtech.
the class MosaicMetadataIntegrationTest method addMetadataToMosaic.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addMetadataToMosaic(RepositoryType type) {
MosaicId targetMosaicId = createMosaic(type);
NamespaceId alias = setMosaicAlias(type, targetMosaicId, "mosaicalias" + targetMosaicId.getIdAsHex().toLowerCase());
String message = "This is the message in the mosaic!";
BigInteger key = BigInteger.TEN;
MosaicMetadataTransaction transaction = MosaicMetadataTransactionFactory.create(getNetworkType(), getDeadline(), testAccount.getAddress(), alias, key, StringEncoder.getBytes(message)).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(transaction.toAggregate(testAccount.getPublicAccount()))).maxFee(maxFee).build();
AggregateTransaction announceCorrectly = announceAndValidate(type, testAccount, aggregateTransaction);
Assertions.assertEquals(aggregateTransaction.getType(), announceCorrectly.getType());
Assertions.assertEquals(testAccount.getPublicAccount(), announceCorrectly.getSigner().get());
Assertions.assertEquals(1, announceCorrectly.getInnerTransactions().size());
Assertions.assertEquals(transaction.getType(), announceCorrectly.getInnerTransactions().get(0).getType());
MosaicMetadataTransaction processedTransaction = (MosaicMetadataTransaction) announceCorrectly.getInnerTransactions().get(0);
Assertions.assertEquals(transaction.getTargetMosaicId(), processedTransaction.getTargetMosaicId());
Assertions.assertEquals(transaction.getValueSizeDelta(), processedTransaction.getValueSizeDelta());
Assertions.assertEquals(transaction.getScopedMetadataKey(), processedTransaction.getScopedMetadataKey());
System.out.println(targetMosaicId.getIdAsHex());
System.out.println(key);
sleep(5000);
List<Metadata> metadata = get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().targetId(targetMosaicId).metadataType(MetadataType.MOSAIC))).getData();
assertMetadata(targetMosaicId, transaction, metadata);
assertMetadata(targetMosaicId, transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().targetId(targetMosaicId).metadataType(MetadataType.MOSAIC).scopedMetadataKey(key))).getData());
assertMetadata(targetMosaicId, transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().sourceAddress(testAccount.getAddress()).targetId(targetMosaicId).metadataType(MetadataType.MOSAIC).scopedMetadataKey(key))).getData());
assertMetadata(targetMosaicId, transaction, metadata);
Assertions.assertArrayEquals(StringEncoder.getBytes(message), processedTransaction.getValue());
}
use of io.nem.symbol.sdk.api.MetadataSearchCriteria in project nem2-sdk-java by nemtech.
the class AccountMetadataServiceIntegrationTest method assertMetadata.
private void assertMetadata(BigInteger key, String value, MetadataRepository metadataRepository) {
MetadataSearchCriteria criteria = new MetadataSearchCriteria().scopedMetadataKey(key).sourceAddress(signerAccount.getAddress());
Metadata originalMetadata = get(metadataRepository.search(criteria)).getData().get(0);
Assertions.assertEquals(value, originalMetadata.getValue());
}
use of io.nem.symbol.sdk.api.MetadataSearchCriteria in project nem2-sdk-java by nemtech.
the class MetadataRepositoryVertxImplTest method search.
@Test
public void search() throws Exception {
Address address = Address.generateRandom(networkType);
MetadataPage dto = getMetadataEntriesDTO();
mockRemoteCall(dto);
List<Metadata> resultList = repository.search(new MetadataSearchCriteria().sourceAddress(address)).toFuture().get().getData();
assertMetadataList(dto, resultList);
}
use of io.nem.symbol.sdk.api.MetadataSearchCriteria in project nem2-sdk-java by nemtech.
the class MosaicMetadataServiceIntegrationTest method assertMetadata.
private void assertMetadata(MosaicId targetMosaicId, BigInteger key, String value, MetadataRepository metadataRepository, Account signerAccount, Account targetAccount) {
MetadataSearchCriteria criteria = new MetadataSearchCriteria().targetId(targetMosaicId).targetAddress(targetAccount.getAddress()).scopedMetadataKey(key).sourceAddress(signerAccount.getAddress());
Metadata originalMetadata = get(metadataRepository.search(criteria)).getData().get(0);
Assertions.assertEquals(value, originalMetadata.getValue());
}
Aggregations