@Test
public void only_oneElement() {

  String result = Stream.of("foo").collect(onlyElement());
  assertThat(result).isEqualTo("foo");
  IllegalArgumentException thrown =
      assertThrows(
          IllegalArgumentException.class, () -> Stream.of(1, 2, 3).collect(onlyElement()));
  assertThat(thrown).hasMessageThat().contains("size: 3");
}