### Question:
Single extends AbstractTuple implements First<R>,
                   MappableFirst<R, Single<?>> { @Override public <A> Single<A> mapFirst(UnaryFunction<R, A> mapper) { return single(mapper.call(first)); } Single(R first); static Single<R> single(R first); @Override R getFirst(); @Override Single<A> mapFirst(UnaryFunction<R, A> mapper); @Override Iterable<Object> getValues();  }### Answer:
@Test public void shouldBeMappableWithMapperOnFirstPosition() throws Exception { Single<Integer> single = tuple(5); Mapper<Integer, String> mapper = new Mapper<Integer, String>() { @Override public String map(Integer input) { return String.valueOf(input); } }; Single<String> expected = tuple("5"); Single<String> actual = single.mapFirst(mapper); assertThat(actual, is(expected)); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionIfMapperSuppliedToMapFirstIsNull() throws Exception { Single<Integer> single = tuple(5); Mapper<Integer, String> mapper = null; single.mapFirst(mapper); }
@Test public void shouldBeMappableWithUnaryFunctionOnFirstPosition() throws Exception { Single<Integer> single = tuple(5); UnaryFunction<Integer, String> function = new UnaryFunction<Integer, String>() { @Override public String call(Integer input) { return String.valueOf(input); } }; Single<String> expected = tuple("5"); Single<String> actual = single.mapFirst(function); assertThat(actual, is(expected)); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionIfUnaryPredicateSuppliedToMapFirstIsNull() throws Exception { Single<Integer> single = tuple(5); UnaryFunction<Integer, String> mapper = null; single.mapFirst(mapper); }