Functions1 { @Nonnull public static Func1<Object, String> toStringFunction() { return new Func1<Object, String>() { @Override public String call(Object o) { if (o == null) { return null; } return o.toString(); } }; }  @Nonnull static Func1<? super Boolean, Boolean> isTrue(); @Nonnull static Func1<? super Boolean, Boolean> isFalse(); @Nonnull static Func1<T, Boolean> neg(@Nonnull final Func1<T, Boolean> func1); @Nonnull static Func1<? super Object, Boolean> isNull(); @Nonnull static Func1<? super Object, Boolean> isNotNull(); @Nonnull static Func1<? super CharSequence, Boolean> isNullOrEmpty(); @Nonnull static Func1<? super Object, Boolean> instanceOf(@Nonnull final Class clazz); @Nonnull static Func1<? super Object, ?> toObject(); @Nonnull static Func1<? super Object, Void> toVoid(); @Nonnull static Func1<? super Boolean, ? extends Boolean> neg(); @Nonnull static Func1<Object, Boolean> returnFalse(); @Nonnull static Func1<Object, Boolean> returnTrue(); @Nonnull static Func1<Object, T> returnJust(final T value); @Deprecated @Nonnull static Func1<? super CharSequence, String> charSequenceToString(); @Nonnull static Func1<Object, String> toStringFunction(); @Nonnull static Func1<? super Object, Boolean> isEqualTo(@Nonnull final Object... values);  }
@Test public void testToStringFunction_null() throws Exception { final TestSubscriber<String> toStringFunctionResult = new TestSubscriber<>(); Observable.just(null) .map(Functions1.toStringFunction()) .subscribe(toStringFunctionResult); assert_().that(toStringFunctionResult.getOnNextEvents()).containsExactly((String) null); }
@Test public void testToStringFunction_string() throws Exception { final TestSubscriber<String> toStringFunctionResult = new TestSubscriber<>(); Observable.just("Awesome string!") .map(Functions1.toStringFunction()) .subscribe(toStringFunctionResult); assert_().that(toStringFunctionResult.getOnNextEvents()).containsExactly("Awesome string!"); }
@Test public void testToStringFunction_int() throws Exception { final TestSubscriber<String> toStringFunctionResult = new TestSubscriber<>(); Observable.just(1337) .map(Functions1.toStringFunction()) .subscribe(toStringFunctionResult); assert_().that(toStringFunctionResult.getOnNextEvents()).containsExactly("1337"); }
@Test public void testToStringFunction_hashMap() throws Exception { final TestSubscriber<String> toStringFunctionResult = new TestSubscriber<>(); final LinkedHashMap<String, Integer> hashMap = new LinkedHashMap<>(); hashMap.put("a", 1); hashMap.put("b", 4); hashMap.put("c", 7); Observable.just(hashMap) .map(Functions1.toStringFunction()) .subscribe(toStringFunctionResult); assert_().that(toStringFunctionResult.getOnNextEvents()).containsExactly("{a=1, b=4, c=7}"); }