@Test public void testComputeHttpUri() { assertThat( computeHttpUri("http", mapOf( "baseUrl", "www.google.com" )) ).isEqualTo("www.google.com"); assertThat( computeHttpUri("http", mapOf( "baseUrl", "www.google.com", "path", "/test" )) ).isEqualTo("www.google.com/test"); assertThat( computeHttpUri("http", mapOf( "baseUrl", "www.google.com/", "path", "/test" )) ).isEqualTo("www.google.com/test"); assertThat( computeHttpUri("http", mapOf( "baseUrl", "www.google.com", "path", "/test" )) ).isEqualTo("www.google.com/test"); assertThat( computeHttpUri("http", mapOf( "baseUrl", "www.google.com", "path", "test" )) ).isEqualTo("www.google.com/test"); assertThat( computeHttpUri("http", mapOf( "baseUrl", "http: "path", "/test" )) ).isEqualTo("www.google.com/test"); assertThat( computeHttpUri("http", mapOf( "baseUrl", "http: "path", "/test" )) ).isEqualTo("www.google.com/test"); assertThat( computeHttpUri("http", mapOf( "baseUrl", "http: )) ).isEqualTo("www.google.com"); assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy( () -> computeHttpUri( "http", mapOf( "baseUrl", "https: )) ); }
public static String computeHttpUri(String scheme, Map<String, Object> options) { String baseUrl = (String)options.remove("baseUrl"); if (ObjectHelper.isEmpty(baseUrl)) { throw new IllegalArgumentException("baseUrl si mandatory"); } String uriScheme = StringHelper.before(baseUrl, ": if (ObjectHelper.isNotEmpty(uriScheme) && !ObjectHelper.equal(scheme, uriScheme)) { throw new IllegalArgumentException("Unsupported scheme: " + uriScheme); } if (ObjectHelper.isNotEmpty(uriScheme)) { baseUrl = StringHelper.after(baseUrl, ": } String path = (String)options.remove("path"); if (StringUtils.isNotEmpty(path)) { return StringUtils.removeEnd(baseUrl, "/") + "/" + StringUtils.removeStart(path, "/"); } else { return baseUrl; } }
HttpConnectorFactories { public static String computeHttpUri(String scheme, Map<String, Object> options) { String baseUrl = (String)options.remove("baseUrl"); if (ObjectHelper.isEmpty(baseUrl)) { throw new IllegalArgumentException("baseUrl si mandatory"); } String uriScheme = StringHelper.before(baseUrl, ": if (ObjectHelper.isNotEmpty(uriScheme) && !ObjectHelper.equal(scheme, uriScheme)) { throw new IllegalArgumentException("Unsupported scheme: " + uriScheme); } if (ObjectHelper.isNotEmpty(uriScheme)) { baseUrl = StringHelper.after(baseUrl, ": } String path = (String)options.remove("path"); if (StringUtils.isNotEmpty(path)) { return StringUtils.removeEnd(baseUrl, "/") + "/" + StringUtils.removeStart(path, "/"); } else { return baseUrl; } } }
HttpConnectorFactories { public static String computeHttpUri(String scheme, Map<String, Object> options) { String baseUrl = (String)options.remove("baseUrl"); if (ObjectHelper.isEmpty(baseUrl)) { throw new IllegalArgumentException("baseUrl si mandatory"); } String uriScheme = StringHelper.before(baseUrl, ": if (ObjectHelper.isNotEmpty(uriScheme) && !ObjectHelper.equal(scheme, uriScheme)) { throw new IllegalArgumentException("Unsupported scheme: " + uriScheme); } if (ObjectHelper.isNotEmpty(uriScheme)) { baseUrl = StringHelper.after(baseUrl, ": } String path = (String)options.remove("path"); if (StringUtils.isNotEmpty(path)) { return StringUtils.removeEnd(baseUrl, "/") + "/" + StringUtils.removeStart(path, "/"); } else { return baseUrl; } } private  HttpConnectorFactories(); }
HttpConnectorFactories { public static String computeHttpUri(String scheme, Map<String, Object> options) { String baseUrl = (String)options.remove("baseUrl"); if (ObjectHelper.isEmpty(baseUrl)) { throw new IllegalArgumentException("baseUrl si mandatory"); } String uriScheme = StringHelper.before(baseUrl, ": if (ObjectHelper.isNotEmpty(uriScheme) && !ObjectHelper.equal(scheme, uriScheme)) { throw new IllegalArgumentException("Unsupported scheme: " + uriScheme); } if (ObjectHelper.isNotEmpty(uriScheme)) { baseUrl = StringHelper.after(baseUrl, ": } String path = (String)options.remove("path"); if (StringUtils.isNotEmpty(path)) { return StringUtils.removeEnd(baseUrl, "/") + "/" + StringUtils.removeStart(path, "/"); } else { return baseUrl; } } private  HttpConnectorFactories(); static String computeHttpUri(String scheme, Map<String, Object> options); }
HttpConnectorFactories { public static String computeHttpUri(String scheme, Map<String, Object> options) { String baseUrl = (String)options.remove("baseUrl"); if (ObjectHelper.isEmpty(baseUrl)) { throw new IllegalArgumentException("baseUrl si mandatory"); } String uriScheme = StringHelper.before(baseUrl, ": if (ObjectHelper.isNotEmpty(uriScheme) && !ObjectHelper.equal(scheme, uriScheme)) { throw new IllegalArgumentException("Unsupported scheme: " + uriScheme); } if (ObjectHelper.isNotEmpty(uriScheme)) { baseUrl = StringHelper.after(baseUrl, ": } String path = (String)options.remove("path"); if (StringUtils.isNotEmpty(path)) { return StringUtils.removeEnd(baseUrl, "/") + "/" + StringUtils.removeStart(path, "/"); } else { return baseUrl; } } private  HttpConnectorFactories(); static String computeHttpUri(String scheme, Map<String, Object> options);  }