### Question:
Triple extends Pair<R, S> implements Third<T>,
                   MappableThird<T, Triple<R, S, ?>> { @Override public <A> Triple<R, S, A> mapThird(UnaryFunction<T, A> function) { return triple(getFirst(), getSecond(), function.call(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 shouldBeMappableUsingMapperOnThirdPosition() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); Mapper<Boolean, String> mapper = new Mapper<Boolean, String>() { @Override public String map(Boolean input) { return input.toString(); } }; Triple<Integer, String, String> expected = tuple(5, "Five", "true"); Triple<Integer, String, String> actual = triple.mapThird(mapper); assertThat(actual, is(expected)); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionIfNullMapperPassedToMapThird() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); Mapper<Boolean, String> mapper = null; triple.mapThird(mapper); }
@Test public void shouldBeMappableUsingUnaryFunctionOnThirdPosition() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); UnaryFunction<Boolean, String> function = new UnaryFunction<Boolean, String>() { @Override public String call(Boolean input) { return input.toString(); } }; Triple<Integer, String, String> expected = tuple(5, "Five", "true"); Triple<Integer, String, String> actual = triple.mapThird(function); assertThat(actual, is(expected)); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionIfNullUnaryFunctionPassedToMapThird() throws Exception { Triple<Integer, String, Boolean> triple = tuple(5, "Five", true); UnaryFunction<Boolean, String> function = null; triple.mapThird(function); }