RobotsURIBuilder { @Nonnull public RobotsURIBuilder withPort(int port) { checkArgument(port >= 0, "port is negative"); checkArgument(port <= 65535, "port too large"); this.port = Optional.of(port); return this; }  @Nonnull RobotsURIBuilder withScheme(@Nonnull String scheme); @Nonnull RobotsURIBuilder withUserInfo(@Nonnull String userInfo); @Nonnull RobotsURIBuilder withHost(@Nonnull String host); @Nonnull RobotsURIBuilder withPort(int port); @Nonnull RobotsURIBuilder fromUriString(@Nonnull String uriString); @Nonnull RobotsURIBuilder fromUri(@Nonnull URI uri); @Nonnull RobotsURIBuilder fromURL(@Nonnull URL url); @Nonnull URI build();  }
@Test(expected = IllegalArgumentException.class) public void givenNegativePort_whenWithPort_thenThrowsIAE() { builder.withPort(-1); }
@Test public void givenMinPort_whenWithPort_thenNoExceptionThrown() { builder.withPort(0); }
@Test public void givenMaxPort_whenWithPort_thenNoExceptionThrown() { builder.withPort(65535); }
@Test(expected = IllegalArgumentException.class) public void givenOverMaxPort_whenWithPort_thenThrowsIAE() { builder.withPort(65536); }