You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/10/15 13:45:52 UTC
[camel-kafka-connector] 01/06: core: remove unused methods from
TaskHelper
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git
commit 22a5f56dea6c35fcb112a33c83044085885c06e9
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Thu Oct 15 11:56:48 2020 +0200
core: remove unused methods from TaskHelper
---
.../camel/kafkaconnector/utils/TaskHelper.java | 28 -------
.../camel/kafkaconnector/utils/TaskHelperTest.java | 98 ----------------------
2 files changed, 126 deletions(-)
diff --git a/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java b/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java
index 78e489d..ecdb5a3 100644
--- a/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java
+++ b/core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java
@@ -69,30 +69,6 @@ public final class TaskHelper {
return rcc.asEndpointUri(componentSchema, filteredProps, false);
}
- public static String buildUrl(Map<String, String> props, String componentSchema, String endpointPropertiesPrefix, String pathPropertiesPrefix) {
- final String urlPath = createUrlPathFromProperties(props, pathPropertiesPrefix);
- final String endpointOptions = createEndpointOptionsFromProperties(props, endpointPropertiesPrefix);
-
- return componentSchema + ":" + urlPath + endpointOptions;
- }
-
- public static String createEndpointOptionsFromProperties(Map<String, String> props, String prefix) {
- return props.keySet().stream()
- .filter(k -> k.startsWith(prefix))
- .map(k -> k.replace(prefix, "") + "=" + props.get(k))
- .reduce((o1, o2) -> o1 + "&" + o2)
- .map(result -> result.isEmpty() ? "" : "?" + result)
- .orElse("");
- }
-
- public static String createUrlPathFromProperties(Map<String, String> props, String prefix) {
- return props.keySet().stream()
- .filter(k -> k.startsWith(prefix))
- .map(props::get)
- .reduce((p1, p2) -> p1 + ":" + p2)
- .orElse("");
- }
-
public static Map<String, String> mergeProperties(Map<String, String> defaultProps, Map<String, String> loadedProps) {
if (loadedProps == null && defaultProps == null) {
return Collections.emptyMap();
@@ -110,10 +86,6 @@ public final class TaskHelper {
}
}
- private static String getStringPrefix(String s) {
- return s.lastIndexOf(".") > 0 ? s.substring(0, s.lastIndexOf(".")) : "";
- }
-
private static Boolean stringStartWithOneOfPrefixes(String s, Set<String> prefixes) {
if (s == null || prefixes == null) {
return false;
diff --git a/core/src/test/java/org/apache/camel/kafkaconnector/utils/TaskHelperTest.java b/core/src/test/java/org/apache/camel/kafkaconnector/utils/TaskHelperTest.java
index bc0f537..5da421c 100644
--- a/core/src/test/java/org/apache/camel/kafkaconnector/utils/TaskHelperTest.java
+++ b/core/src/test/java/org/apache/camel/kafkaconnector/utils/TaskHelperTest.java
@@ -117,104 +117,6 @@ public class TaskHelperTest {
}
@Test
- public void testCreateEndpointOptionsFromProperties() {
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("prefix.key1", "value1");
- put("notprefix.key2", "value2");
- }
- };
-
- String result = TaskHelper.createEndpointOptionsFromProperties(props, "prefix.");
-
- assertEquals("?key1=value1", result);
- }
-
- @Test
- public void testCreateEndpointOptionsFromPropertiesConcatenation() {
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("prefix.key1", "value1");
- put("prefix.key2", "value2");
- }
- };
-
- String result = TaskHelper.createEndpointOptionsFromProperties(props, "prefix.");
-
- assertEquals("?key1=value1&key2=value2", result);
- }
-
- @Test
- public void testCreateEndpointOptionsFromPropertiesEmpty() {
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("prefix.key1", "value1");
- put("notprefix.key2", "value2");
- }
- };
-
- String result = TaskHelper.createEndpointOptionsFromProperties(props, "anotherprefix");
-
- assertEquals("", result);
- }
-
- @Test
- public void testCreateUrlPathFromProperties() {
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("prefix.key1", "value1");
- put("notprefix.key2", "value2");
- }
- };
-
- String result = TaskHelper.createUrlPathFromProperties(props, "prefix.");
-
- assertEquals("value1", result);
- }
-
- @Test
- public void testCreateUrlPathFromPropertiesConcatenation() {
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("prefix.key1", "value1");
- put("prefix.key2", "value2");
- }
- };
-
- String result = TaskHelper.createUrlPathFromProperties(props, "prefix.");
-
- assertEquals("value1:value2", result);
- }
-
- @Test
- public void testCreateUrlPathFromPropertiesEmpty() {
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("prefix.key1", "value1");
- put("notprefix.key2", "value2");
- }
- };
-
- String result = TaskHelper.createUrlPathFromProperties(props, "anotherprefix");
-
- assertEquals("", result);
- }
-
- @Test
- public void testBuildUrl() {
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("prefix.key1", "value1");
- put("anotherPrefix.key2", "value2");
- }
- };
-
- String result = TaskHelper.buildUrl(props, "test", "prefix.", "anotherPrefix.");
-
- assertEquals("test:value2?key1=value1", result);
- }
-
- @Test
public void testBuildUrlWithRuntimeCatalog() throws URISyntaxException {
DefaultCamelContext dcc = new DefaultCamelContext();
RuntimeCamelCatalog rcc = dcc.adapt(ExtendedCamelContext.class).getRuntimeCamelCatalog();