### Question:
Triple extends Pair<R, S> implements Third<T>,
                   MappableThird<T, Triple<R, S, ?>> { @Override public <A> Triple<A, S, T> mapFirst(UnaryFunction<R, A> function) { return triple(function.call(getFirst()), getSecond(), getThird()); } Triple(R first, S second, T third); static Triple<R, S, T> triple(R first, S second, T third); @Override T getThird(); @Override Triple<A, S, T> mapFirst(UnaryFunction<R, A> function); @Override Triple<R, A, T> mapSecond(UnaryFunction<S, A> function); @Override Triple<R, S, A> mapThird(UnaryFunction<T, A> function); @Override Iterable<Object> getValues();  }### Answer:
@Test public void shouldBeMappableUsingMapperOnFirstPosition() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); Mapper<Integer, String> mapper = new Mapper<Integer, String>() { @Override public String map(Integer input) { return String.valueOf(input); } }; Triple<String, String, Boolean> expected = tuple("5", "Five", true); Triple<String, String, Boolean> actual = triple.mapFirst(mapper); assertThat(actual, is(expected)); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionIfNullMapperPassedToMapFirst() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); Mapper<Integer, String> mapper = null; triple.mapFirst(mapper); }
@Test public void shouldBeMappableUsingUnaryFunctionOnFirstPosition() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); UnaryFunction<Integer, String> function = new UnaryFunction<Integer, String>() { @Override public String call(Integer input) { return String.valueOf(input); } }; Triple<String, String, Boolean> expected = tuple("5", "Five", true); Triple<String, String, Boolean> actual = triple.mapFirst(function); assertThat(actual, is(expected)); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionIfNullUnaryFunctionPassedToMapFirst() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); UnaryFunction<Integer, String> function = null; triple.mapFirst(function); }