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

    // When
    triple.mapThird(mapper);

    // Then a NullPointerException is thrown
  }
Пример #2
0
  @Test(expected = NullPointerException.class)
  public void shouldThrowNullPointerExceptionIfNullUnaryFunctionPassedToMapThird()
      throws Exception {
    // Given
    Triple<Integer, String, Boolean> triple = tuple(5, "Five", true);
    UnaryFunction<Boolean, String> function = null;

    // When
    triple.mapThird(function);

    // Then a NullPointerException is thrown
  }
Пример #3
0
  @Test
  public void shouldBeMappableUsingUnaryFunctionOnThirdPosition() throws Exception {
    // Given
    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");

    // When
    Triple<Integer, String, String> actual = triple.mapThird(function);

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