use of io.reactivex.Observable in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryVertxImpl method search.
@Override
public Observable<Page<NamespaceInfo>> search(NamespaceSearchCriteria criteria) {
String ownerAddress = toDto(criteria.getOwnerAddress());
NamespaceRegistrationTypeEnum registrationType = criteria.getRegistrationType() == null ? null : NamespaceRegistrationTypeEnum.fromValue(criteria.getRegistrationType().getValue());
String level0 = criteria.getLevel0();
AliasTypeEnum aliasType = criteria.getAliasType() == null ? null : AliasTypeEnum.fromValue(criteria.getAliasType().getValue());
Integer pageSize = criteria.getPageSize();
Integer pageNumber = criteria.getPageNumber();
String offset = criteria.getOffset();
Order order = toDto(criteria.getOrder());
Consumer<Handler<AsyncResult<NamespacePage>>> callback = handler -> getClient().searchNamespaces(ownerAddress, registrationType, level0, aliasType, pageSize, pageNumber, offset, order, handler);
return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(this::toNamespaceInfo).collect(Collectors.toList()))));
}
use of io.reactivex.Observable in project nem2-sdk-java by nemtech.
the class RestrictionAccountRepositoryVertxImpl method search.
@Override
public Observable<Page<AccountRestrictions>> search(AccountRestrictionSearchCriteria criteria) {
String address = toDto(criteria.getAddress());
Integer pageSize = criteria.getPageSize();
Integer pageNumber = criteria.getPageNumber();
String offset = criteria.getOffset();
Order order = toDto(criteria.getOrder());
Consumer<Handler<AsyncResult<AccountRestrictionsPage>>> handlerConsumer = (h) -> getClient().searchAccountRestrictions(address, pageSize, pageNumber, offset, order, h);
return this.call(handlerConsumer, this::toPage);
}
use of io.reactivex.Observable in project retrofit by square.
the class RxJava2CallAdapterFactoryTest method rawResponseTypeThrows.
@Test
public void rawResponseTypeThrows() {
Type observableType = new TypeToken<Observable<Response>>() {
}.getType();
try {
factory.get(observableType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
}
Type singleType = new TypeToken<Single<Response>>() {
}.getType();
try {
factory.get(singleType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
}
Type maybeType = new TypeToken<Maybe<Response>>() {
}.getType();
try {
factory.get(maybeType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
}
Type flowableType = new TypeToken<Flowable<Response>>() {
}.getType();
try {
factory.get(flowableType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>");
}
}
use of io.reactivex.Observable in project retrofit by square.
the class RxJava2CallAdapterFactoryTest method rawResultTypeThrows.
@Test
public void rawResultTypeThrows() {
Type observableType = new TypeToken<Observable<Result>>() {
}.getType();
try {
factory.get(observableType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
}
Type singleType = new TypeToken<Single<Result>>() {
}.getType();
try {
factory.get(singleType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
}
Type maybeType = new TypeToken<Maybe<Result>>() {
}.getType();
try {
factory.get(maybeType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
}
Type flowableType = new TypeToken<Flowable<Result>>() {
}.getType();
try {
factory.get(flowableType, NO_ANNOTATIONS, retrofit);
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>");
}
}
use of io.reactivex.Observable in project RxJava by ReactiveX.
the class ObservableConcatTest method concatVeryLongObservableOfObservablesTakeHalf.
@Test
public void concatVeryLongObservableOfObservablesTakeHalf() {
final int n = 10000;
Observable<Observable<Integer>> source = Observable.range(0, n).map(new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer v) {
return Observable.just(v);
}
});
Single<List<Integer>> result = Observable.concat(source).take(n / 2).toList();
SingleObserver<List<Integer>> o = TestHelper.mockSingleObserver();
InOrder inOrder = inOrder(o);
result.subscribe(o);
List<Integer> list = new ArrayList<Integer>(n);
for (int i = 0; i < n / 2; i++) {
list.add(i);
}
inOrder.verify(o).onSuccess(list);
verify(o, never()).onError(any(Throwable.class));
}
Aggregations