class MesosClient {

    static int getPort(@NotNull final URI uri) {
        final int uriPort = uri.getPort();
        if (uriPort > 0) {
            return uriPort;
        } else {
            switch (uri.getScheme()) {
                case "http":
                    return 80;
                case "https":
                    return 443;
                default:
                    throw new IllegalArgumentException("URI Scheme must be http or https");
            }
        }
    }

}

class MesosClientTest {

    @Test
    public void testGetPort_returnsSpecifiedPort() throws Exception {

        assertThat(MesosClient.getPort(URI.create("http://glavin:500/path"))).isEqualTo(500);
    }

}