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