Search in sources :

Example 26 with Page

use of io.nem.symbol.sdk.api.Page in project nem2-sdk-java by nemtech.

the class MetadataTransactionServiceTest method shouldCreateNamespaceMetadataTransactionFactoryWhenNotFound.

@Test
void shouldCreateNamespaceMetadataTransactionFactoryWhenNotFound() throws Exception {
    BigInteger metadataKey = BigInteger.valueOf(10);
    String newValue = "the new Message";
    MetadataSearchCriteria criteria = new MetadataSearchCriteria().sourceAddress(sourceAddress).scopedMetadataKey(metadataKey).targetId(namespaceId).metadataType(MetadataType.NAMESPACE);
    Mockito.when(metadataRepositoryMock.search(Mockito.eq(criteria))).thenReturn(Observable.just(new Page<>(Collections.emptyList())));
    NamespaceMetadataTransactionFactory result = service.createNamespaceMetadataTransactionFactory(targetAccount.getAddress(), metadataKey, newValue, sourceAddress, namespaceId).toFuture().get();
    Assertions.assertEquals(metadataKey, result.getScopedMetadataKey());
    Assertions.assertArrayEquals(StringEncoder.getBytes(newValue), result.getValue());
    Assertions.assertEquals(StringEncoder.getBytes(newValue).length, result.getValueSizeDelta());
    Assertions.assertEquals(targetAccount.getAddress(), result.getTargetAddress());
    Assertions.assertEquals(namespaceId.getId(), result.getTargetNamespaceId().getId());
    Mockito.verify(metadataRepositoryMock).search(criteria);
}
Also used : MetadataSearchCriteria(io.nem.symbol.sdk.api.MetadataSearchCriteria) BigInteger(java.math.BigInteger) Page(io.nem.symbol.sdk.api.Page) NamespaceMetadataTransactionFactory(io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransactionFactory) Test(org.junit.jupiter.api.Test)

Aggregations

Page (io.nem.symbol.sdk.api.Page)26 BigInteger (java.math.BigInteger)18 Observable (io.reactivex.Observable)17 Collectors (java.util.stream.Collectors)17 List (java.util.List)13 ApiClient (io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient)10 Order (io.nem.symbol.sdk.openapi.vertx.model.Order)10 AsyncResult (io.vertx.core.AsyncResult)10 Handler (io.vertx.core.Handler)10 Consumer (java.util.function.Consumer)10 MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)9 ObjectUtils (org.apache.commons.lang3.ObjectUtils)9 Test (org.junit.jupiter.api.Test)9 MetadataSearchCriteria (io.nem.symbol.sdk.api.MetadataSearchCriteria)8 MapperUtils (io.nem.symbol.core.utils.MapperUtils)7 ReceiptRepository (io.nem.symbol.sdk.api.ReceiptRepository)7 ResolutionStatementSearchCriteria (io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria)7 Address (io.nem.symbol.sdk.model.account.Address)7 AddressResolutionStatement (io.nem.symbol.sdk.model.receipt.AddressResolutionStatement)7 MosaicResolutionStatement (io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement)7