Example #1
0
  @Test(expected = NullPointerException.class)
  public void shouldThrowNullPointerExceptionIfNullMapperPassedToMapSecond() throws Exception {
    // Given
    Triple<Integer, String, Boolean> triple = tuple(5, "Five", true);
    Mapper<String, Integer> mapper = null;

    // When
    triple.mapSecond(mapper);

    // Then a NullPointerException is thrown
  }
Example #2
0
  @Test
  public void shouldBeMappableUsingUnaryFunctionOnSecondPosition() throws Exception {
    // Given
    Triple<Integer, String, Boolean> triple = tuple(5, "Five", true);
    UnaryFunction<String, Integer> function =
        new UnaryFunction<String, Integer>() {
          @Override
          public Integer call(String input) {
            return input.length();
          }
        };
    Triple<Integer, Integer, Boolean> expected = tuple(5, 4, true);

    // When
    Triple<Integer, Integer, Boolean> actual = triple.mapSecond(function);

    // Then
    assertThat(actual, is(expected));
  }