### Question:
InstanceURIParser { public CLIConnectionConfig parseInstanceURI(String uriString, String namespaceString) { uriString = addScheme(uriString); if (uriString.length() > 0 && !uriString.endsWith("/")) { uriString = String.format("%s/", uriString); } URI uri = URI.create(uriString); NamespaceId namespace = (namespaceString == null || namespaceString.isEmpty()) ? NamespaceId.DEFAULT : new NamespaceId(namespaceString); String apiPath = uri.getPath(); if (apiPath != null && apiPath.startsWith("/")) { apiPath = apiPath.substring(1); } ConnectionConfig config = ConnectionConfig.builder() .setHostname(uri.getHost()) .setPort(uri.getPort() == -1 ? null : uri.getPort()) .setSSLEnabled("https".equals(uri.getScheme())) .setApiPath(apiPath) .build(); return new CLIConnectionConfig(config, namespace, null); } @Inject  InstanceURIParser(CConfiguration cConf); CLIConnectionConfig parse(String uriString); CLIConnectionConfig parseInstanceURI(String uriString, String namespaceString); static final InstanceURIParser DEFAULT; static final String DEFAULT_PROTOCOL; }### Answer:
@Test public void testParseInstanceURI() { NamespaceId someNamespace = new NamespaceId("nsx"); InstanceURIParser parser = new InstanceURIParser(null); Assert.assertEquals(new CLIConnectionConfig(NamespaceId.DEFAULT, "somehost", null, false, ""), parser.parseInstanceURI("somehost", null)); Assert.assertEquals(new CLIConnectionConfig(NamespaceId.DEFAULT, "somehost", null, false, ""), parser.parseInstanceURI("http: Assert.assertEquals(new CLIConnectionConfig(NamespaceId.DEFAULT, "somehost", null, true, ""), parser.parseInstanceURI("https: Assert.assertEquals(new CLIConnectionConfig(NamespaceId.DEFAULT, "somehost", 1234, false, ""), parser.parseInstanceURI("somehost:1234", "")); Assert.assertEquals(new CLIConnectionConfig(NamespaceId.DEFAULT, "somehost", 1234, false, ""), parser.parseInstanceURI("http: Assert.assertEquals(new CLIConnectionConfig(NamespaceId.DEFAULT, "somehost", 1234, true, ""), parser.parseInstanceURI("https: Assert.assertEquals(new CLIConnectionConfig(NamespaceId.DEFAULT, "somehost", null, false, "api/"), parser.parseInstanceURI("somehost/api/", "")); Assert.assertEquals(new CLIConnectionConfig(someNamespace, "somehost", 1234, false, ""), parser.parseInstanceURI("http: Assert.assertEquals(new CLIConnectionConfig(someNamespace, "somehost", null, true, "api/"), parser.parseInstanceURI("https: }