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:56 UTC
[camel-kafka-connector] 05/06: TaskHelperTest: replace double brace
initialization with Camel's helpers
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 176244bff17db1f5d7734c83e1505d7d6c966755
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Thu Oct 15 12:27:27 2020 +0200
TaskHelperTest: replace double brace initialization with Camel's helpers
---
.../camel/kafkaconnector/utils/TaskHelperTest.java | 78 +++++++---------------
1 file changed, 25 insertions(+), 53 deletions(-)
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 14d162a..91087dc 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
@@ -18,7 +18,6 @@ package org.apache.camel.kafkaconnector.utils;
import java.net.URISyntaxException;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -33,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.ext.LoggerWrapper;
+import static org.apache.camel.util.CollectionHelper.mapOf;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -49,18 +49,8 @@ public class TaskHelperTest {
@Test
public void testMergePropertiesDefaultAreAdded() {
- Map<String, String> defaults = new HashMap<String, String>() {
- {
- put("property", "defaultValue");
- }
- };
-
- Map<String, String> loaded = new HashMap<String, String>() {
- {
- put("anotherProperty", "loadedValue");
- }
- };
-
+ Map<String, String> defaults = mapOf("property", "defaultValue");
+ Map<String, String> loaded = mapOf("anotherProperty", "loadedValue");
Map<String, String> result = TaskHelper.mergeProperties(defaults, loaded);
assertTrue(result.containsKey("property"));
@@ -71,18 +61,8 @@ public class TaskHelperTest {
@Test
public void testMergePropertiesLoadedHavePrecedence() {
- Map<String, String> defaults = new HashMap<String, String>() {
- {
- put("property", "defaultValue");
- }
- };
-
- Map<String, String> loaded = new HashMap<String, String>() {
- {
- put("property", "loadedValue");
- }
- };
-
+ Map<String, String> defaults = mapOf("property", "defaultValue");
+ Map<String, String> loaded = mapOf("property", "loadedValue");
Map<String, String> result = TaskHelper.mergeProperties(defaults, loaded);
assertTrue(result.containsKey("property"));
@@ -91,21 +71,17 @@ public class TaskHelperTest {
@Test
public void testMergePropertiesLoadedHavePrecedenceWithPrefixFiltering() {
- Map<String, String> defaults = new HashMap<String, String>() {
- {
- put("property", "defaultValue");
- put("camel.component.x.objectProperty", "#class:my.package.MyClass");
- put("camel.component.x.objectProperty.field", "defaultValue");
- }
- };
-
- Map<String, String> loaded = new HashMap<String, String>() {
- {
- put("camel.component.x.objectProperty", "#class:my.package.MyOtherClass");
- put("camel.component.x.objectProperty.anotherField", "loadedValue");
- put("camel.component.x.normalProperty", "loadedValue");
- }
- };
+ Map<String, String> defaults = mapOf(
+ "property", "defaultValue",
+ "camel.component.x.objectProperty", "#class:my.package.MyClass",
+ "camel.component.x.objectProperty.field", "defaultValue"
+ );
+
+ Map<String, String> loaded = mapOf(
+ "camel.component.x.objectProperty", "#class:my.package.MyOtherClass",
+ "camel.component.x.objectProperty.anotherField", "loadedValue",
+ "camel.component.x.normalProperty", "loadedValue"
+ );
Map<String, String> result = TaskHelper.mergeProperties(defaults, loaded);
@@ -120,24 +96,20 @@ public class TaskHelperTest {
public void testBuildUrlWithRuntimeCatalog() throws URISyntaxException {
DefaultCamelContext dcc = new DefaultCamelContext();
RuntimeCamelCatalog rcc = dcc.adapt(ExtendedCamelContext.class).getRuntimeCamelCatalog();
- Map<String, String> props = new HashMap<String, String>() {
- {
- put("camel.source.path.name", "test");
- put("camel.source.endpoint.synchronous", "true");
- }
- };
+ Map<String, String> props = mapOf(
+ "camel.source.path.name", "test",
+ "camel.source.endpoint.synchronous", "true"
+ );
String result = TaskHelper.buildUrl(rcc, props, "direct", "camel.source.endpoint.", "camel.source.path.");
assertEquals("direct:test?synchronous=true", result);
- props = new HashMap<String, String>() {
- {
- put("camel.source.path.port", "8080");
- put("camel.source.path.keyspace", "test");
- put("camel.source.path.hosts", "localhost");
- }
- };
+ props = mapOf(
+ "camel.source.path.port", "8080",
+ "camel.source.path.keyspace", "test",
+ "camel.source.path.hosts", "localhost"
+ );
result = TaskHelper.buildUrl(rcc, props, "cql", "camel.source.endpoint.", "camel.source.path.");