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

    // When
    triple.mapFirst(mapper);

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

    // When
    triple.mapFirst(function);

    // Then a NullPointerException is thrown
  }
Exemple #3
0
  @Test
  public void shouldBeMappableUsingUnaryFunctionOnFirstPosition() throws Exception {
    // Given
    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);

    // When
    Triple<String, String, Boolean> actual = triple.mapFirst(function);

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