From 5f66bb84c8772608c95acfae5f5a6cb2818f65d9 Mon Sep 17 00:00:00 2001 From: Dominik Riemer Date: Tue, 17 Dec 2024 21:09:40 +0100 Subject: [PATCH] Fix test --- .../shared/kafka/KafkaConfigExtractor.java | 26 +++++++++++-------- .../adapters/KafkaAdapterTester.java | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/streampipes-extensions/streampipes-connectors-kafka/src/main/java/org/apache/streampipes/extensions/connectors/kafka/shared/kafka/KafkaConfigExtractor.java b/streampipes-extensions/streampipes-connectors-kafka/src/main/java/org/apache/streampipes/extensions/connectors/kafka/shared/kafka/KafkaConfigExtractor.java index 399f42a8c9..0289fb56ca 100644 --- a/streampipes-extensions/streampipes-connectors-kafka/src/main/java/org/apache/streampipes/extensions/connectors/kafka/shared/kafka/KafkaConfigExtractor.java +++ b/streampipes-extensions/streampipes-connectors-kafka/src/main/java/org/apache/streampipes/extensions/connectors/kafka/shared/kafka/KafkaConfigExtractor.java @@ -129,16 +129,20 @@ public SecurityProtocol getSecurityProtocol(String selectedSecurityConfiguration } public static Map parseAdditionalProperties(String text) { - return Arrays.stream(text.split("\\R")) - .map(String::trim) - .filter(line -> !line.isEmpty() && !line.startsWith("#")) - .filter(line -> line.contains("=")) - .map(line -> line.split("=", 2)) - .collect(Collectors.toMap( - parts -> parts[0].trim(), - parts -> parts[1].trim(), - (existing, replacement) -> replacement, - LinkedHashMap::new - )); + if (text == null || text.isEmpty()) { + return Map.of(); + } else { + return Arrays.stream(text.split("\\R")) + .map(String::trim) + .filter(line -> !line.isEmpty() && !line.startsWith("#")) + .filter(line -> line.contains("=")) + .map(line -> line.split("=", 2)) + .collect(Collectors.toMap( + parts -> parts[0].trim(), + parts -> parts[1].trim(), + (existing, replacement) -> replacement, + LinkedHashMap::new + )); + } } } diff --git a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/KafkaAdapterTester.java b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/KafkaAdapterTester.java index db830f1b7a..803b2b1693 100644 --- a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/KafkaAdapterTester.java +++ b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/KafkaAdapterTester.java @@ -115,7 +115,7 @@ public IAdapterConfiguration prepareAdapter() throws AdapterException { // Set format to Json ((StaticPropertyAlternatives) (desc) .getConfig() - .get(7)) + .get(8)) .getAlternatives() .get(0) .setSelected(true);