### Question:
StreamPair { public PrintStream get(final Type type) { Objects.requireNonNull(type, "Stream type must not be null."); return Type.OUT.equals(type) ? out : err; } StreamPair(final PrintStream out, final PrintStream err); PrintStream get(final Type type);  }### Answer:
@Test public void shouldGetTypeOut() { PrintStream out = mock(PrintStream.class); PrintStream err = mock(PrintStream.class); PrintStream result = new StreamPair(out, err).get(StreamPair.Type.OUT); assertThat(result, equalTo(out)); assertThat(result, not(equalTo(err))); }
@Test public void shouldGetTypeErr() { PrintStream out = mock(PrintStream.class); PrintStream err = mock(PrintStream.class); PrintStream result = new StreamPair(out, err).get(StreamPair.Type.ERR); assertThat(result, equalTo(err)); assertThat(result, not(equalTo(out))); }