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);
}
Aggregations