HttpMessages { static Optional<Integer> getPort(final URI uri) { final int port = uri.getPort(); return port == -1 ? Optional.empty() : Optional.of(port); } private  HttpMessages();   }
@Test void shouldReturnPort() throws Exception { final URI uri = new URI("http: assertEquals(Optional.of(99999), getPort(uri)); }
@Test void shouldReturnEmptyForAbsentPort() throws Exception { final URI uri = new URI("http: assertEquals(Optional.empty(), getPort(uri)); }