From eee114d6cf01c8a51af805c7c4a9095fedc7dbb4 Mon Sep 17 00:00:00 2001
From: JoshLabelleSolace <97129775+JoshLabelleSolace@users.noreply.github.com>
Date: Wed, 24 May 2023 16:27:06 -0400
Subject: [PATCH 01/31] Updated pom configs
---
service/application/pom.xml | 2 +-
service/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index f54ab4ac..18e9db58 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -290,7 +290,7 @@
../resources/pmd/pmd-rules.xml
- false
+ true
true
diff --git a/service/pom.xml b/service/pom.xml
index 1a8e4143..687e6f26 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -341,7 +341,7 @@
resources/pmd/pmd-rules.xml
- false
+ true
true
From 07d6da4e2e5b0a4abdd612e0757a34e3f9a46c4f Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 12:19:04 -0400
Subject: [PATCH 02/31] fix failure violations
---
.../com/solace/maas/ep/common/messages/HeartbeatMessage.java | 5 +++++
.../solace/maas/ep/common/messages/ScanCommandMessage.java | 5 +++++
.../maas/ep/common/messages/ScanDataImportMessage.java | 5 +++++
.../com/solace/maas/ep/common/messages/ScanDataMessage.java | 5 +++++
.../maas/ep/common/messages/ScanDataStatusMessage.java | 5 +++++
.../com/solace/maas/ep/common/messages/ScanLogMessage.java | 5 +++++
.../solace/maas/ep/common/messages/ScanStatusMessage.java | 5 +++++
.../agent/plugin/common/messages/VmrProcessorMessage.java | 5 +++++
.../ep/event/management/agent/plugin/mop/MOPMessage.java | 4 +---
.../delegate/base/MessagingServiceRouteDelegateImpl.java | 2 +-
10 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java
index 7232a14c..203e29e2 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java
@@ -26,4 +26,9 @@ public HeartbeatMessage(String runtimeAgentId, String timestamp) {
this.runtimeAgentId = runtimeAgentId;
this.timestamp = timestamp;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java
index 9e1cd05c..7c65cc31 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java
@@ -36,4 +36,9 @@ public ScanCommandMessage(String messagingServiceId,
this.scanTypes = scanTypes;
this.destinations = destinations;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java
index 9cbcf1d7..9d4c3518 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java
@@ -39,4 +39,9 @@ public ScanDataImportMessage(String orgId, String scanId, String messagingServic
this.scanTypes = scanTypes;
this.runtimeAgentId = runtimeAgentId;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java
index ed599579..35531156 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java
@@ -31,4 +31,9 @@ public ScanDataMessage(String orgId, String scanId, String scanType, String data
this.data = data;
this.timestamp = timestamp;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java
index e49cfe18..ba833e7c 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java
@@ -35,4 +35,9 @@ public ScanDataStatusMessage(String orgId, String scanId, String status, String
this.description = description;
this.scanType = scanType;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java
index 30517840..34342bce 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java
@@ -31,4 +31,9 @@ public ScanLogMessage(String orgId, String scanId, String level, String log, Lon
this.log = log;
this.timestamp = timestamp;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java
index 1633ef48..2034425a 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java
@@ -37,4 +37,9 @@ public ScanStatusMessage(String orgId, String scanId, String status, String desc
this.description = description;
this.scanTypes = scanTypes;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/common/messages/VmrProcessorMessage.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/common/messages/VmrProcessorMessage.java
index 5589dd94..01a7eb17 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/common/messages/VmrProcessorMessage.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/common/messages/VmrProcessorMessage.java
@@ -19,4 +19,9 @@ public VmrProcessorMessage(String payload) {
.withUhFlag(MOPUHFlag.ignore);
this.payload = payload;
}
+
+ @Override
+ public String toLog() {
+ return null;
+ }
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java
index e0a5a079..fe5a3bd7 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java
@@ -169,8 +169,6 @@ public Boolean getRepeat() {
return repeat == null ? FALSE : repeat;
}
- public String toLog() {
- return null;
- }
+ public abstract String toLog();
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/base/MessagingServiceRouteDelegateImpl.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/base/MessagingServiceRouteDelegateImpl.java
index b4c75b3a..fa60f237 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/base/MessagingServiceRouteDelegateImpl.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/base/MessagingServiceRouteDelegateImpl.java
@@ -25,7 +25,7 @@ public RouteBundle createRouteBundle(List destinations, List
Date: Tue, 30 May 2023 12:39:52 -0400
Subject: [PATCH 03/31] address warning violations
---
.../management/agent/config/VMRConfiguration.java | 3 ++-
.../agent/plugin/config/VMRProperties.java | 7 ++++---
.../plugin/messagingService/RtoMessageBuilder.java | 10 +++++-----
.../agent/plugin/mop/EnumDeserializer.java | 1 +
.../management/agent/plugin/mop/MOPConstants.java | 12 ++++++------
.../agent/plugin/publisher/SolacePublisher.java | 2 +-
.../plugin/route/RouteBundleHierarchyStore.java | 2 +-
.../handler/base/AsyncDataPublisherRouteBuilder.java | 6 ++++++
.../route/handler/base/AsyncManagerRouteBuilder.java | 1 +
9 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java
index d6007029..35127234 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java
@@ -11,6 +11,7 @@
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
@Slf4j
@@ -28,7 +29,7 @@ public Properties vmrConfig(VMRProperties vmrProperties) {
@Bean
@ConditionalOnBean(VMRProperties.class)
@ConditionalOnProperty(name = "event-portal.gateway.messaging.rto-session", havingValue = "true")
- public ArrayList sessionConfig(VMRProperties sessionProperties) {
+ public List sessionConfig(VMRProperties sessionProperties) {
return sessionProperties.getRTOSessionProperties();
}
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/config/VMRProperties.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/config/VMRProperties.java
index 1c02cc18..a775ffa5 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/config/VMRProperties.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/config/VMRProperties.java
@@ -14,6 +14,7 @@
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Properties;
@@ -86,7 +87,7 @@ public void parseVmrProperties() {
username = messagingServiceUsersProperties.getUsername();
password = messagingServiceUsersProperties.getPassword();
clientName = messagingServiceUsersProperties.getClientName();
- } catch (NullPointerException | NoSuchElementException e) {
+ } catch (NoSuchElementException e) {
log.error("An error occurred while connecting to EP gateway: {}", e.getMessage());
}
}
@@ -109,10 +110,10 @@ public Properties getVmrProperties() {
return properties;
}
- public ArrayList getRTOSessionProperties() {
+ public List getRTOSessionProperties() {
parseVmrProperties();
- ArrayList sessionProperties = new ArrayList<>();
+ List sessionProperties = new ArrayList<>();
sessionProperties.add(SessionHandle.PROPERTIES.HOST);
sessionProperties.add(url);
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/messagingService/RtoMessageBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/messagingService/RtoMessageBuilder.java
index 2c030688..80d36591 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/messagingService/RtoMessageBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/messagingService/RtoMessageBuilder.java
@@ -18,13 +18,13 @@
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import java.util.ArrayList;
+import java.util.List;
@ProviderType
@ConditionalOnBean(VMRProperties.class)
@ConditionalOnProperty(name = "event-portal.gateway.messaging.rto-session", havingValue = "true")
public interface RtoMessageBuilder {
- RtoMessageBuilder fromProperties(ArrayList sessionConfiguration);
+ RtoMessageBuilder fromProperties(List sessionConfiguration);
RtoMessageBuilder createContext();
@@ -43,7 +43,7 @@ public interface RtoMessageBuilder {
class RtoMessageBuilderImpl implements RtoMessageBuilder {
private final MessageCallback messageCallback;
private final SessionEventCallback sessionEventCallback;
- private ArrayList sessionConfig;
+ private List sessionConfig;
private ContextHandle contextHandle;
private SessionHandle sessionHandle;
private MessageHandle messageHandle;
@@ -53,7 +53,7 @@ public RtoMessageBuilderImpl(MessageCallback messageCallback, SessionEventCallba
this.sessionEventCallback = sessionEventCallback;
}
- public RtoMessageBuilder fromProperties(ArrayList sessionConfiguration) {
+ public RtoMessageBuilder fromProperties(List sessionConfiguration) {
this.sessionConfig = sessionConfiguration;
return this;
}
@@ -129,7 +129,7 @@ public RtoMessageBuilder destroy() {
// destroy the context
destroyHandle(contextHandle, "contextHandle");
} catch (Throwable t) {
- System.err.println("Unable to call destroy on messageCallback " + t.getCause());
+ log.error("Unable to call destroy on messageCallback " + t.getCause());
}
return this;
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/EnumDeserializer.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/EnumDeserializer.java
index 1c7d59d3..a334cfcb 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/EnumDeserializer.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/EnumDeserializer.java
@@ -17,6 +17,7 @@ public final class EnumDeserializer extends JsonDeserializer
Class clazz;
public EnumDeserializer(Class clazz) {
+ super();
this.clazz = clazz;
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPConstants.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPConstants.java
index e0791f4a..3773c073 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPConstants.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPConstants.java
@@ -1,11 +1,11 @@
package com.solace.maas.ep.event.management.agent.plugin.mop;
-public interface MOPConstants {
+public class MOPConstants {
// message encoding, meta
- String MOP_MSG_META_CONTENT_TYPE = "mop.meta.contenttype";
- String MOP_MSG_META_DECODER = "mop.meta.decoder";
- String MOP_VER = "mop.ver";
- String MOP_PROTOCOL = "mop.protocol";
- String MOP_MSG_TYPE = "mop.msgtype";
+ public static final String MOP_MSG_META_CONTENT_TYPE = "mop.meta.contenttype";
+ public static final String MOP_MSG_META_DECODER = "mop.meta.decoder";
+ public static final String MOP_VER = "mop.ver";
+ public static final String MOP_PROTOCOL = "mop.protocol";
+ public static final String MOP_MSG_TYPE = "mop.msgtype";
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java
index e62d0ced..ae94c129 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java
@@ -25,7 +25,7 @@ public class SolacePublisher {
private static final ObjectMapper mapper = new ObjectMapper();
private final OutboundMessageBuilder outboundMessageBuilder;
- private DirectMessagePublisher directMessagePublisher;
+ private final DirectMessagePublisher directMessagePublisher;
public SolacePublisher(OutboundMessageBuilder outboundMessageBuilder,
DirectMessagePublisher directMessagePublisher) {
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java
index 33cc03e9..e9f96f3e 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java
@@ -8,7 +8,7 @@
@Data
public class RouteBundleHierarchyStore {
- private static int storeKey = 0;
+ private static int storeKey;
private Map store;
public RouteBundleHierarchyStore() {
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index 81963822..c43a0537 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -15,6 +15,7 @@
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -89,5 +90,10 @@ public void configure() {
if(Objects.nonNull(routeManager)) {
routeManager.setupRoute(routeId);
}
+ try {
+ camel.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncManagerRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncManagerRouteBuilder.java
index bbdb152e..676b8ab3 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncManagerRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncManagerRouteBuilder.java
@@ -12,6 +12,7 @@ public class AsyncManagerRouteBuilder extends RouteBuilder {
private final AsyncManagerProcessor asyncManagerProcessor;
public AsyncManagerRouteBuilder(AsyncManagerProcessor asyncManagerProcessor) {
+ super();
this.asyncManagerProcessor = asyncManagerProcessor;
}
From b19ec447bf02b892c6ba8949d6da191b6cca52b3 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 13:06:03 -0400
Subject: [PATCH 04/31] address warning violations
---
.../handler/base/AsyncDataPublisherRouteBuilder.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index c43a0537..e6ba1aa5 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -6,6 +6,7 @@
import com.solace.maas.ep.event.management.agent.plugin.processor.EmptyScanEntityProcessor;
import com.solace.maas.ep.event.management.agent.plugin.processor.logging.MDCProcessor;
import com.solace.maas.ep.event.management.agent.plugin.route.manager.RouteManager;
+import lombok.SneakyThrows;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams;
@@ -40,6 +41,7 @@ public AsyncDataPublisherRouteBuilder(Processor processor, AsyncRoutePublisherIm
this.asyncRoutePublisher = asyncRoutePublisher;
}
+ @SneakyThrows
@Override
public void configure() {
interceptFrom()
@@ -90,10 +92,7 @@ public void configure() {
if(Objects.nonNull(routeManager)) {
routeManager.setupRoute(routeId);
}
- try {
- camel.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+
+ camel.close();
}
}
From 93b2db3c16bc8930746a33805b9faf9a0756e2ba Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 13:08:09 -0400
Subject: [PATCH 05/31] checkstyle
---
.../route/handler/base/AsyncDataPublisherRouteBuilder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index e6ba1aa5..3d174600 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -89,7 +89,7 @@ public void configure() {
.publishOn(Schedulers.boundedElastic())
.subscribe(asyncRoutePublisher::start);
- if(Objects.nonNull(routeManager)) {
+ if (Objects.nonNull(routeManager)) {
routeManager.setupRoute(routeId);
}
From 0ee38b2a067ad4a8a53feea2a324a57aa4d01156 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 13:09:51 -0400
Subject: [PATCH 06/31] checkstyle
---
.../route/handler/base/AsyncDataPublisherRouteBuilder.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index 3d174600..f527a0ea 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -16,7 +16,6 @@
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
From acc35c12f46ec906f38ff6d887727591227c4719 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 13:17:32 -0400
Subject: [PATCH 07/31] close CamelReactiveStreamsService after use
---
.../handler/base/AsyncDataPublisherRouteBuilder.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index f527a0ea..014cb8aa 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -6,7 +6,6 @@
import com.solace.maas.ep.event.management.agent.plugin.processor.EmptyScanEntityProcessor;
import com.solace.maas.ep.event.management.agent.plugin.processor.logging.MDCProcessor;
import com.solace.maas.ep.event.management.agent.plugin.route.manager.RouteManager;
-import lombok.SneakyThrows;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams;
@@ -16,6 +15,7 @@
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -40,7 +40,6 @@ public AsyncDataPublisherRouteBuilder(Processor processor, AsyncRoutePublisherIm
this.asyncRoutePublisher = asyncRoutePublisher;
}
- @SneakyThrows
@Override
public void configure() {
interceptFrom()
@@ -92,6 +91,10 @@ public void configure() {
routeManager.setupRoute(routeId);
}
- camel.close();
+ try {
+ camel.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
}
From dab94f4d952cf368553b5e48013a03c9162f3cdf Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 13:28:42 -0400
Subject: [PATCH 08/31] close CamelReactiveStreamsService after use
---
.../route/handler/base/AsyncDataPublisherRouteBuilder.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index 014cb8aa..ab137a36 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -15,7 +15,6 @@
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -91,10 +90,6 @@ public void configure() {
routeManager.setupRoute(routeId);
}
- try {
- camel.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ camel.stop();
}
}
From 68a337e96d7d39b82d279a468a354bb0a4ebc411 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 14:18:13 -0400
Subject: [PATCH 09/31] close CamelReactiveStreamsService after use
---
.../agent/config/VMRConfiguration.java | 1 -
.../base/AsyncDataPublisherRouteBuilder.java | 80 ++++++++++---------
2 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java
index 35127234..297197d3 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/VMRConfiguration.java
@@ -10,7 +10,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index ab137a36..1865b774 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -15,6 +15,7 @@
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -45,51 +46,52 @@ public void configure() {
.setHeader(RouteConstants.SCAN_TYPE, constant(routeType))
.process(mdcProcessor);
- CamelReactiveStreamsService camel = CamelReactiveStreams.get(getContext());
+ try (CamelReactiveStreamsService camel = CamelReactiveStreams.get(getContext())) {
+ from("seda:" + routeId + "?blockWhenFull=true&size=1000000")
+ .routeId(routeId)
+ .log("EXECUTION TIMER: ${header" + SchedulerConstants.SCHEDULER_TERMINATION_TIMER + "}")
+ .choice()
+ .when(simple("${header." + SchedulerConstants.SCHEDULER_TERMINATION_TIMER + "} == true"))
+ .setBody(exchange -> {
+ String scanId = exchange.getIn().getHeader(RouteConstants.SCAN_ID, String.class);
+ String scanType = exchange.getIn().getHeader(RouteConstants.SCAN_TYPE, String.class);
- from("seda:" + routeId + "?blockWhenFull=true&size=1000000")
- .routeId(routeId)
- .log("EXECUTION TIMER: ${header" + SchedulerConstants.SCHEDULER_TERMINATION_TIMER + "}")
- .choice()
- .when(simple("${header." + SchedulerConstants.SCHEDULER_TERMINATION_TIMER + "} == true"))
- .setBody(exchange -> {
- String scanId = exchange.getIn().getHeader(RouteConstants.SCAN_ID, String.class);
- String scanType = exchange.getIn().getHeader(RouteConstants.SCAN_TYPE, String.class);
+ Map signal = new HashMap<>();
+ signal.put(RouteConstants.SCAN_ID, scanId);
+ signal.put(RouteConstants.SCAN_TYPE, scanType);
- Map signal = new HashMap<>();
- signal.put(RouteConstants.SCAN_ID, scanId);
- signal.put(RouteConstants.SCAN_TYPE, scanType);
+ return signal;
+ })
+ .to("seda://jobScheduler")
+ .end()
+ .to("reactive-streams:asyncProcessing_" + routeId);
- return signal;
- })
- .to("seda://jobScheduler")
- .end()
- .to("reactive-streams:asyncProcessing_" + routeId);
+ from("seda:asyncEvent_" + routeId + "?blockWhenFull=true&size=1000000")
+ .setHeader(RouteConstants.SCAN_TYPE, constant(routeType))
+ .setHeader("RECIPIENTS", method(this, "getRecipients(${header."
+ + RouteConstants.SCAN_ID + "})"))
+ .setHeader("DESTINATIONS", method(this, "getDestinations(${header."
+ + RouteConstants.SCAN_ID + "})"))
+ .process(processor)
+ .recipientList().header("RECIPIENTS").delimiter(";")
+ .shareUnitOfWork()
+ .split(body()).streaming().shareUnitOfWork()
+ .marshal().json(JsonLibrary.Jackson)
+ .recipientList().header("DESTINATIONS").delimiter(";")
+ .shareUnitOfWork();
- from("seda:asyncEvent_" + routeId + "?blockWhenFull=true&size=1000000")
- .setHeader(RouteConstants.SCAN_TYPE, constant(routeType))
- .setHeader("RECIPIENTS", method(this, "getRecipients(${header."
- + RouteConstants.SCAN_ID + "})"))
- .setHeader("DESTINATIONS", method(this, "getDestinations(${header."
- + RouteConstants.SCAN_ID + "})"))
- .process(processor)
- .recipientList().header("RECIPIENTS").delimiter(";")
- .shareUnitOfWork()
- .split(body()).streaming().shareUnitOfWork()
- .marshal().json(JsonLibrary.Jackson)
- .recipientList().header("DESTINATIONS").delimiter(";")
- .shareUnitOfWork();
-
- Publisher exchanges = camel.fromStream("asyncProcessing_" + routeId);
+ Publisher exchanges = camel.fromStream("asyncProcessing_" + routeId);
- Flux.from(exchanges)
- .publishOn(Schedulers.boundedElastic())
- .subscribe(asyncRoutePublisher::start);
+ camel.stop();
+ Flux.from(exchanges)
+ .publishOn(Schedulers.boundedElastic())
+ .subscribe(asyncRoutePublisher::start);
- if (Objects.nonNull(routeManager)) {
- routeManager.setupRoute(routeId);
+ if (Objects.nonNull(routeManager)) {
+ routeManager.setupRoute(routeId);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
-
- camel.stop();
}
}
From 45d22eb9756bdac33900d71e70b34ea280aede38 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 14:26:48 -0400
Subject: [PATCH 10/31] resolve PMD violations on in Application
---
.../agent/config/SolaceConfiguration.java | 6 +++---
.../EmptyScanEntityProcessorImpl.java | 1 +
.../processor/RouteCompleteProcessorImpl.java | 1 +
.../agent/publisher/HeartbeatGenerator.java | 4 ++--
.../ep/ScanStatusPersistenceRouteBuilder.java | 1 +
.../route/ep/exceptions/ClientException.java | 1 +
.../agent/route/scan/ScanRouteBuilder.java | 1 +
.../rest/DataImportControllerImpl.java | 11 +++++------
.../agent/service/ImportService.java | 18 +++++++++++-------
.../MessageCallbackImpl.java | 4 ++--
.../SessionCallbackImpl.java | 2 +-
.../subscriber/ScanCommandMessageHandler.java | 4 +---
.../agent/subscriber/SolaceMessageHandler.java | 2 +-
.../management/agent/util/IDGenerator.java | 2 +-
.../agent/logging/StreamingAppenderTests.java | 2 +-
.../ScanDataPublisherDelegateImplTests.java | 2 +-
.../agent/subscriber/MessageReceiverTests.java | 6 +++---
17 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/SolaceConfiguration.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/SolaceConfiguration.java
index 7df96ea4..cecec899 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/SolaceConfiguration.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/config/SolaceConfiguration.java
@@ -21,7 +21,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
-import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
@Slf4j
@@ -31,12 +31,12 @@
public class SolaceConfiguration {
private static final String TOPIC_PREFIX_FORMAT = "sc/ep/runtime/%s/%s/";
private final Properties vmrConfiguration;
- private final ArrayList sessionConfiguration;
+ private final List sessionConfiguration;
private final EventPortalProperties eventPortalProperties;
private String topicPrefix;
@Autowired
- public SolaceConfiguration(Properties vmrConfig, ArrayList sessionConfig,
+ public SolaceConfiguration(Properties vmrConfig, List sessionConfig,
EventPortalProperties eventPortalProperties) {
this.vmrConfiguration = vmrConfig;
this.sessionConfiguration = sessionConfig;
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java
index 72516e21..c86c5765 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java
@@ -21,6 +21,7 @@ public class EmptyScanEntityProcessorImpl extends EmptyScanEntityProcessor {
private final ScanRecipientHierarchyRepository scanRecipientHierarchyRepository;
public EmptyScanEntityProcessorImpl(ScanRecipientHierarchyRepository scanRecipientHierarchyRepository) {
+ super();
this.scanRecipientHierarchyRepository = scanRecipientHierarchyRepository;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java
index 50db426f..d3f63335 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java
@@ -16,6 +16,7 @@ public class RouteCompleteProcessorImpl extends RouteCompleteProcessor {
private final ScanStatusService scanStatusService;
public RouteCompleteProcessorImpl(ScanStatusService scanStatusService) {
+ super();
this.scanStatusService = scanStatusService;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java
index 3b969be7..3f4026b8 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java
@@ -17,8 +17,8 @@
public class HeartbeatGenerator {
private final SolacePublisher solacePublisher;
- private String runtimeAgentId;
- private String topic;
+ private final String runtimeAgentId;
+ private final String topic;
public HeartbeatGenerator(SolaceConfiguration solaceConfiguration,
EventPortalProperties eventPortalProperties,
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java
index 4d8fae21..fe488a01 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java
@@ -8,6 +8,7 @@ public class ScanStatusPersistenceRouteBuilder extends AbstractRouteBuilder {
private final RouteCompleteProcessorImpl routeCompleteProcessor;
public ScanStatusPersistenceRouteBuilder(RouteCompleteProcessorImpl routeCompleteProcessor) {
+ super();
this.routeCompleteProcessor = routeCompleteProcessor;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
index 446a1d63..2d778fd7 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
@@ -11,6 +11,7 @@ public class ClientException extends RuntimeException {
private Map> exceptionStore;
ClientException(final String message, final Map> validationDetails) {
+ super();
this.message = message;
this.exceptionStore = validationDetails;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java
index 414f730c..0f011d1e 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java
@@ -9,6 +9,7 @@ public class ScanRouteBuilder extends RouteBuilder {
private final StartScanProcessor startScanProcessor;
public ScanRouteBuilder(StartScanProcessor startScanProcessor) {
+ super();
this.startScanProcessor = startScanProcessor;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
index a736ca8f..d0f10946 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
@@ -60,14 +60,13 @@ public ResponseEntity read(@RequestParam("file") MultipartFile file) {
@Override
@GetMapping(value = "/export/{scanId}/zip")
public ResponseEntity zip(@PathVariable(value = "scanId") String scanId) {
- try {
- ZipRequestBO zipRequestBO = ZipRequestBO.builder()
- .scanId(scanId)
- .build();
+ ZipRequestBO zipRequestBO = ZipRequestBO.builder()
+ .scanId(scanId)
+ .build();
- log.info("Received zip request for scan: {}", scanId);
+ log.info("Received zip request for scan: {}", scanId);
- InputStream zipInputStream = importService.zip(zipRequestBO);
+ try (InputStream zipInputStream = importService.zip(zipRequestBO)) {
InputStreamResource inputStreamResource = new InputStreamResource(zipInputStream);
HttpHeaders httpHeaders = new HttpHeaders();
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
index bf757d3a..a9be3d82 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
@@ -50,15 +50,19 @@ public ImportService(ProducerTemplate producerTemplate, DataCollectionFileServic
this.eventPortalProperties = eventPortalProperties;
}
- public void importData(ImportRequestBO importRequestBO) throws IOException {
+ public void importData(ImportRequestBO importRequestBO) {
boolean isEMAStandalone = eventPortalProperties.getGateway().getMessaging().isStandalone();
- InputStream importStream = importRequestBO.getDataFile().getInputStream();
- String importId = UUID.randomUUID().toString();
+ try (InputStream importStream = importRequestBO.getDataFile().getInputStream()) {
- if (isEMAStandalone) {
- throw new FileUploadException("Scan data could not be imported in standalone mode.");
- } else {
- initiateImport(importStream, importId);
+ String importId = UUID.randomUUID().toString();
+
+ if (isEMAStandalone) {
+ throw new FileUploadException("Scan data could not be imported in standalone mode.");
+ } else {
+ initiateImport(importStream, importId);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/MessageCallbackImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/MessageCallbackImpl.java
index 56879c80..53304cea 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/MessageCallbackImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/MessageCallbackImpl.java
@@ -20,8 +20,8 @@
public class MessageCallbackImpl implements MessageCallback {
private final boolean logCallbacks;
private String callBackId;
- private boolean keepRxMessage = false;
- private int messageCount = 0;
+ private boolean keepRxMessage;
+ private int messageCount;
private List _rxMessages = new LinkedList<>();
public MessageCallbackImpl(String id, boolean logCalls) {
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/SessionCallbackImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/SessionCallbackImpl.java
index 46331ada..64e6073b 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/SessionCallbackImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/rtoMessagingServiceCallbacks/SessionCallbackImpl.java
@@ -13,7 +13,7 @@ public class SessionCallbackImpl implements SessionEventCallback {
private final boolean logCallbacks;
String callBackId;
- private int eventCount = 0;
+ private int eventCount;
public SessionCallbackImpl(String id, boolean logCalls) {
callBackId = id;
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
index fa03b666..6841cbc8 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
@@ -23,14 +23,12 @@ public class ScanCommandMessageHandler extends SolaceMessageHandler", solaceSubscriber);
this.scanManager = scanManager;
- this.scanRequestMapper = scanRequestMapper;
}
@Override
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java
index 7093c5fb..71b560b6 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java
@@ -23,7 +23,7 @@
@Slf4j
public abstract class SolaceMessageHandler implements MessageReceiver.MessageHandler {
- private String topicString;
+ private final String topicString;
private static ObjectMapper objectMapper = new ObjectMapper();
private static final SimpleModule module = new SimpleModule();
private final Map cachedJSONDecoders = new HashMap();
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java
index 9dd5ba55..70f7c70a 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java
@@ -63,7 +63,7 @@ public String generateRandomUniqueId() {
public void init() {
byte[] instanceSeed = "1".getBytes(StandardCharsets.UTF_8);
if (idGeneratorProperties.getOriginId() != null) {
- String instanceSeedString = idGeneratorProperties.getOriginId() + (System.nanoTime() & 65535);
+ String instanceSeedString = idGeneratorProperties.getOriginId() + (System.nanoTime() & 655_35);
instanceSeed = instanceSeedString.getBytes(StandardCharsets.UTF_8);
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java
index a39d4728..62501652 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java
@@ -42,7 +42,7 @@ public void testStreamingAppender() {
ILoggingEvent event = new LoggingEvent(null, logger, Level.DEBUG,
"test message", new Throwable("throwable message"), null);
- RouteEntity route = RouteEntity.builder()
+ RouteEntity.builder()
.id("seda:scanLogsPublisher")
.active(true)
.build();
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java
index b4f01399..c0bf824e 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java
@@ -20,7 +20,7 @@ public class ScanDataPublisherDelegateImplTests {
@InjectMocks
private ScanDataPublisherDelegateImpl scanDataPublisherDelegate;
- private List destinations = List.of(
+ private final List destinations = List.of(
RouteBundle.builder()
.destinations(List.of())
.recipients(List.of())
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
index 9dda35f2..bac66b04 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
@@ -85,7 +85,7 @@ public void scanReceiver() {
when(inboundMessage.getDestinationName()).thenReturn("anyTopic");
ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(solaceConfiguration,
- solaceSubscriber, scanManager, scanRequestMapper);
+ solaceSubscriber, scanManager);
String topic = scanCommandMessageHandler.getTopicString();
log.info("topic: {}", topic);
@@ -102,7 +102,7 @@ public void testBadClass() {
Exception e = assertThrows(RuntimeException.class, () -> {
when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn("badClass");
ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(solaceConfiguration,
- solaceSubscriber, scanManager, scanRequestMapper);
+ solaceSubscriber, scanManager);
scanCommandMessageHandler.onMessage(inboundMessage);
});
}
@@ -111,7 +111,7 @@ public void testBadClass() {
@SneakyThrows
public void testScanCommandMessage() {
ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(solaceConfiguration,
- solaceSubscriber, scanManager, scanRequestMapper);
+ solaceSubscriber, scanManager);
ScanCommandMessage scanCommandMessage =
new ScanCommandMessage("messagingServiceId",
From b5e81b8620d08e35947f769131969d516e3d0a3b Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 15:16:06 -0400
Subject: [PATCH 11/31] resolve PMD violations on in Application
---
...ataImportParseMetaInfFileRouteBuilder.java | 1 +
...ScanDataImportStreamFilesRouteBuilder.java | 1 +
.../management/agent/service/ScanService.java | 11 ++---
.../subscriber/ScanCommandMessageHandler.java | 1 -
.../management/agent/util/IDGenerator.java | 2 +-
.../base/AsyncRoutePublisherImplTests.java | 44 +++++++++----------
.../scanManager/rest/EMAControllerTest.java | 3 --
.../scanManager/rest/ScanControllerTest.java | 3 --
.../swagger/SwaggerConfigTest.java | 2 +-
.../agent/service/ScanServiceTests.java | 3 --
.../subscriber/MessageReceiverTests.java | 2 +-
11 files changed, 31 insertions(+), 42 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java
index d9e7173e..3f38676d 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java
@@ -30,6 +30,7 @@ public ScanDataImportParseMetaInfFileRouteBuilder(ScanDataImportParseMetaInfFile
ScanDataImportPublishImportScanEventProcessor scanDataImportPublishImportScanEventProcessor,
ScanDataImportPersistScanDataProcessor scanDataImportPersistScanDataProcessor,
ScanDataImportPersistFilePathsProcessor scanDataImportPersistFilePathsProcessor) {
+ super();
this.scanDataImportParseMetaInfFileProcessor = scanDataImportParseMetaInfFileProcessor;
this.scanDataImportOverAllStatusProcessor = scanDataImportOverAllStatusProcessor;
this.scanDataImportPublishImportScanEventProcessor = scanDataImportPublishImportScanEventProcessor;
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java
index 92963f5f..edff6185 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java
@@ -23,6 +23,7 @@ public class ScanDataImportStreamFilesRouteBuilder extends RouteBuilder {
public ScanDataImportStreamFilesRouteBuilder(ScanDataImportStatusProcessor scanDataImportStatusProcessor,
ScanDataImportPersistScanFilesProcessor scanDataImportPersistScanFilesProcessor) {
+ super();
this.scanDataImportStatusProcessor = scanDataImportStatusProcessor;
this.scanDataImportPersistScanFilesProcessor = scanDataImportPersistScanFilesProcessor;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
index 7d9281e2..d9acbc84 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
@@ -38,9 +38,6 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.MESSAGING_SERVICE_ID;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCHEDULE_ID;
-
/**
* Responsible for initiating and managing Messaging Service scans.
*/
@@ -249,8 +246,8 @@ protected Exchange scan(String groupId, String scanId, RouteEntity route,
return producerTemplate.send("seda:" + route.getId(), exchange -> {
// Need to set headers to let the Route have access to the Scan ID, Group ID, and Messaging Service ID.
exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
- exchange.getIn().setHeader(SCHEDULE_ID, groupId);
- exchange.getIn().setHeader(MESSAGING_SERVICE_ID, messagingServiceId);
+ exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId);
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
});
}
@@ -279,8 +276,8 @@ protected CompletableFuture scanAsync(String groupId, String scanId, R
return producerTemplate.asyncSend("seda:" + route.getId(), exchange -> {
// Need to set headers to let the Route have access to the Scan ID, Group ID, and Messaging Service ID.
exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
- exchange.getIn().setHeader(SCHEDULE_ID, groupId);
- exchange.getIn().setHeader(MESSAGING_SERVICE_ID, messagingServiceId);
+ exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId);
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
exchange.getIn().setHeader(SchedulerConstants.SCHEDULER_TERMINATION_TIMER, true);
exchange.getIn().setHeader(SchedulerConstants.SCHEDULER_TYPE, SchedulerType.INTERVAL.name());
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
index 6841cbc8..a24d300b 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
@@ -3,7 +3,6 @@
import com.solace.maas.ep.common.messages.ScanCommandMessage;
import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration;
import com.solace.maas.ep.event.management.agent.scanManager.ScanManager;
-import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanRequestMapper;
import com.solace.maas.ep.event.management.agent.scanManager.model.ScanRequestBO;
import lombok.extern.slf4j.Slf4j;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java
index 70f7c70a..afbe46dc 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/util/IDGenerator.java
@@ -63,7 +63,7 @@ public String generateRandomUniqueId() {
public void init() {
byte[] instanceSeed = "1".getBytes(StandardCharsets.UTF_8);
if (idGeneratorProperties.getOriginId() != null) {
- String instanceSeedString = idGeneratorProperties.getOriginId() + (System.nanoTime() & 655_35);
+ String instanceSeedString = idGeneratorProperties.getOriginId() + (System.nanoTime() & 65_535);
instanceSeed = instanceSeedString.getBytes(StandardCharsets.UTF_8);
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java
index 5081c954..5d70aabf 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java
@@ -49,7 +49,7 @@ public void testStart() {
.withHeader(RouteConstants.SCAN_TYPE, "testScan")
.build();
- try(MockedStatic reactiveStreams = mockStatic(CamelReactiveStreams.class)) {
+ try (MockedStatic reactiveStreams = mockStatic(CamelReactiveStreams.class)) {
reactiveStreams.when(() -> CamelReactiveStreams.get(camelContext))
.thenReturn(camelReactiveStreamsService);
@@ -75,34 +75,34 @@ public void testSendMessage() {
.withHeader(RouteConstants.SCAN_TYPE, "testScan")
.build();
- CamelContext extendedCamelContext = mock(ExtendedCamelContext.class);
+ try (CamelContext extendedCamelContext = mock(ExtendedCamelContext.class)) {
+ Exchange newExchange = mock(Exchange.class);
+ Message message = mock(Message.class);
- Exchange newExchange = mock(Exchange.class);
- Message message = mock(Message.class);
+ when(camelReactiveStreamsService.getCamelContext())
+ .thenReturn(extendedCamelContext);
- when(camelReactiveStreamsService.getCamelContext())
- .thenReturn(extendedCamelContext);
+ try (MockedStatic reactiveStreams = mockStatic(CamelReactiveStreams.class)) {
+ reactiveStreams.when(() -> CamelReactiveStreams.get(camelContext))
+ .thenReturn(camelReactiveStreamsService);
- try(MockedStatic reactiveStreams = mockStatic(CamelReactiveStreams.class)) {
- reactiveStreams.when(() -> CamelReactiveStreams.get(camelContext))
- .thenReturn(camelReactiveStreamsService);
+ ExchangeBuilder exchangeBuilder = mock(ExchangeBuilder.class, Mockito.RETURNS_SELF);
+ when(exchangeBuilder.build())
+ .thenReturn(newExchange);
- ExchangeBuilder exchangeBuilder = mock(ExchangeBuilder.class, Mockito.RETURNS_SELF);
- when(exchangeBuilder.build())
- .thenReturn(newExchange);
+ when(newExchange.getIn()).thenReturn(message);
+ when(message.getHeaders())
+ .thenReturn(Map.of());
+ doNothing().when(message).setHeaders(anyMap());
- when(newExchange.getIn()).thenReturn(message);
- when(message.getHeaders())
- .thenReturn(Map.of());
- doNothing().when(message).setHeaders(anyMap());
+ AsyncRoutePublisherImpl asyncRoutePublisher = mock(AsyncRoutePublisherImpl.class, Mockito.withSettings()
+ .useConstructor(camelContext, asyncManager)
+ .defaultAnswer(Mockito.CALLS_REAL_METHODS));
- AsyncRoutePublisherImpl asyncRoutePublisher = mock(AsyncRoutePublisherImpl.class, Mockito.withSettings()
- .useConstructor(camelContext, asyncManager)
- .defaultAnswer(Mockito.CALLS_REAL_METHODS));
-
- asyncRoutePublisher.sendMesage("test", exchange);
+ asyncRoutePublisher.sendMesage("test", exchange);
+ }
}
-
+
assertThatNoException();
}
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
index 7b803e4e..9f83913f 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
@@ -35,9 +35,6 @@ public class EMAControllerTest {
@Autowired
private ScanRequestMapper scanRequestMapper;
- @Autowired
- private ScanItemMapper scanItemMapper;
-
@Test
public void testEMAControllerInConnectedMode() {
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
index d680c673..b37d5e78 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
@@ -34,9 +34,6 @@ public class ScanControllerTest {
@Mock
private ScanItemMapper scanItemMapper;
- @Mock
- private EventPortalProperties eventPortalProperties;
-
@Mock
private ScanManager scanManager;
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/swagger/SwaggerConfigTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/swagger/SwaggerConfigTest.java
index 33ef7212..f5d2fb6e 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/swagger/SwaggerConfigTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/swagger/SwaggerConfigTest.java
@@ -24,7 +24,7 @@ public class SwaggerConfigTest {
@Test
@SneakyThrows
- public void SwaggerConfigTest() {
+ public void testSwaggerConfig() {
swaggerConfig.swagger(resourceLoader);
assertThatNoException();
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
index 1727bae1..6dcd1b5a 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
@@ -77,9 +77,6 @@ public class ScanServiceTests {
@Mock
private ScanRouteService scanRouteService;
- @Mock
- private RouteCompleteProcessorImpl routeCompleteProcessor;
-
@Mock
private IDGenerator idGenerator;
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
index bac66b04..5050ecaa 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
@@ -99,7 +99,7 @@ public void scanReceiver() {
@Test
@SneakyThrows
public void testBadClass() {
- Exception e = assertThrows(RuntimeException.class, () -> {
+ assertThrows(RuntimeException.class, () -> {
when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn("badClass");
ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(solaceConfiguration,
solaceSubscriber, scanManager);
From 890402c0271fe5c47faa3d526765e8fa983e8315 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 30 May 2023 15:57:16 -0400
Subject: [PATCH 12/31] resolve PMD violations on in Application
---
.../agent/service/ImportService.java | 6 +++---
.../DataPublisherRouteBuilderTests.java | 21 ++++++++++---------
.../ScanDataImportRouteBuilderTests.java | 9 ++++----
.../base/AsyncRoutePublisherImplTests.java | 1 -
.../agent/scanManager/ScanManagerTest.java | 4 ++--
.../scanManager/rest/EMAControllerTest.java | 1 -
.../scanManager/rest/ScanControllerTest.java | 1 -
.../agent/service/ScanServiceTests.java | 3 +--
8 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
index a9be3d82..b375314d 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
@@ -19,10 +19,10 @@
import org.springframework.stereotype.Service;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -78,7 +78,7 @@ private void initiateImport(InputStream files, String importId) {
});
}
- public InputStream zip(ZipRequestBO zipRequestBO) throws FileNotFoundException {
+ public InputStream zip(ZipRequestBO zipRequestBO) throws IOException {
String scanId = zipRequestBO.getScanId();
List files = dataCollectionFileService.findAllByScanId(scanId);
@@ -111,7 +111,7 @@ public InputStream zip(ZipRequestBO zipRequestBO) throws FileNotFoundException {
GenericFile> downloadedGenericFile = exchange.getIn().getBody(GenericFile.class);
File downloadedFile = (File) downloadedGenericFile.getFile();
- return new FileInputStream(downloadedFile);
+ return Files.newInputStream(Paths.get(downloadedFile.toURI()));
}
private MetaInfFileBO prepareMetaInfJson(List files, String messagingServiceId,
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java
index f1025b69..225af315 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java
@@ -61,20 +61,21 @@ public static List generateTestData() {
@Test
public void testMockRoute() throws Exception {
- DirectVmEndpoint ep = new DirectVmEndpoint("scanStatusPublisher", null);
- camelContext.addEndpoint("direct:scanStatusPublisher", ep);
+ try (DirectVmEndpoint ep = new DirectVmEndpoint("scanStatusPublisher", null)) {
+ camelContext.addEndpoint("direct:scanStatusPublisher", ep);
- AdviceWith.adviceWith(camelContext, "dataPublisherRoute",
- route -> {
- route.replaceFromWith("direct:dataPublisherRoute");
- route.weaveAddLast().to("mock:direct:result");
- });
+ AdviceWith.adviceWith(camelContext, "dataPublisherRoute",
+ route -> {
+ route.replaceFromWith("direct:dataPublisherRoute");
+ route.weaveAddLast().to("mock:direct:result");
+ });
- mockResult.expectedMessageCount(1);
+ mockResult.expectedMessageCount(1);
- producerTemplate.sendBody("direct:dataPublisherRoute", null);
+ producerTemplate.sendBody("direct:dataPublisherRoute", null);
- mockResult.assertIsSatisfied();
+ mockResult.assertIsSatisfied();
+ }
}
@AllArgsConstructor
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java
index a77f6977..c650f392 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java
@@ -48,14 +48,13 @@ public class ScanDataImportRouteBuilderTests {
private MockEndpoint mockResult;
private static byte[] getZippedText(String entryName) throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("TEXT" .getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream);
- try {
+ try(
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("TEXT" .getBytes(StandardCharsets.UTF_8));
+ ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream);
+ ) {
zipOutputStream.putNextEntry(new ZipEntry(entryName));
IOHelper.copy(byteArrayInputStream, zipOutputStream);
- } finally {
- IOHelper.close(byteArrayInputStream, zipOutputStream);
}
return byteArrayOutputStream.toByteArray();
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java
index 5d70aabf..0ef05525 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncRoutePublisherImplTests.java
@@ -102,7 +102,6 @@ public void testSendMessage() {
asyncRoutePublisher.sendMesage("test", exchange);
}
}
-
assertThatNoException();
}
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java
index 4e91dfa3..2117ad18 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java
@@ -72,11 +72,11 @@ void testScanManagerExceptions() {
ScanRequestBO scanRequestBOTopics =
new ScanRequestBO("id", "scanId", List.of("TEST_SCAN_1"), List.of());
- Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBO));
+ Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBOTopics));
ScanRequestBO scanRequestBOConsumerGroups =
new ScanRequestBO("id", "scanId", List.of("TEST_SCAN_2"), List.of());
- Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBO));
+ Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBOConsumerGroups));
}
@Test
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
index 9f83913f..efdf543e 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
@@ -6,7 +6,6 @@
import com.solace.maas.ep.event.management.agent.config.eventPortal.GatewayMessagingProperties;
import com.solace.maas.ep.event.management.agent.config.eventPortal.GatewayProperties;
import com.solace.maas.ep.event.management.agent.scanManager.ScanManager;
-import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanItemMapper;
import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanRequestMapper;
import com.solace.maas.ep.event.management.agent.scanManager.model.ScanRequestBO;
import com.solace.maas.ep.event.management.agent.util.IDGenerator;
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
index b37d5e78..b39c9487 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
@@ -1,7 +1,6 @@
package com.solace.maas.ep.event.management.agent.scanManager.rest;
import com.solace.maas.ep.event.management.agent.TestConfig;
-import com.solace.maas.ep.event.management.agent.config.eventPortal.EventPortalProperties;
import com.solace.maas.ep.event.management.agent.scanManager.ScanManager;
import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanItemMapper;
import com.solace.maas.ep.event.management.agent.scanManager.model.ScanItemBO;
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
index 6dcd1b5a..d16ed511 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
@@ -5,13 +5,12 @@
import com.solace.maas.ep.event.management.agent.plugin.constants.ScanStatus;
import com.solace.maas.ep.event.management.agent.plugin.route.RouteBundle;
import com.solace.maas.ep.event.management.agent.plugin.route.RouteBundleHierarchyStore;
-import com.solace.maas.ep.event.management.agent.processor.RouteCompleteProcessorImpl;
import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.MessagingServiceEntity;
import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity;
import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanEntity;
+import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanRecipientHierarchyEntity;
import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanStatusEntity;
import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanTypeEntity;
-import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanRecipientHierarchyEntity;
import com.solace.maas.ep.event.management.agent.repository.scan.ScanRecipientHierarchyRepository;
import com.solace.maas.ep.event.management.agent.repository.scan.ScanRepository;
import com.solace.maas.ep.event.management.agent.repository.scan.ScanTypeRepository;
From 335265a9b0badd002847c51ebca46e3c680673fe Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Wed, 31 May 2023 14:41:52 -0400
Subject: [PATCH 13/31] resolve PMD violations on in Application
---
.../route/ep/exceptions/ClientException.java | 21 +----
.../agent/service/ImportService.java | 4 +-
.../management/agent/service/ScanService.java | 60 +++++-------
.../ep/event/management/agent/TestConfig.java | 94 +------------------
.../agent/service/ScanServiceTests.java | 54 ++++-------
.../MessagingServiceTestConfig.java | 57 +++++++++++
.../testConfigs/PublisherTestConfig.java | 63 +++++++++++++
7 files changed, 170 insertions(+), 183 deletions(-)
create mode 100644 service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/MessagingServiceTestConfig.java
create mode 100644 service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/PublisherTestConfig.java
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
index 2d778fd7..9573746b 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
@@ -1,10 +1,14 @@
package com.solace.maas.ep.event.management.agent.route.ep.exceptions;
import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import java.util.List;
import java.util.Map;
+@EqualsAndHashCode(callSuper = true)
+@Data
@ExcludeFromJacocoGeneratedReport
public class ClientException extends RuntimeException {
private String message;
@@ -16,22 +20,7 @@ public class ClientException extends RuntimeException {
this.exceptionStore = validationDetails;
}
- public String getMessage() {
- return this.message;
- }
-
- public void setMessage(final String message) {
- this.message = message;
- }
-
- public Map> getExceptionStore() {
- return this.exceptionStore;
- }
-
- public void setExceptionStore(final Map> exceptionStore) {
- this.exceptionStore = exceptionStore;
- }
-
+ @Override
public String toString() {
String var10000 = this.getMessage();
return "ClientException(message=" + var10000 + ", validationDetails=" + this.getExceptionStore() + ")";
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
index b375314d..bb8ab41d 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
@@ -50,7 +50,7 @@ public ImportService(ProducerTemplate producerTemplate, DataCollectionFileServic
this.eventPortalProperties = eventPortalProperties;
}
- public void importData(ImportRequestBO importRequestBO) {
+ public void importData(ImportRequestBO importRequestBO) throws IOException {
boolean isEMAStandalone = eventPortalProperties.getGateway().getMessaging().isStandalone();
try (InputStream importStream = importRequestBO.getDataFile().getInputStream()) {
@@ -61,8 +61,6 @@ public void importData(ImportRequestBO importRequestBO) {
} else {
initiateImport(importStream, importId);
}
- } catch (IOException e) {
- throw new RuntimeException(e);
}
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
index d9acbc84..a6bb294e 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
@@ -343,48 +343,32 @@ public List listScans() {
public Page findAll(Pageable pageable) {
return repository.findAll(pageable)
- .map(se -> {
- List scanTypes = se.getScanTypes()
- .stream()
- .map(scanTypeEntity -> ScanTypeBO.builder()
- .name(scanTypeEntity.getName())
- .status(scanTypeEntity.getStatus().getStatus())
- .build())
- .collect(Collectors.toUnmodifiableList());
-
- return ScanItemBO.builder()
- .id(se.getId())
- .createdAt(se.getCreatedAt())
- .messagingServiceId(se.getMessagingService().getId())
- .messagingServiceName(se.getMessagingService().getName())
- .messagingServiceType(se.getMessagingService().getType())
- .emaId(se.getEmaId())
- .scanTypes(scanTypes)
- .build();
- });
+ .map(this::mapToScanItemBO);
}
public Page findByMessagingServiceId(String messagingServiceId, Pageable pageable) {
return repository.findAllByMessagingServiceId(messagingServiceId, pageable)
- .map(se -> {
- List scanTypes = se.getScanTypes()
- .stream()
- .map(scanTypeEntity -> ScanTypeBO.builder()
- .name(scanTypeEntity.getName())
- .status(scanTypeEntity.getStatus().getStatus())
- .build())
- .collect(Collectors.toUnmodifiableList());
-
- return ScanItemBO.builder()
- .id(se.getId())
- .createdAt(se.getCreatedAt())
- .messagingServiceId(se.getMessagingService().getId())
- .messagingServiceName(se.getMessagingService().getName())
- .messagingServiceType(se.getMessagingService().getType())
- .emaId(se.getEmaId())
- .scanTypes(scanTypes)
- .build();
- });
+ .map(this::mapToScanItemBO);
+ }
+
+ private ScanItemBO mapToScanItemBO(ScanEntity scanEntity) {
+ List scanTypes = scanEntity.getScanTypes()
+ .stream()
+ .map(scanTypeEntity -> ScanTypeBO.builder()
+ .name(scanTypeEntity.getName())
+ .status(scanTypeEntity.getStatus().getStatus())
+ .build())
+ .collect(Collectors.toUnmodifiableList());
+
+ return ScanItemBO.builder()
+ .id(scanEntity.getId())
+ .createdAt(scanEntity.getCreatedAt())
+ .messagingServiceId(scanEntity.getMessagingService().getId())
+ .messagingServiceName(scanEntity.getMessagingService().getName())
+ .messagingServiceType(scanEntity.getMessagingService().getType())
+ .emaId(scanEntity.getEmaId())
+ .scanTypes(scanTypes)
+ .build();
}
protected RouteBundleHierarchyStore parseRouteRecipients(List routeBundles, RouteBundleHierarchyStore pathStore) {
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java
index 7290ecfa..4a509114 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java
@@ -1,25 +1,14 @@
package com.solace.maas.ep.event.management.agent;
-import com.solace.maas.ep.event.management.agent.config.plugin.enumeration.MessagingServiceType;
import com.solace.maas.ep.event.management.agent.messagingServices.RtoMessagingService;
import com.solace.maas.ep.event.management.agent.plugin.config.VMRProperties;
import com.solace.maas.ep.event.management.agent.plugin.config.eventPortal.EventPortalPluginProperties;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.RtoMessageBuilder;
-import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher;
-import com.solace.maas.ep.event.management.agent.plugin.publisher.SolaceWebPublisher;
import com.solace.maas.ep.event.management.agent.plugin.vmr.VmrProcessor;
-import com.solace.maas.ep.event.management.agent.publisher.ScanDataPublisher;
-import com.solace.maas.ep.event.management.agent.publisher.ScanLogsPublisher;
-import com.solace.maas.ep.event.management.agent.publisher.ScanStatusPublisher;
-import com.solace.maas.ep.event.management.agent.repository.messagingservice.MessagingServiceRepository;
-import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.ConnectionDetailsEntity;
-import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.MessagingServiceEntity;
-import com.solace.maas.ep.event.management.agent.service.MessagingServiceEntityToEventConverter;
-import com.solace.maas.ep.event.management.agent.service.MessagingServiceEventToEntityConverter;
+import com.solace.maas.ep.event.management.agent.testConfigs.MessagingServiceTestConfig;
+import com.solace.maas.ep.event.management.agent.testConfigs.PublisherTestConfig;
import com.solace.maas.ep.event.management.agent.util.IDGenerator;
import com.solace.maas.ep.event.management.agent.util.config.idgenerator.IDGeneratorProperties;
-import com.solace.messaging.MessagingService;
-import com.solace.messaging.publisher.DirectMessagePublisher;
import com.solace.messaging.publisher.OutboundMessageBuilder;
import com.solace.messaging.resources.Topic;
import org.apache.camel.CamelContext;
@@ -29,22 +18,20 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
-import java.util.List;
-import java.util.Optional;
import java.util.Properties;
import java.util.Random;
-import java.util.UUID;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@TestConfiguration
@Profile("TEST")
+@Import({PublisherTestConfig.class, MessagingServiceTestConfig.class})
public class TestConfig {
@Autowired
@@ -85,48 +72,6 @@ public VmrProcessor getVmrProcessor() {
return processor;
}
- @Bean
- @Primary
- public MessagingService messagingService() {
- return mock(MessagingService.class);
- }
-
- @Bean
- @Primary
- public SolacePublisher solacePublisher() {
- return mock(SolacePublisher.class);
- }
-
- @Bean
- @Primary
- public SolaceWebPublisher solaceWebPublisher() {
- return mock(SolaceWebPublisher.class);
- }
-
- @Bean
- @Primary
- public ScanDataPublisher scanDataPublisher() {
- return mock(ScanDataPublisher.class);
- }
-
- @Bean
- @Primary
- public DirectMessagePublisher directMessagePublisher() {
- return mock(DirectMessagePublisher.class);
- }
-
- @Bean
- @Primary
- public ScanLogsPublisher scanLogsPublisher() {
- return mock(ScanLogsPublisher.class);
- }
-
- @Bean
- @Primary
- public ScanStatusPublisher scanStatusPublisher() {
- return mock(ScanStatusPublisher.class);
- }
-
@Bean
@Primary
public OutboundMessageBuilder outboundMessageBuilder() {
@@ -145,37 +90,6 @@ public RtoMessageBuilder webMessagingService() {
return mock(RtoMessageBuilder.class);
}
- @Bean
- @Primary
- public MessagingServiceRepository getRepository() {
- MessagingServiceRepository repository = mock(MessagingServiceRepository.class);
- ConnectionDetailsEntity connectionDetailsEntity = ConnectionDetailsEntity.builder()
- .id(UUID.randomUUID().toString())
- .url("localhost:9090")
- .build();
-
- when(repository.findById(any(String.class)))
- .thenReturn(Optional.of(MessagingServiceEntity.builder()
- .type(MessagingServiceType.SOLACE.name())
- .name("service1")
- .id(UUID.randomUUID().toString())
- .connections(List.of(connectionDetailsEntity))
- .build()));
- return repository;
- }
-
- @Bean
- @Primary
- public MessagingServiceEntityToEventConverter entityToEventConverter() {
- return new MessagingServiceEntityToEventConverter();
- }
-
- @Bean
- @Primary
- public MessagingServiceEventToEntityConverter eventToEntityConverter() {
- return new MessagingServiceEventToEntityConverter();
- }
-
@Bean
@Primary
public IDGeneratorProperties idGeneratorProperties() {
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
index d16ed511..0c9da006 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
@@ -89,80 +89,63 @@ public class ScanServiceTests {
@SneakyThrows
public void testSingleScanWithRouteBundle() {
RouteBundle consumerGroupsConfiguration = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("consumerGroupsConfiguration")
- .destinations(List.of())
+ .messagingServiceId("service1").routeId("route1")
+ .scanType("consumerGroupsConfiguration").destinations(List.of())
.recipients(List.of())
.build();
RouteBundle consumerGroups = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("consumerGroups")
- .destinations(List.of())
+ .messagingServiceId("service1").routeId("route1")
+ .scanType("consumerGroups").destinations(List.of())
.recipients(List.of(consumerGroupsConfiguration))
.build();
RouteBundle routeBundleDestination = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("log:deadend")
- .scanType("none")
- .destinations(List.of())
+ .messagingServiceId("service1").routeId("log:deadend")
+ .scanType("none").destinations(List.of())
.recipients(List.of())
.build();
RouteBundle topicConfiguration = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("topicConfiguration")
- .destinations(List.of())
+ .messagingServiceId("service1").routeId("route1")
+ .scanType("topicConfiguration").destinations(List.of())
.recipients(List.of())
.build();
RouteBundle overrideTopicConfiguration = RouteBundle.builder()
.messagingServiceId("service1")
- .routeId("route1")
- .scanType("overrideTopicConfiguration")
- .destinations(List.of())
- .recipients(List.of())
+ .routeId("route1").scanType("overrideTopicConfiguration")
+ .destinations(List.of()).recipients(List.of())
.build();
RouteBundle topicListing = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("topicListing")
- .destinations(List.of(routeBundleDestination))
+ .messagingServiceId("service1").routeId("route1")
+ .scanType("topicListing").destinations(List.of(routeBundleDestination))
.recipients(List.of(topicConfiguration, overrideTopicConfiguration))
.build();
RouteBundle additionalConsumerGroupConfigPart1 = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
+ .messagingServiceId("service1").routeId("route1")
.scanType("additionalConsumerGroupConfigPart1")
.destinations(List.of(routeBundleDestination))
.recipients(List.of())
.build();
RouteBundle additionalConsumerGroupConfigPart2 = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
+ .messagingServiceId("service1").routeId("route1")
.scanType("additionalConsumerGroupConfigPart2")
.destinations(List.of(routeBundleDestination))
.recipients(List.of())
.build();
RouteBundle additionalConsumerGroupConfigBundle = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("consumerGroupsConfiguration")
- .destinations(List.of(routeBundleDestination))
+ .messagingServiceId("service1").routeId("route1")
+ .scanType("consumerGroupsConfiguration").destinations(List.of(routeBundleDestination))
.recipients(List.of(additionalConsumerGroupConfigPart1, additionalConsumerGroupConfigPart2))
.build();
RouteEntity returnedEntity = RouteEntity.builder()
- .id(routeId)
- .childRouteIds("")
+ .id(routeId).childRouteIds("")
.active(true)
.build();
@@ -172,8 +155,7 @@ public void testSingleScanWithRouteBundle() {
.build();
ScanTypeEntity scanType = ScanTypeEntity.builder()
- .id("scan1")
- .name("scanType")
+ .id("scan1").name("scanType")
.scan(scanEntity)
.build();
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/MessagingServiceTestConfig.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/MessagingServiceTestConfig.java
new file mode 100644
index 00000000..094ed5ae
--- /dev/null
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/MessagingServiceTestConfig.java
@@ -0,0 +1,57 @@
+package com.solace.maas.ep.event.management.agent.testConfigs;
+
+import com.solace.maas.ep.event.management.agent.config.plugin.enumeration.MessagingServiceType;
+import com.solace.maas.ep.event.management.agent.repository.messagingservice.MessagingServiceRepository;
+import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.ConnectionDetailsEntity;
+import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.MessagingServiceEntity;
+import com.solace.maas.ep.event.management.agent.service.MessagingServiceEntityToEventConverter;
+import com.solace.maas.ep.event.management.agent.service.MessagingServiceEventToEntityConverter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@TestConfiguration
+@Profile("TEST")
+@Slf4j
+public class MessagingServiceTestConfig {
+ @Bean
+ @Primary
+ public MessagingServiceRepository getRepository() {
+ MessagingServiceRepository repository = mock(MessagingServiceRepository.class);
+ ConnectionDetailsEntity connectionDetailsEntity = ConnectionDetailsEntity.builder()
+ .id(UUID.randomUUID().toString())
+ .url("localhost:9090")
+ .build();
+
+ when(repository.findById(any(String.class)))
+ .thenReturn(Optional.of(MessagingServiceEntity.builder()
+ .type(MessagingServiceType.SOLACE.name())
+ .name("service1")
+ .id(UUID.randomUUID().toString())
+ .connections(List.of(connectionDetailsEntity))
+ .build()));
+ return repository;
+ }
+
+ @Bean
+ @Primary
+ public MessagingServiceEntityToEventConverter entityToEventConverter() {
+ return new MessagingServiceEntityToEventConverter();
+ }
+
+ @Bean
+ @Primary
+ public MessagingServiceEventToEntityConverter eventToEntityConverter() {
+ return new MessagingServiceEventToEntityConverter();
+ }
+}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/PublisherTestConfig.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/PublisherTestConfig.java
new file mode 100644
index 00000000..e6384b03
--- /dev/null
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/testConfigs/PublisherTestConfig.java
@@ -0,0 +1,63 @@
+package com.solace.maas.ep.event.management.agent.testConfigs;
+
+import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher;
+import com.solace.maas.ep.event.management.agent.plugin.publisher.SolaceWebPublisher;
+import com.solace.maas.ep.event.management.agent.publisher.ScanDataPublisher;
+import com.solace.maas.ep.event.management.agent.publisher.ScanLogsPublisher;
+import com.solace.maas.ep.event.management.agent.publisher.ScanStatusPublisher;
+import com.solace.messaging.MessagingService;
+import com.solace.messaging.publisher.DirectMessagePublisher;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+
+import static org.mockito.Mockito.mock;
+
+@TestConfiguration
+@Profile("TEST")
+@Slf4j
+public class PublisherTestConfig {
+ @Bean
+ @Primary
+ public MessagingService messagingService() {
+ return mock(MessagingService.class);
+ }
+
+ @Bean
+ @Primary
+ public SolacePublisher solacePublisher() {
+ return mock(SolacePublisher.class);
+ }
+
+ @Bean
+ @Primary
+ public SolaceWebPublisher solaceWebPublisher() {
+ return mock(SolaceWebPublisher.class);
+ }
+
+ @Bean
+ @Primary
+ public ScanDataPublisher scanDataPublisher() {
+ return mock(ScanDataPublisher.class);
+ }
+
+ @Bean
+ @Primary
+ public DirectMessagePublisher directMessagePublisher() {
+ return mock(DirectMessagePublisher.class);
+ }
+
+ @Bean
+ @Primary
+ public ScanLogsPublisher scanLogsPublisher() {
+ return mock(ScanLogsPublisher.class);
+ }
+
+ @Bean
+ @Primary
+ public ScanStatusPublisher scanStatusPublisher() {
+ return mock(ScanStatusPublisher.class);
+ }
+}
From 0f4b797e8d074f689943a720a4e0e88113564de6 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Mon, 5 Jun 2023 10:01:45 -0400
Subject: [PATCH 14/31] address pr comments
---
.../scanManager/rest/DataImportControllerImpl.java | 13 +++++++------
.../base/AsyncDataPublisherRouteBuilder.java | 1 -
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
index d0f10946..20c0d932 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
@@ -59,14 +59,15 @@ public ResponseEntity read(@RequestParam("file") MultipartFile file) {
@Override
@GetMapping(value = "/export/{scanId}/zip")
+ @SuppressWarnings("PMD.CloseResource")
public ResponseEntity zip(@PathVariable(value = "scanId") String scanId) {
- ZipRequestBO zipRequestBO = ZipRequestBO.builder()
- .scanId(scanId)
- .build();
-
- log.info("Received zip request for scan: {}", scanId);
+ try {
+ ZipRequestBO zipRequestBO = ZipRequestBO.builder()
+ .scanId(scanId)
+ .build();
+ log.info("Received zip request for scan: {}", scanId);
- try (InputStream zipInputStream = importService.zip(zipRequestBO)) {
+ InputStream zipInputStream = importService.zip(zipRequestBO);
InputStreamResource inputStreamResource = new InputStreamResource(zipInputStream);
HttpHeaders httpHeaders = new HttpHeaders();
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
index 1865b774..a48453b7 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/AsyncDataPublisherRouteBuilder.java
@@ -82,7 +82,6 @@ public void configure() {
Publisher exchanges = camel.fromStream("asyncProcessing_" + routeId);
- camel.stop();
Flux.from(exchanges)
.publishOn(Schedulers.boundedElastic())
.subscribe(asyncRoutePublisher::start);
From f7ff7236aca9232e05707b57304d15c1b821cf58 Mon Sep 17 00:00:00 2001
From: Puck Wang
Date: Tue, 6 Jun 2023 01:06:33 -0400
Subject: [PATCH 15/31] disable CloseResource warning on manual import
---
.../management/agent/service/ImportService.java | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
index bb8ab41d..350b3144 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
@@ -50,17 +50,16 @@ public ImportService(ProducerTemplate producerTemplate, DataCollectionFileServic
this.eventPortalProperties = eventPortalProperties;
}
+ @SuppressWarnings("PMD.CloseResource")
public void importData(ImportRequestBO importRequestBO) throws IOException {
boolean isEMAStandalone = eventPortalProperties.getGateway().getMessaging().isStandalone();
- try (InputStream importStream = importRequestBO.getDataFile().getInputStream()) {
+ InputStream importStream = importRequestBO.getDataFile().getInputStream();
+ String importId = UUID.randomUUID().toString();
- String importId = UUID.randomUUID().toString();
-
- if (isEMAStandalone) {
- throw new FileUploadException("Scan data could not be imported in standalone mode.");
- } else {
- initiateImport(importStream, importId);
- }
+ if (isEMAStandalone) {
+ throw new FileUploadException("Scan data could not be imported in standalone mode.");
+ } else {
+ initiateImport(importStream, importId);
}
}
From 2851acbe2469d49aedbfe6dded2bfd8b1ad1fabb Mon Sep 17 00:00:00 2001
From: Abdullah Habes <33485177+AHabes@users.noreply.github.com>
Date: Thu, 8 Jun 2023 18:09:41 -0400
Subject: [PATCH 16/31] Add the traceId to all messages streamed by EMA to EP
(#68)
---
service/application/pom.xml | 6 +
.../messages/ScanDataImportMessage.java | 7 +-
.../ep/common/messages/ScanDataMessage.java | 5 +-
.../messages/ScanDataStatusMessage.java | 5 +-
.../ep/common/messages/ScanLogMessage.java | 5 +-
.../ep/common/messages/ScanStatusMessage.java | 5 +-
.../agent/logging/StreamingAppender.java | 5 +-
.../EmptyScanEntityProcessorImpl.java | 11 +-
.../processor/RouteCompleteProcessorImpl.java | 1 +
...anDataImportParseMetaInfFileProcessor.java | 13 ++
...anDataImportPersistFilePathsProcessor.java | 19 +-
...canDataImportPersistScanDataProcessor.java | 2 +
...ImportPublishImportScanEventProcessor.java | 14 +-
.../agent/processor/ScanDataProcessor.java | 4 +-
.../agent/processor/ScanLogsProcessor.java | 8 +-
.../processor/ScanStatusOverAllProcessor.java | 4 +-
.../ScanStatusPerRouteProcessor.java | 4 +-
.../ManualImportDetailsEntity.java | 9 +-
.../repository/model/scan/ScanEntity.java | 3 +
.../ep/ScanStatusPersistenceRouteBuilder.java | 1 +
.../FileParseAggregationStrategy.java | 2 +
.../route/ep/exceptions/ClientException.java | 1 +
.../manualImport/ImportRouteBuilder.java | 8 +-
...ataImportParseMetaInfFileRouteBuilder.java | 23 ++-
...ScanDataImportStreamFilesRouteBuilder.java | 17 +-
.../agent/route/scan/ScanRouteBuilder.java | 1 +
.../agent/scanManager/ScanManager.java | 4 +-
.../scanManager/model/ImportRequestBO.java | 2 +
.../scanManager/model/ScanRequestBO.java | 3 +
.../rest/DataImportControllerImpl.java | 4 +
.../agent/service/ImportService.java | 20 +-
.../management/agent/service/ScanService.java | 51 +++---
.../subscriber/ScanCommandMessageHandler.java | 13 +-
.../subscriber/SolaceMessageHandler.java | 24 ++-
.../StartImportScanCommandMessageHandler.java | 44 +++--
.../agent/logging/StreamingAppenderTests.java | 5 +-
.../ScanDataPublisherDelegateImplTests.java | 2 +-
.../DataPublisherRouteBuilderTests.java | 21 ++-
...portParseMetaInfFileRouteBuilderTests.java | 15 +-
.../ScanDataImportRouteBuilderTests.java | 8 +-
...ataImportStreamFilesRouteBuilderTests.java | 14 +-
.../ScanLogsPublisherRouteBuilderTests.java | 8 +-
...tatusMarkerAndLoggerRouteBuilderTests.java | 152 ++++++++++++++++
.../ScanStatusPublisherRouteBuilderTests.java | 1 +
...taImportPersistScanDataProcessorTests.java | 8 +-
.../processor/ScanDataProcessorTests.java | 11 +-
.../ScanStatusOverAllProcessorTests.java | 15 +-
.../ScanStatusPerRouteProcessorTests.java | 14 +-
.../agent/scanManager/ScanManagerTest.java | 56 ++++--
.../mapper/ScanRequestMapperTest.java | 14 +-
.../scanManager/rest/EMAControllerTest.java | 28 ++-
.../scanManager/rest/ScanControllerTest.java | 22 +--
.../agent/service/ImportServiceTests.java | 28 +--
.../agent/service/ScanServiceHelper.java | 66 +++++++
.../agent/service/ScanServiceTests.java | 172 +++++-------------
.../subscriber/MessageReceiverTests.java | 52 +++++-
.../delegate/KafkaRouteDelegateImplTests.java | 2 +-
...ericListScanIdAggregationStrategyTest.java | 6 +-
.../ScanIdAggregationStrategyTest.java | 9 +-
.../plugin/constants/RouteConstants.java | 5 +-
.../processor/logging/MDCProcessor.java | 9 +-
.../plugin/publisher/SolacePublisher.java | 2 +-
.../route/RouteBundleHierarchyStore.java | 2 +-
...ScanStatusMarkerAndLoggerRouteBuilder.java | 36 +++-
.../SolaceRouteDelegateImplTests.java | 2 +-
65 files changed, 735 insertions(+), 398 deletions(-)
create mode 100644 service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java
create mode 100644 service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceHelper.java
diff --git a/service/application/pom.xml b/service/application/pom.xml
index 994c62d4..6a0d9651 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -16,6 +16,7 @@
1.6.11
2.0
+ 3.1.5
@@ -47,6 +48,11 @@
org.springframework.boot
spring-boot-starter-data-jpa
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+ ${spring-cloud-starter-sleuth.version}
+
org.springframework.kafka
spring-kafka
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java
index 4f5f019c..6e1339b1 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java
@@ -16,6 +16,8 @@ public class ScanDataImportMessage extends MOPMessage {
String scanId;
+ String traceId;
+
String messagingServiceId;
String runtimeAgentId;
@@ -26,7 +28,7 @@ public ScanDataImportMessage() {
super();
}
- public ScanDataImportMessage(String orgId, String scanId, String messagingServiceId, List scanTypes, String runtimeAgentId) {
+ public ScanDataImportMessage(String orgId, String scanId, String traceId, String messagingServiceId, String runtimeAgentId, List scanTypes) {
super();
withMessageType(MOPMessageType.generic)
.withProtocol(MOPProtocol.scanDataControl)
@@ -35,8 +37,9 @@ public ScanDataImportMessage(String orgId, String scanId, String messagingServic
this.orgId = orgId;
this.scanId = scanId;
+ this.traceId = traceId;
this.messagingServiceId = messagingServiceId;
- this.scanTypes = scanTypes;
this.runtimeAgentId = runtimeAgentId;
+ this.scanTypes = scanTypes;
}
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java
index f7b4e1c4..dd667be7 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java
@@ -12,13 +12,15 @@ public class ScanDataMessage extends MOPMessage {
String scanId;
+ String traceId;
+
String scanType;
String data;
private String timestamp;
- public ScanDataMessage(String orgId, String scanId, String scanType, String data, String timestamp) {
+ public ScanDataMessage(String orgId, String scanId, String traceId, String scanType, String data, String timestamp) {
super();
withMessageType(MOPMessageType.generic)
.withProtocol(MOPProtocol.scanData)
@@ -27,6 +29,7 @@ public ScanDataMessage(String orgId, String scanId, String scanType, String data
this.orgId = orgId;
this.scanId = scanId;
+ this.traceId = traceId;
this.scanType = scanType;
this.data = data;
this.timestamp = timestamp;
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java
index 59259f5a..32e339f5 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java
@@ -16,13 +16,15 @@ public class ScanDataStatusMessage extends MOPMessage {
String scanId;
+ String traceId;
+
String status;
String description;
String scanType;
- public ScanDataStatusMessage(String orgId, String scanId, String status, String description, String scanType) {
+ public ScanDataStatusMessage(String orgId, String scanId, String traceId, String status, String description, String scanType) {
super();
withMessageType(MOPMessageType.generic)
.withProtocol(MOPProtocol.scanDataControl)
@@ -31,6 +33,7 @@ public ScanDataStatusMessage(String orgId, String scanId, String status, String
this.orgId = orgId;
this.scanId = scanId;
+ this.traceId = traceId;
this.status = status;
this.description = description;
this.scanType = scanType;
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java
index 322510e8..f4b42542 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java
@@ -12,13 +12,15 @@ public class ScanLogMessage extends MOPMessage {
String scanId;
+ String traceId;
+
String level;
String log;
Long timestamp;
- public ScanLogMessage(String orgId, String scanId, String level, String log, Long timestamp) {
+ public ScanLogMessage(String orgId, String scanId, String traceId, String level, String log, Long timestamp) {
super();
withMessageType(MOPMessageType.generic)
.withProtocol(MOPProtocol.scanDataControl)
@@ -27,6 +29,7 @@ public ScanLogMessage(String orgId, String scanId, String level, String log, Lon
this.orgId = orgId;
this.scanId = scanId;
+ this.traceId = traceId;
this.level = level;
this.log = log;
this.timestamp = timestamp;
diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java
index cb6e5f7b..1c72c219 100644
--- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java
+++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java
@@ -18,13 +18,15 @@ public class ScanStatusMessage extends MOPMessage {
String scanId;
+ String traceId;
+
String status;
String description;
private List scanTypes;
- public ScanStatusMessage(String orgId, String scanId, String status, String description, List scanTypes) {
+ public ScanStatusMessage(String orgId, String scanId, String traceId, String status, String description, List scanTypes) {
super();
withMessageType(MOPMessageType.generic)
.withProtocol(MOPProtocol.scanDataControl)
@@ -33,6 +35,7 @@ public ScanStatusMessage(String orgId, String scanId, String status, String desc
this.orgId = orgId;
this.scanId = scanId;
+ this.traceId = traceId;
this.status = status;
this.description = description;
this.scanTypes = scanTypes;
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java
index d46cdbb9..c9b8dee3 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java
@@ -29,6 +29,7 @@ protected void append(ILoggingEvent event) {
if (!event.getMDCPropertyMap().get(RouteConstants.SCAN_ID).isEmpty()) {
sendLogsAsync(event,
event.getMDCPropertyMap().get(RouteConstants.SCAN_ID),
+ event.getMDCPropertyMap().get(RouteConstants.TRACE_ID),
event.getMDCPropertyMap().get(RouteConstants.SCAN_TYPE),
event.getMDCPropertyMap().get(RouteConstants.SCHEDULE_ID),
event.getMDCPropertyMap().get(RouteConstants.MESSAGING_SERVICE_ID));
@@ -36,13 +37,13 @@ protected void append(ILoggingEvent event) {
}
}
- public void sendLogsAsync(ILoggingEvent event, String scanId, String scanType, String groupId,
- String messagingServiceId) {
+ public void sendLogsAsync(ILoggingEvent event, String scanId, String traceId, String scanType, String groupId, String messagingServiceId) {
RouteEntity route = creatLoggingRoute(scanType, messagingServiceId);
producerTemplate.asyncSend(route.getId(), exchange -> {
// Need to set headers to let the Route have access to the Scan ID, Group ID, and Messaging Service ID.
exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId);
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, scanType);
exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId);
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java
index 72516e21..953da0f9 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/EmptyScanEntityProcessorImpl.java
@@ -21,6 +21,7 @@ public class EmptyScanEntityProcessorImpl extends EmptyScanEntityProcessor {
private final ScanRecipientHierarchyRepository scanRecipientHierarchyRepository;
public EmptyScanEntityProcessorImpl(ScanRecipientHierarchyRepository scanRecipientHierarchyRepository) {
+ super();
this.scanRecipientHierarchyRepository = scanRecipientHierarchyRepository;
}
@@ -31,19 +32,20 @@ public void process(Exchange exchange) throws Exception {
Map properties = exchange.getIn().getHeaders();
String scanId = (String) properties.get(RouteConstants.SCAN_ID);
+ String traceId = (String) properties.get(RouteConstants.TRACE_ID);
String scanType = (String) properties.get(RouteConstants.SCAN_TYPE);
- log.info("Scan request [{}]: Encountered an empty scan type [{}].", scanId, scanType);
+ log.info("Scan request [{}], trace ID [{}]: Encountered an empty scan type [{}].", scanId, traceId, scanType);
emptyScanTypes.add(scanType);
- List emptyDescendents = checkScanTypeDescendents(scanId, scanType);
+ List emptyDescendents = checkScanTypeDescendents(scanId, traceId, scanType);
emptyScanTypes.addAll(emptyDescendents);
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, emptyScanTypes);
}
- private List checkScanTypeDescendents(String scanId, String scanType) {
+ private List checkScanTypeDescendents(String scanId, String traceId, String scanType) {
List emptyDescendentsForScanType = new ArrayList<>();
List scanRecipientHierarchyEntities =
scanRecipientHierarchyRepository.findScanRecipientHierarchyEntitiesByScanId(scanId);
@@ -62,11 +64,12 @@ private List checkScanTypeDescendents(String scanId, String scanType) {
List childScanTypes = emptyScanTypes.subList(parentScanTypeIndex + 1, emptyScanTypes.size());
childScanTypes.forEach(childScanType -> {
- log.info("Scan request [{}]: Encountered an empty scan type [{}].", scanId, childScanType);
+ log.info("Scan request [{}], trace ID [{}]: Encountered an empty scan type [{}].", scanId, traceId, childScanType);
emptyDescendentsForScanType.add(childScanType);
});
}
});
+
return emptyDescendentsForScanType;
}
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java
index 50db426f..d3f63335 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/RouteCompleteProcessorImpl.java
@@ -16,6 +16,7 @@ public class RouteCompleteProcessorImpl extends RouteCompleteProcessor {
private final ScanStatusService scanStatusService;
public RouteCompleteProcessorImpl(ScanStatusService scanStatusService) {
+ super();
this.scanStatusService = scanStatusService;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java
index f6031dff..9516d2c1 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java
@@ -10,6 +10,9 @@
import org.springframework.stereotype.Component;
import java.util.List;
+import java.util.stream.Collectors;
+
+import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.TRACE_ID;
@Slf4j
@Component
@@ -19,6 +22,7 @@ public class ScanDataImportParseMetaInfFileProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
MetaInfFileBO metaInfFileBO = exchange.getIn().getBody(MetaInfFileBO.class);
+ String traceId = (String) exchange.getProperty(TRACE_ID);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, metaInfFileBO.getScanId());
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, metaInfFileBO.getMessagingServiceId());
@@ -27,5 +31,14 @@ public void process(Exchange exchange) throws Exception {
List filesDetails = metaInfFileBO.getFiles();
exchange.getIn().setBody(filesDetails);
+
+ log.debug("Scan import request [{}]: Parsing the zip file, event broker: [{}], EMA Id: [{}], files: [{}], traceId: [{}]",
+ metaInfFileBO.getScanId(),
+ metaInfFileBO.getMessagingServiceId(),
+ metaInfFileBO.getEmaId(),
+ filesDetails.stream()
+ .map(MetaInfFileDetailsBO::getFileName)
+ .collect(Collectors.joining(", ")),
+ traceId);
}
}
\ No newline at end of file
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistFilePathsProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistFilePathsProcessor.java
index 75c6fd86..1dd1c19a 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistFilePathsProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistFilePathsProcessor.java
@@ -21,6 +21,7 @@
import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.IMPORT_ID;
import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCAN_ID;
import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCHEDULE_ID;
+import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.TRACE_ID;
@Slf4j
@Component
@@ -42,25 +43,29 @@ public ScanDataImportPersistFilePathsProcessor(ManualImportFilesService manualIm
@Override
@Transactional
public void process(Exchange exchange) throws Exception {
-
List files = (List) exchange.getIn().getBody();
+ String traceId = (String) exchange.getProperty(TRACE_ID);
+
Map properties = exchange.getIn().getHeaders();
- String scanId = (String) properties.get(SCAN_ID);
String scheduleId = (String) properties.get(SCHEDULE_ID);
+ String scanId = (String) properties.get(SCAN_ID);
String emaId = (String) properties.get(EVENT_MANAGEMENT_ID);
String importId = (String) exchange.getProperty(IMPORT_ID);
ManualImportDetailsEntity manualImportDetailsEntity = ManualImportDetailsEntity.builder()
.id(idGenerator.generateRandomUniqueId())
- .importId(importId)
.scheduleId(scheduleId)
- .emaId(emaId)
.scanId(scanId)
+ .traceId(traceId)
+ .emaId(emaId)
+ .importId(importId)
.build();
+
manualImportDetailsService.save(manualImportDetailsEntity);
- log.debug("saved manualImportDetailsEntity: {}", manualImportDetailsEntity);
+
+ log.debug("saved import details: {}", manualImportDetailsEntity);
List manualImportFilesEntityList = files.stream()
.map(file -> ManualImportFilesEntity.builder()
@@ -70,7 +75,9 @@ public void process(Exchange exchange) throws Exception {
.scanId(scanId)
.build())
.collect(Collectors.toList());
+
manualImportFilesService.saveAll(manualImportFilesEntityList);
- log.debug("saved manualImportFilesEntityList: {}", manualImportFilesEntityList);
+
+ log.debug("saved import files list: {}", manualImportFilesEntityList);
}
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessor.java
index 62605f57..49b3ca94 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessor.java
@@ -48,6 +48,7 @@ private void prepareAndSaveScanDetails(Exchange exchange) {
String messagingServiceId = (String) exchange.getIn().getHeader(RouteConstants.MESSAGING_SERVICE_ID);
String emaId = (String) exchange.getIn().getHeader(RouteConstants.EVENT_MANAGEMENT_ID);
String scanId = (String) exchange.getIn().getHeader(RouteConstants.SCAN_ID);
+ String traceId = (String) exchange.getIn().getHeader(RouteConstants.TRACE_ID);
String scheduleId = (String) exchange.getIn().getHeader(RouteConstants.SCHEDULE_ID);
String scanType = (String) exchange.getIn().getHeader(RouteConstants.SCAN_TYPE);
@@ -60,6 +61,7 @@ private void prepareAndSaveScanDetails(Exchange exchange) {
.id(scanId)
.messagingService(messagingServiceEntity)
.emaId(emaId)
+ .traceId(traceId)
.build();
List fileEntities = prepareFiles(scanEntity, files, scheduleId, scanId);
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPublishImportScanEventProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPublishImportScanEventProcessor.java
index da235027..3cb83602 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPublishImportScanEventProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPublishImportScanEventProcessor.java
@@ -22,7 +22,6 @@
public class ScanDataImportPublishImportScanEventProcessor implements Processor {
private final String orgId;
private final String runtimeAgentId;
-
private final ScanDataPublisher scanDataPublisher;
public ScanDataImportPublishImportScanEventProcessor(ScanDataPublisher scanDataPublisher,
@@ -36,13 +35,16 @@ public ScanDataImportPublishImportScanEventProcessor(ScanDataPublisher scanDataP
@Override
public void process(Exchange exchange) throws Exception {
+ Map topicDetails = new HashMap<>();
+ exchange.getIn().setHeader(RouteConstants.IS_DATA_IMPORT, true);
List files = (List) exchange.getIn().getBody();
- List scanTypes = files.stream().map(MetaInfFileDetailsBO::getDataEntityType).collect(Collectors.toUnmodifiableList());
- exchange.getIn().setHeader(RouteConstants.IS_DATA_IMPORT, true);
+ List scanTypes = files.stream()
+ .map(MetaInfFileDetailsBO::getDataEntityType)
+ .collect(Collectors.toUnmodifiableList());
- Map topicDetails = new HashMap<>();
+ String traceId = (String) exchange.getProperty(RouteConstants.TRACE_ID);
Map properties = exchange.getIn().getHeaders();
@@ -51,7 +53,7 @@ public void process(Exchange exchange) throws Exception {
Boolean isImportOp = (Boolean) properties.get(RouteConstants.IS_DATA_IMPORT);
ScanDataImportMessage importDataMessage =
- new ScanDataImportMessage(orgId, scanId, messagingServiceId, scanTypes, runtimeAgentId);
+ new ScanDataImportMessage(orgId, scanId, traceId, messagingServiceId, runtimeAgentId, scanTypes);
topicDetails.put("orgId", orgId);
topicDetails.put("runtimeAgentId", runtimeAgentId);
@@ -59,6 +61,8 @@ public void process(Exchange exchange) throws Exception {
topicDetails.put("scanId", scanId);
topicDetails.put("isImportOp", String.valueOf(isImportOp));
+ log.debug("Performing handshake with EP. Sending ScanDataImportMessage: {}", importDataMessage);
+
scanDataPublisher.sendScanData(importDataMessage, topicDetails);
}
}
\ No newline at end of file
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java
index 69683ea5..35c29209 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java
@@ -45,11 +45,11 @@ public void process(Exchange exchange) throws Exception {
String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID);
String scanId = (String) properties.get(RouteConstants.SCAN_ID);
+ String traceId = (String) properties.get(RouteConstants.TRACE_ID);
String scanType = (String) properties.get(RouteConstants.SCAN_TYPE);
Boolean isImportOp = (Boolean) properties.get(RouteConstants.IS_DATA_IMPORT);
- ScanDataMessage scanDataMessage =
- new ScanDataMessage(orgId, scanId, scanType, body, Instant.now().toString());
+ ScanDataMessage scanDataMessage = new ScanDataMessage(orgId, scanId, traceId, scanType, body, Instant.now().toString());
topicDetails.put("orgId", orgId);
topicDetails.put("runtimeAgentId", runtimeAgentId);
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java
index e0216bdc..7148f44c 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java
@@ -40,12 +40,12 @@ public void process(Exchange exchange) throws Exception {
Map properties = exchange.getIn().getHeaders();
ILoggingEvent event = (ILoggingEvent) exchange.getIn().getBody();
- String scanId = (String) exchange.getIn().getHeader(RouteConstants.SCAN_ID);
+ String scanId = (String) properties.get(RouteConstants.SCAN_ID);
+ String traceId = (String) properties.get(RouteConstants.TRACE_ID);
String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID);
- ScanLogMessage logDataMessage =
- new ScanLogMessage(orgId, scanId, event.getLevel().toString(),
- String.format("%s%s", event.getFormattedMessage(), "\n"), event.getTimeStamp());
+ ScanLogMessage logDataMessage = new ScanLogMessage(orgId, scanId, traceId, event.getLevel().toString(),
+ String.format("%s%s", event.getFormattedMessage(), "\n"), event.getTimeStamp());
topicDetails.put("orgId", orgId);
topicDetails.put("runtimeAgentId", runtimeAgentId);
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java
index 07273696..08fe0a21 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java
@@ -40,6 +40,7 @@ public void process(Exchange exchange) throws Exception {
String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID);
String scanId = (String) properties.get(RouteConstants.SCAN_ID);
+ String traceId = (String) properties.get(RouteConstants.TRACE_ID);
ScanStatus status = (ScanStatus) properties.get(RouteConstants.SCAN_STATUS);
String description = (String) properties.get(RouteConstants.SCAN_STATUS_DESC);
@@ -53,8 +54,7 @@ public void process(Exchange exchange) throws Exception {
topicDetails.put("scanType", scanType);
topicDetails.put("status", status.name());
- ScanStatusMessage generalStatusMessage = new
- ScanStatusMessage(orgId, scanId, status.name(), description, scanTypes);
+ ScanStatusMessage generalStatusMessage = new ScanStatusMessage(orgId, scanId, traceId, status.name(), description, scanTypes);
exchange.getIn().setHeader(RouteConstants.GENERAL_STATUS_MESSAGE, generalStatusMessage);
exchange.getIn().setHeader(RouteConstants.TOPIC_DETAILS, topicDetails);
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java
index ed1156bd..675d2aa7 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java
@@ -37,6 +37,7 @@ public void process(Exchange exchange) throws Exception {
String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID);
String scanId = (String) properties.get(RouteConstants.SCAN_ID);
+ String traceId = (String) properties.get(RouteConstants.TRACE_ID);
String scanType = (String) properties.get(RouteConstants.SCAN_TYPE);
ScanStatus status = (ScanStatus) properties.get(RouteConstants.SCAN_STATUS);
String description = (String) properties.get(RouteConstants.SCAN_STATUS_DESC);
@@ -48,8 +49,7 @@ public void process(Exchange exchange) throws Exception {
topicDetails.put("status", status.name());
topicDetails.put("scanDataType", scanType);
- ScanDataStatusMessage scanDataStatusMessage = new
- ScanDataStatusMessage(orgId, scanId, status.name(), description, scanType);
+ ScanDataStatusMessage scanDataStatusMessage = new ScanDataStatusMessage(orgId, scanId, traceId, status.name(), description, scanType);
exchange.getIn().setHeader(RouteConstants.SCAN_DATA_STATUS_MESSAGE, scanDataStatusMessage);
exchange.getIn().setHeader(RouteConstants.TOPIC_DETAILS, topicDetails);
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/manualimport/ManualImportDetailsEntity.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/manualimport/ManualImportDetailsEntity.java
index 1c3f462a..027ec2da 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/manualimport/ManualImportDetailsEntity.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/manualimport/ManualImportDetailsEntity.java
@@ -27,12 +27,15 @@ public class ManualImportDetailsEntity implements Serializable {
@Column(name = "SCHEDULE_ID")
private String scheduleId;
+ @Column(name = "SCAN_ID")
+ private String scanId;
+
+ @Column(name = "TRACE_ID")
+ private String traceId;
+
@Column(name = "EMA_ID")
private String emaId;
@Column(name = "IMPORT_ID")
private String importId;
-
- @Column(name = "SCAN_ID")
- private String scanId;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java
index 314e120f..b733b21b 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java
@@ -42,6 +42,9 @@ public class ScanEntity implements Serializable {
@Column(name = "EVENTMANAGEMENT_AGENT_ID", nullable = false)
private String emaId;
+ @Column(name = "TRACE_ID")
+ private String traceId;
+
@OneToMany(mappedBy = "scan", fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
private List scanTypes;
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java
index 4d8fae21..fe488a01 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/ScanStatusPersistenceRouteBuilder.java
@@ -8,6 +8,7 @@ public class ScanStatusPersistenceRouteBuilder extends AbstractRouteBuilder {
private final RouteCompleteProcessorImpl routeCompleteProcessor;
public ScanStatusPersistenceRouteBuilder(RouteCompleteProcessorImpl routeCompleteProcessor) {
+ super();
this.routeCompleteProcessor = routeCompleteProcessor;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/aggregation/FileParseAggregationStrategy.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/aggregation/FileParseAggregationStrategy.java
index 63361bb6..bf6a3f5b 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/aggregation/FileParseAggregationStrategy.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/aggregation/FileParseAggregationStrategy.java
@@ -18,6 +18,8 @@ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
oldExchange.getIn().getHeader(RouteConstants.SCAN_ID));
newExchange.getIn().setHeader(RouteConstants.SCHEDULE_ID,
oldExchange.getIn().getHeader(RouteConstants.SCHEDULE_ID));
+ newExchange.getIn().setHeader(RouteConstants.TRACE_ID,
+ oldExchange.getIn().getHeader(RouteConstants.TRACE_ID));
newExchange.getIn().setHeader(RouteConstants.SCAN_TYPE,
oldExchange.getIn().getHeader(RouteConstants.SCAN_TYPE));
newExchange.getIn().setHeader(RouteConstants.SCAN_STATUS,
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
index 446a1d63..2d778fd7 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/ep/exceptions/ClientException.java
@@ -11,6 +11,7 @@ public class ClientException extends RuntimeException {
private Map> exceptionStore;
ClientException(final String message, final Map> validationDetails) {
+ super();
this.message = message;
this.exceptionStore = validationDetails;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ImportRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ImportRouteBuilder.java
index 86c4bce5..3f0f3426 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ImportRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ImportRouteBuilder.java
@@ -7,6 +7,7 @@
import org.springframework.stereotype.Component;
import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.IMPORT_ID;
+import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.TRACE_ID;
@Component
@ConditionalOnExpression("${eventPortal.gateway.messaging.standalone} == false")
@@ -22,17 +23,18 @@ public void configure() {
.continued(true)
.end()
.setProperty(IMPORT_ID, header(IMPORT_ID))
+ .setProperty(TRACE_ID, header(TRACE_ID))
.setHeader(Exchange.FILE_NAME, simple("${header." + IMPORT_ID + "}.zip"))
.toD("file://data_collection/import/compressed_data_collection")
.to("direct:checkZipSizeAndUnzipFiles");
from("direct:continueParsingUnzippedFiles")
.routeId("continueParsingUnzippedFiles")
- .to("direct:parseMetaInfoAndSendOverAllImportStatus");
+ .to("direct:parseMetaInfoAndPerformHandShakeWithEP");
- from("direct:continueImportFiles")
- .routeId("continueImportFiles")
+ from("direct:continueImportingFiles")
+ .routeId("continueImportingFiles")
.to("direct:sendOverAllInProgressImportStatus")
.to("direct:parseAndStreamImportFiles");
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java
index d9e7173e..24baa28d 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportParseMetaInfFileRouteBuilder.java
@@ -1,5 +1,6 @@
package com.solace.maas.ep.event.management.agent.route.manualImport;
+import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.processor.ScanDataImportOverAllStatusProcessor;
import com.solace.maas.ep.event.management.agent.processor.ScanDataImportParseMetaInfFileProcessor;
import com.solace.maas.ep.event.management.agent.processor.ScanDataImportPersistFilePathsProcessor;
@@ -20,28 +21,30 @@
public class ScanDataImportParseMetaInfFileRouteBuilder extends RouteBuilder {
private final ScanDataImportParseMetaInfFileProcessor scanDataImportParseMetaInfFileProcessor;
- private final ScanDataImportOverAllStatusProcessor scanDataImportOverAllStatusProcessor;
+ private final ScanDataImportPersistFilePathsProcessor scanDataImportPersistFilePathsProcessor;
private final ScanDataImportPublishImportScanEventProcessor scanDataImportPublishImportScanEventProcessor;
+ private final ScanDataImportOverAllStatusProcessor scanDataImportOverAllStatusProcessor;
private final ScanDataImportPersistScanDataProcessor scanDataImportPersistScanDataProcessor;
- private final ScanDataImportPersistFilePathsProcessor scanDataImportPersistFilePathsProcessor;
public ScanDataImportParseMetaInfFileRouteBuilder(ScanDataImportParseMetaInfFileProcessor scanDataImportParseMetaInfFileProcessor,
- ScanDataImportOverAllStatusProcessor scanDataImportOverAllStatusProcessor,
+ ScanDataImportPersistFilePathsProcessor scanDataImportPersistFilePathsProcessor,
ScanDataImportPublishImportScanEventProcessor scanDataImportPublishImportScanEventProcessor,
- ScanDataImportPersistScanDataProcessor scanDataImportPersistScanDataProcessor,
- ScanDataImportPersistFilePathsProcessor scanDataImportPersistFilePathsProcessor) {
+ ScanDataImportOverAllStatusProcessor scanDataImportOverAllStatusProcessor,
+ ScanDataImportPersistScanDataProcessor scanDataImportPersistScanDataProcessor
+ ) {
+ super();
this.scanDataImportParseMetaInfFileProcessor = scanDataImportParseMetaInfFileProcessor;
- this.scanDataImportOverAllStatusProcessor = scanDataImportOverAllStatusProcessor;
+ this.scanDataImportPersistFilePathsProcessor = scanDataImportPersistFilePathsProcessor;
this.scanDataImportPublishImportScanEventProcessor = scanDataImportPublishImportScanEventProcessor;
+ this.scanDataImportOverAllStatusProcessor = scanDataImportOverAllStatusProcessor;
this.scanDataImportPersistScanDataProcessor = scanDataImportPersistScanDataProcessor;
- this.scanDataImportPersistFilePathsProcessor = scanDataImportPersistFilePathsProcessor;
}
@Override
public void configure() {
- from("direct:parseMetaInfoAndSendOverAllImportStatus")
- .routeId("parseMetaInfoAndSendOverAllImportStatus")
+ from("direct:parseMetaInfoAndPerformHandShakeWithEP")
+ .routeId("parseMetaInfoAndPerformHandShakeWithEP")
.onException(Exception.class)
.process(new ScanDataImportExceptionHandler())
.continued(true)
@@ -59,6 +62,8 @@ public void configure() {
from("direct:sendOverAllInProgressImportStatus")
.routeId("sendOverAllInProgressImportStatus")
.process(scanDataImportOverAllStatusProcessor)
+ .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: Starting scan data import process.")
.process(scanDataImportPersistScanDataProcessor)
.to("direct:overallScanStatusPublisher?block=false&failIfNoConsumers=false");
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java
index 92963f5f..c4127de5 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/manualImport/ScanDataImportStreamFilesRouteBuilder.java
@@ -1,7 +1,6 @@
package com.solace.maas.ep.event.management.agent.route.manualImport;
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
-import com.solace.maas.ep.event.management.agent.plugin.constants.ScanStatus;
import com.solace.maas.ep.event.management.agent.processor.ScanDataImportPersistScanFilesProcessor;
import com.solace.maas.ep.event.management.agent.processor.ScanDataImportStatusProcessor;
import com.solace.maas.ep.event.management.agent.route.ep.aggregation.FileParseAggregationStrategy;
@@ -18,11 +17,11 @@
public class ScanDataImportStreamFilesRouteBuilder extends RouteBuilder {
private final ScanDataImportStatusProcessor scanDataImportStatusProcessor;
-
private final ScanDataImportPersistScanFilesProcessor scanDataImportPersistScanFilesProcessor;
public ScanDataImportStreamFilesRouteBuilder(ScanDataImportStatusProcessor scanDataImportStatusProcessor,
ScanDataImportPersistScanFilesProcessor scanDataImportPersistScanFilesProcessor) {
+ super();
this.scanDataImportStatusProcessor = scanDataImportStatusProcessor;
this.scanDataImportPersistScanFilesProcessor = scanDataImportPersistScanFilesProcessor;
}
@@ -35,13 +34,15 @@ public void configure() throws Exception {
.split().body()
.streaming()
.process(scanDataImportStatusProcessor)
- .to("direct:perRouteScanStatusPublisher?block=false&failIfNoConsumers=false")
-
+ .to("direct:markRouteImportStatusInProgress?block=false&failIfNoConsumers=false")
.pollEnrich()
- .simple("file://data_collection/import/unzipped_data_collection/${header." + IMPORT_ID + "}?" +
- "fileName=${body.fileName}&noop=true&idempotent=false")
+ .simple("file://data_collection/import/unzipped_data_collection/${header." +
+ IMPORT_ID + "}?" + "fileName=${body.fileName}&noop=true&idempotent=false")
.aggregationStrategy(new FileParseAggregationStrategy())
.process(scanDataImportPersistScanFilesProcessor)
+ .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: " + "Streaming [${header." +
+ RouteConstants.SCAN_TYPE + "}] data contents to EP.")
.split().tokenize("\\n").streaming()
.to("direct:streamImportFiles")
.end();
@@ -61,8 +62,6 @@ public void configure() throws Exception {
from("direct:processEndOfFileImportStatus")
.routeId("processEndOfFileImportStatus")
.setHeader("FILE_IMPORTING_COMPLETE", constant(true))
- .to("direct:processScanStatusAsComplete")
- .log("Scan request [${header." + RouteConstants.SCAN_ID + "}]: The status of [${header."
- + RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.COMPLETE + "].");
+ .to("direct:markRouteImportStatusComplete?block=false&failIfNoConsumers=false");
}
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java
index 414f730c..0f011d1e 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/route/scan/ScanRouteBuilder.java
@@ -9,6 +9,7 @@ public class ScanRouteBuilder extends RouteBuilder {
private final StartScanProcessor startScanProcessor;
public ScanRouteBuilder(StartScanProcessor startScanProcessor) {
+ super();
this.startScanProcessor = startScanProcessor;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java
index 3a177a38..facb517d 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java
@@ -44,9 +44,11 @@ public ScanManager(MessagingServiceDelegateServiceImpl messagingServiceDelegateS
public String scan(ScanRequestBO scanRequestBO) {
String messagingServiceId = scanRequestBO.getMessagingServiceId();
String scanId = scanRequestBO.getScanId();
+ String traceId = scanRequestBO.getTraceId();
String groupId = UUID.randomUUID().toString();
MDC.put(RouteConstants.SCAN_ID, scanId);
+ MDC.put(RouteConstants.TRACE_ID, traceId);
MDC.put(RouteConstants.SCHEDULE_ID, groupId);
MDC.put(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
@@ -95,7 +97,7 @@ public String scan(ScanRequestBO scanRequestBO) {
)
.collect(Collectors.toList()).stream().flatMap(List::stream).collect(Collectors.toList());
- return scanService.singleScan(routes, groupId, scanId, messagingServiceEntity, runtimeAgentId);
+ return scanService.singleScan(routes, groupId, scanId, traceId, messagingServiceEntity, runtimeAgentId);
}
private MessagingServiceEntity retrieveMessagingServiceEntity(String messagingServiceId) {
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ImportRequestBO.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ImportRequestBO.java
index 6792ff85..12e8a3af 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ImportRequestBO.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ImportRequestBO.java
@@ -16,4 +16,6 @@
public class ImportRequestBO extends AbstractBaseBO {
private MultipartFile dataFile;
+
+ private String traceId;
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java
index 60302bdd..ab35eacf 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java
@@ -21,6 +21,8 @@ public class ScanRequestBO extends AbstractBaseBO {
private String scanId;
+ private String traceId;
+
private List scanTypes;
private List destinations;
@@ -29,6 +31,7 @@ public class ScanRequestBO extends AbstractBaseBO {
public String toString() {
return "{ messaging service id:[" + messagingServiceId + ']' +
", scan id: [" + scanId + ']' +
+ ", trace id: " + traceId +
", scan types: " + scanTypes +
", destinations: " + destinations +
" }";
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
index a736ca8f..4d0589bf 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
@@ -5,6 +5,7 @@
import com.solace.maas.ep.event.management.agent.scanManager.model.ZipRequestBO;
import com.solace.maas.ep.event.management.agent.service.ImportService;
import lombok.extern.slf4j.Slf4j;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
@@ -39,8 +40,10 @@ public DataImportControllerImpl(ImportService importService) {
@PostMapping(value = "/import")
public ResponseEntity read(@RequestParam("file") MultipartFile file) {
try {
+ String traceId = MDC.get("traceId");
ImportRequestBO importRequestBO = ImportRequestBO.builder()
.dataFile(file)
+ .traceId(traceId)
.build();
log.info("Received import request for data file: {}", importRequestBO.getDataFile().getOriginalFilename());
@@ -59,6 +62,7 @@ public ResponseEntity read(@RequestParam("file") MultipartFile file) {
@Override
@GetMapping(value = "/export/{scanId}/zip")
+ @SuppressWarnings("PMD.CloseResource")
public ResponseEntity zip(@PathVariable(value = "scanId") String scanId) {
try {
ZipRequestBO zipRequestBO = ZipRequestBO.builder()
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
index bf757d3a..b77282af 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ImportService.java
@@ -19,10 +19,10 @@
import org.springframework.stereotype.Service;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -31,8 +31,6 @@
import java.util.UUID;
import java.util.stream.Collectors;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.IMPORT_ID;
-
@Slf4j
@Service
public class ImportService {
@@ -50,31 +48,35 @@ public ImportService(ProducerTemplate producerTemplate, DataCollectionFileServic
this.eventPortalProperties = eventPortalProperties;
}
+ @SuppressWarnings("PMD.CloseResource")
public void importData(ImportRequestBO importRequestBO) throws IOException {
+ String importId = UUID.randomUUID().toString();
+ String traceId = importRequestBO.getTraceId();
+
boolean isEMAStandalone = eventPortalProperties.getGateway().getMessaging().isStandalone();
InputStream importStream = importRequestBO.getDataFile().getInputStream();
- String importId = UUID.randomUUID().toString();
if (isEMAStandalone) {
throw new FileUploadException("Scan data could not be imported in standalone mode.");
} else {
- initiateImport(importStream, importId);
+ initiateImport(importStream, importId, traceId);
}
}
- private void initiateImport(InputStream files, String importId) {
+ private void initiateImport(InputStream files, String importId, String traceId) {
RouteEntity route = RouteEntity.builder()
.id("importScanData")
.active(true)
.build();
producerTemplate.asyncSend("seda:" + route.getId(), exchange -> {
- exchange.getIn().setHeader(IMPORT_ID, importId);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId);
+ exchange.getIn().setHeader(RouteConstants.IMPORT_ID, importId);
exchange.getIn().setBody(files);
});
}
- public InputStream zip(ZipRequestBO zipRequestBO) throws FileNotFoundException {
+ public InputStream zip(ZipRequestBO zipRequestBO) throws IOException {
String scanId = zipRequestBO.getScanId();
List files = dataCollectionFileService.findAllByScanId(scanId);
@@ -107,7 +109,7 @@ public InputStream zip(ZipRequestBO zipRequestBO) throws FileNotFoundException {
GenericFile> downloadedGenericFile = exchange.getIn().getBody(GenericFile.class);
File downloadedFile = (File) downloadedGenericFile.getFile();
- return new FileInputStream(downloadedFile);
+ return Files.newInputStream(Paths.get(downloadedFile.toURI()));
}
private MetaInfFileBO prepareMetaInfJson(List files, String messagingServiceId,
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
index 7d9281e2..f7197f12 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java
@@ -38,9 +38,6 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.MESSAGING_SERVICE_ID;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCHEDULE_ID;
-
/**
* Responsible for initiating and managing Messaging Service scans.
*/
@@ -137,9 +134,9 @@ public ScanService(ScanRepository repository,
* @param routeBundles - see description above
* @return The id of the scan.
*/
- public String singleScan(List routeBundles, String groupId, String scanId,
+ public String singleScan(List routeBundles, String groupId, String scanId, String traceId,
MessagingServiceEntity messagingServiceEntity, String runtimeAgentId) {
- log.info("Scan request [{}]: Starting a single scan.", scanId);
+ log.info("Scan request [{}], trace ID [{}]: Starting a single scan.", scanId, traceId);
List scanTypes = parseRouteBundle(routeBundles, new ArrayList<>());
@@ -148,17 +145,17 @@ public String singleScan(List routeBundles, String groupId, String
save(routeBundleHierarchy, scanId);
- log.info("Scan request [{}]: Total of {} scan types to be retrieved: [{}]",
- scanId, scanTypes.size(), StringUtils.join(scanTypes, ", "));
+ log.info("Scan request [{}], trace ID [{}]: Total of {} scan types to be retrieved: [{}].",
+ scanId, traceId, scanTypes.size(), StringUtils.join(scanTypes, ", "));
- sendScanStatus(scanId, groupId, routeBundles.stream().findFirst().orElseThrow().getMessagingServiceId(),
+ sendScanStatus(groupId, scanId, traceId, routeBundles.stream().findFirst().orElseThrow().getMessagingServiceId(),
StringUtils.join(scanTypes, ","), ScanStatus.IN_PROGRESS);
log.trace("RouteBundles to be processed: {}", routeBundles);
String scanEntityId = Objects.requireNonNullElseGet(scanId, () -> UUID.randomUUID().toString());
- ScanEntity returnedScanEntity = setupScan(scanEntityId, messagingServiceEntity, runtimeAgentId);
+ ScanEntity returnedScanEntity = setupScan(scanEntityId, traceId, messagingServiceEntity, runtimeAgentId);
for (RouteBundle routeBundle : routeBundles) {
log.trace("Processing RouteBundles: {}", routeBundle);
@@ -168,15 +165,15 @@ public String singleScan(List routeBundles, String groupId, String
updateScan(route, routeBundle, returnedScanEntity);
- scanAsync(groupId, scanEntityId, route, routeBundle.getMessagingServiceId());
+ scanAsync(groupId, scanEntityId, traceId, route, routeBundle.getMessagingServiceId());
}
return scanId;
}
@Transactional
- protected ScanEntity setupScan(String scanId, MessagingServiceEntity messagingServiceEntity, String emaId) {
- return saveScanEntity(scanId, messagingServiceEntity, emaId);
+ protected ScanEntity setupScan(String scanId, String traceId, MessagingServiceEntity messagingServiceEntity, String emaId) {
+ return saveScanEntity(scanId, traceId, messagingServiceEntity, emaId);
}
@Transactional
@@ -210,10 +207,10 @@ protected void updateScan(RouteEntity route, RouteBundle routeBundle, ScanEntity
setupRecipientsForScan(scanEntity, routeBundle);
}
- private ScanEntity saveScanEntity(String scanId, MessagingServiceEntity messagingServiceEntity,
- String emaId) {
+ private ScanEntity saveScanEntity(String scanId, String traceId, MessagingServiceEntity messagingServiceEntity, String emaId) {
ScanEntity scan = ScanEntity.builder()
.id(scanId)
+ .traceId(traceId)
.messagingService(messagingServiceEntity)
.emaId(emaId)
.build();
@@ -244,16 +241,6 @@ public Optional findById(String scanId) {
return repository.findById(scanId);
}
- protected Exchange scan(String groupId, String scanId, RouteEntity route,
- String messagingServiceId) {
- return producerTemplate.send("seda:" + route.getId(), exchange -> {
- // Need to set headers to let the Route have access to the Scan ID, Group ID, and Messaging Service ID.
- exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
- exchange.getIn().setHeader(SCHEDULE_ID, groupId);
- exchange.getIn().setHeader(MESSAGING_SERVICE_ID, messagingServiceId);
- });
- }
-
/**
* Sends the initial scan status message to signal the start of Messaging Service scan.
*
@@ -263,11 +250,12 @@ protected Exchange scan(String groupId, String scanId, RouteEntity route,
* @param scanTypes The scan types included in the scan request.
* @param status The status of scan.
*/
- public void sendScanStatus(String scanId, String groupId, String messagingServiceId, String scanTypes,
+ public void sendScanStatus(String groupId, String scanId, String traceId, String messagingServiceId, String scanTypes,
ScanStatus status) {
producerTemplate.send("direct:overallScanStatusPublisher?block=false&failIfNoConsumers=false", exchange -> {
- exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId);
+ exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId);
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, scanTypes);
exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, status);
@@ -275,12 +263,14 @@ public void sendScanStatus(String scanId, String groupId, String messagingServic
});
}
- protected CompletableFuture scanAsync(String groupId, String scanId, RouteEntity route, String messagingServiceId) {
+ protected CompletableFuture scanAsync(String groupId, String scanId, String traceId, RouteEntity route, String messagingServiceId) {
return producerTemplate.asyncSend("seda:" + route.getId(), exchange -> {
// Need to set headers to let the Route have access to the Scan ID, Group ID, and Messaging Service ID.
+ exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
- exchange.getIn().setHeader(SCHEDULE_ID, groupId);
- exchange.getIn().setHeader(MESSAGING_SERVICE_ID, messagingServiceId);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId);
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
+ exchange.getIn().setHeader(RouteConstants.SCAN_STATUS_DESC, "");
exchange.getIn().setHeader(SchedulerConstants.SCHEDULER_TERMINATION_TIMER, true);
exchange.getIn().setHeader(SchedulerConstants.SCHEDULER_TYPE, SchedulerType.INTERVAL.name());
@@ -289,8 +279,9 @@ protected CompletableFuture scanAsync(String groupId, String scanId, R
exchange.getIn().setHeader(SchedulerConstants.SCHEDULER_INTERVAL, 5000);
exchange.getIn().setHeader(SchedulerConstants.SCHEDULER_REPEAT_COUNT, 0);
- MDC.put(RouteConstants.SCAN_ID, scanId);
MDC.put(RouteConstants.SCHEDULE_ID, groupId);
+ MDC.put(RouteConstants.SCAN_ID, scanId);
+ MDC.put(RouteConstants.TRACE_ID, traceId);
MDC.put(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
}).whenComplete((exchange, exception) -> {
if (exception != null) {
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
index fa03b666..0acb3a99 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java
@@ -3,7 +3,6 @@
import com.solace.maas.ep.common.messages.ScanCommandMessage;
import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration;
import com.solace.maas.ep.event.management.agent.scanManager.ScanManager;
-import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanRequestMapper;
import com.solace.maas.ep.event.management.agent.scanManager.model.ScanRequestBO;
import lombok.extern.slf4j.Slf4j;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
@@ -23,14 +22,10 @@ public class ScanCommandMessageHandler extends SolaceMessageHandler", solaceSubscriber);
this.scanManager = scanManager;
- this.scanRequestMapper = scanRequestMapper;
}
@Override
@@ -40,8 +35,8 @@ public void receiveMessage(String destinationName, ScanCommandMessage message) {
List destinations = new ArrayList<>();
List entityTypes = new ArrayList<>();
- log.debug("Received scan command message: {} for messaging service: {}",
- message, message.getMessagingServiceId());
+ log.debug("Received scan command message: {} for event broker: {}, traceId: {}",
+ message, message.getMessagingServiceId(), message.getTraceId());
message.getScanTypes().forEach(scanType -> entityTypes.add(scanType.name()));
@@ -61,11 +56,13 @@ public void receiveMessage(String destinationName, ScanCommandMessage message) {
ScanRequestBO scanRequestBO = ScanRequestBO.builder()
.messagingServiceId(message.getMessagingServiceId())
.scanId(!StringUtils.isEmpty(message.getScanId()) ? message.getScanId() : UUID.randomUUID().toString())
+ .traceId(message.getTraceId())
.scanTypes(entityTypes)
.destinations(scanRequestDestinations)
.build();
log.info("Received scan request {}. Request details: {}", scanRequestBO.getScanId(), scanRequestBO);
+
scanManager.scan(scanRequestBO);
}
}
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java
index 7093c5fb..e96ae696 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java
@@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.mop.EnumDeserializer;
import com.solace.maas.ep.event.management.agent.plugin.mop.MOPConstants;
import com.solace.maas.ep.event.management.agent.plugin.mop.MOPMessage;
@@ -16,6 +17,7 @@
import com.solace.messaging.receiver.InboundMessage;
import com.solace.messaging.receiver.MessageReceiver;
import lombok.extern.slf4j.Slf4j;
+import org.jboss.logging.MDC;
import java.util.HashMap;
import java.util.Map;
@@ -23,10 +25,8 @@
@Slf4j
public abstract class SolaceMessageHandler implements MessageReceiver.MessageHandler {
- private String topicString;
- private static ObjectMapper objectMapper = new ObjectMapper();
private static final SimpleModule module = new SimpleModule();
- private final Map cachedJSONDecoders = new HashMap();
+ private static final ObjectMapper objectMapper = new ObjectMapper();
static {
// Register all the enums we expect to cross versions and allow them to be mapped to null instead of throwing an exception if unknown
@@ -41,6 +41,9 @@ public abstract class SolaceMessageHandler implements Mess
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
+ private final Map cachedJSONDecoders = new HashMap();
+ private final String topicString;
+
public SolaceMessageHandler(String topicString, SolaceSubscriber solaceSubscriber) {
this.topicString = topicString;
solaceSubscriber.registerMessageHandler(this);
@@ -54,6 +57,7 @@ public String getTopicString() {
public void onMessage(InboundMessage inboundMessage) {
String messageAsString = inboundMessage.getPayloadAsString();
String mopMessageSubclass = inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER);
+
try {
Class messageClass = cachedJSONDecoders.get(mopMessageSubclass);
T message = null;
@@ -63,6 +67,20 @@ public void onMessage(InboundMessage inboundMessage) {
cachedJSONDecoders.put(mopMessageSubclass, messageClass);
}
+ String receivedClassName = messageClass.getSimpleName();
+
+ if ("ScanCommandMessage" .equals(receivedClassName) || "ScanDataImportMessage" .equals(receivedClassName)) {
+ Map map = objectMapper.readValue(messageAsString, Map.class);
+ String scanId = (String) map.get("scanId");
+ String traceId = (String) map.get("traceId");
+ String messagingServiceId = (String) map.get("messagingServiceId");
+
+ MDC.clear();
+ MDC.put(RouteConstants.SCAN_ID, scanId);
+ MDC.put(RouteConstants.TRACE_ID, traceId);
+ MDC.put(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
+ }
+
message = (T) objectMapper.readValue(messageAsString, messageClass);
log.trace("onMessage: {}\n{}", messageClass, messageAsString);
log.trace("onMessage: {} {}", inboundMessage.getDestinationName(), message);
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/StartImportScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/StartImportScanCommandMessageHandler.java
index ecf8f44b..b0036b7d 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/StartImportScanCommandMessageHandler.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/StartImportScanCommandMessageHandler.java
@@ -2,12 +2,14 @@
import com.solace.maas.ep.common.messages.ScanDataImportMessage;
import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration;
+import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.repository.model.manualimport.ManualImportDetailsEntity;
import com.solace.maas.ep.event.management.agent.repository.model.manualimport.ManualImportFilesEntity;
import com.solace.maas.ep.event.management.agent.scanManager.model.MetaInfFileDetailsBO;
import com.solace.maas.ep.event.management.agent.service.ManualImportDetailsService;
import com.solace.maas.ep.event.management.agent.service.ManualImportFilesService;
import lombok.extern.slf4j.Slf4j;
+import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import org.apache.camel.ProducerTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
@@ -15,13 +17,6 @@
import java.util.List;
import java.util.stream.Collectors;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.EVENT_MANAGEMENT_ID;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.IMPORT_ID;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.MESSAGING_SERVICE_ID;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCAN_ID;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCAN_TYPE;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCHEDULE_ID;
-
@Slf4j
@Component
@ConditionalOnProperty(name = "event-portal.gateway.messaging.standalone", havingValue = "false")
@@ -44,15 +39,19 @@ public StartImportScanCommandMessageHandler(
}
@Override
- public void receiveMessage(String destinationName, ScanDataImportMessage message) {
- log.debug("Received startImportScan command message: {} for messaging service: {}",
- message, message.getMessagingServiceId());
-
- String scanId = message.getScanId();
+ public void receiveMessage(String destinationName, ScanDataImportMessage scanDataImportMessage) {
+ String scanId = scanDataImportMessage.getScanId();
+ String traceId = scanDataImportMessage.getTraceId();
+ String messagingServiceId = scanDataImportMessage.getMessagingServiceId();
+ String scanTypes = String.join(",", scanDataImportMessage.getScanTypes());
- String scanTypes = String.join(",", message.getScanTypes());
List manualImportFilesEntityList = manualImportFilesService.getAllByScanId(scanId);
+ log.trace("Received startImportScan command message: {} for event broker: {}, traceId: {}",
+ scanDataImportMessage, messagingServiceId, traceId);
+
+ log.info("Scan import request [{}], trace ID [{}]: Handshake with EP is complete.", scanId, traceId);
+
if (manualImportFilesEntityList.isEmpty()) {
throw new RuntimeException(String.format("can't retrieve any manualImportFiles for scanId: %s", scanId));
}
@@ -67,13 +66,18 @@ public void receiveMessage(String destinationName, ScanDataImportMessage message
.build())
.collect(Collectors.toList());
- producerTemplate.send("direct:continueImportFiles", exchange -> {
- exchange.getIn().setHeader(SCAN_ID, scanId);
- exchange.getIn().setHeader(SCHEDULE_ID, manualImportDetailsEntity.getScheduleId());
- exchange.getIn().setHeader(EVENT_MANAGEMENT_ID, manualImportDetailsEntity.getEmaId());
- exchange.getIn().setHeader(IMPORT_ID, manualImportDetailsEntity.getImportId());
- exchange.getIn().setHeader(MESSAGING_SERVICE_ID, message.getMessagingServiceId());
- exchange.getIn().setHeader(SCAN_TYPE, scanTypes);
+ log.info("Scan import request [{}], trace ID [{}]: Total of {} scan types to be imported: [{}].",
+ scanId, traceId, scanDataImportMessage.getScanTypes().size(), StringUtils.join(scanDataImportMessage.getScanTypes(), ", "));
+
+ producerTemplate.send("direct:continueImportingFiles", exchange -> {
+ exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId);
+ exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, manualImportDetailsEntity.getScheduleId());
+ exchange.getIn().setHeader(RouteConstants.EVENT_MANAGEMENT_ID, manualImportDetailsEntity.getEmaId());
+ exchange.getIn().setHeader(RouteConstants.IMPORT_ID, manualImportDetailsEntity.getImportId());
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId);
+ exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, scanTypes);
+
exchange.getIn().setBody(metaInfFileDetailsBOList);
});
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java
index a39d4728..41b45aa6 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppenderTests.java
@@ -5,8 +5,8 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import com.solace.maas.ep.event.management.agent.TestConfig;
-import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity;
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
+import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity;
import lombok.SneakyThrows;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
@@ -42,7 +42,7 @@ public void testStreamingAppender() {
ILoggingEvent event = new LoggingEvent(null, logger, Level.DEBUG,
"test message", new Throwable("throwable message"), null);
- RouteEntity route = RouteEntity.builder()
+ RouteEntity.builder()
.id("seda:scanLogsPublisher")
.active(true)
.build();
@@ -50,6 +50,7 @@ public void testStreamingAppender() {
streamingAppender.setStandalone(false);
MDC.put(RouteConstants.SCAN_ID, "12345");
+ MDC.put(RouteConstants.TRACE_ID, "trace-12345");
MDC.put(RouteConstants.SCAN_TYPE, "topicListing");
MDC.put(RouteConstants.SCHEDULE_ID, "groupId");
MDC.put(RouteConstants.MESSAGING_SERVICE_ID, "messagingServiceId");
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java
index b4f01399..c0bf824e 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/delegate/ScanDataPublisherDelegateImplTests.java
@@ -20,7 +20,7 @@ public class ScanDataPublisherDelegateImplTests {
@InjectMocks
private ScanDataPublisherDelegateImpl scanDataPublisherDelegate;
- private List destinations = List.of(
+ private final List destinations = List.of(
RouteBundle.builder()
.destinations(List.of())
.recipients(List.of())
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java
index f1025b69..225af315 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/DataPublisherRouteBuilderTests.java
@@ -61,20 +61,21 @@ public static List generateTestData() {
@Test
public void testMockRoute() throws Exception {
- DirectVmEndpoint ep = new DirectVmEndpoint("scanStatusPublisher", null);
- camelContext.addEndpoint("direct:scanStatusPublisher", ep);
+ try (DirectVmEndpoint ep = new DirectVmEndpoint("scanStatusPublisher", null)) {
+ camelContext.addEndpoint("direct:scanStatusPublisher", ep);
- AdviceWith.adviceWith(camelContext, "dataPublisherRoute",
- route -> {
- route.replaceFromWith("direct:dataPublisherRoute");
- route.weaveAddLast().to("mock:direct:result");
- });
+ AdviceWith.adviceWith(camelContext, "dataPublisherRoute",
+ route -> {
+ route.replaceFromWith("direct:dataPublisherRoute");
+ route.weaveAddLast().to("mock:direct:result");
+ });
- mockResult.expectedMessageCount(1);
+ mockResult.expectedMessageCount(1);
- producerTemplate.sendBody("direct:dataPublisherRoute", null);
+ producerTemplate.sendBody("direct:dataPublisherRoute", null);
- mockResult.assertIsSatisfied();
+ mockResult.assertIsSatisfied();
+ }
}
@AllArgsConstructor
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportParseMetaInfFileRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportParseMetaInfFileRouteBuilderTests.java
index 2ea86513..ddd31ba8 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportParseMetaInfFileRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportParseMetaInfFileRouteBuilderTests.java
@@ -55,22 +55,23 @@ public class ScanDataImportParseMetaInfFileRouteBuilderTests {
@Test
@SneakyThrows
- public void testMockParseMetaInfoAndSendOverAllImportStatusRoute() {
+ public void testMockParseMetaInfoAndPerformHandShakeWithEP() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "traceId");
+ exchange.getIn().setHeader("CamelFileName", "META_INF.json");
+ exchange.getIn().setBody(getMetaInfJson());
- AdviceWith.adviceWith(camelContext, "parseMetaInfoAndSendOverAllImportStatus",
+ AdviceWith.adviceWith(camelContext, "parseMetaInfoAndPerformHandShakeWithEP",
route -> {
route.weaveByType(PollEnrichDefinition.class).replace().process(exchange1 -> {
- exchange1.getIn().setHeader("CamelFileName", "META_INF.json");
- exchange1.getIn().setBody(getMetaInfJson());
});
route.weaveAddLast().to("mock:direct:mockParseMetaInfoResult");
});
mockParseMetaInfoResult.expectedMessageCount(1);
- producerTemplate.send("direct:parseMetaInfoAndSendOverAllImportStatus", exchange);
+ producerTemplate.send("direct:parseMetaInfoAndPerformHandShakeWithEP", exchange);
mockParseMetaInfoResult.assertIsSatisfied();
}
@@ -111,8 +112,8 @@ public static RoutesBuilder createRouteBuilder() {
= mock(ScanDataImportPersistFilePathsProcessor.class);
return new ScanDataImportParseMetaInfFileRouteBuilder(scanDataImportParseMetaInfFileProcessor,
- scanDataImportOverAllStatusProcessor, scanDataImportPublishProcessor,
- scanDataImportPersistScanDataProcessor, scanDataImportPersistFilePathsProcessor);
+ scanDataImportPersistFilePathsProcessor, scanDataImportPublishProcessor,
+ scanDataImportOverAllStatusProcessor, scanDataImportPersistScanDataProcessor);
}
public static String getMetaInfJson() throws JSONException {
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java
index a77f6977..ee7dbb78 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportRouteBuilderTests.java
@@ -48,14 +48,12 @@ public class ScanDataImportRouteBuilderTests {
private MockEndpoint mockResult;
private static byte[] getZippedText(String entryName) throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("TEXT" .getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream);
- try {
+
+ try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("TEXT" .getBytes(StandardCharsets.UTF_8));
+ ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream)) {
zipOutputStream.putNextEntry(new ZipEntry(entryName));
IOHelper.copy(byteArrayInputStream, zipOutputStream);
- } finally {
- IOHelper.close(byteArrayInputStream, zipOutputStream);
}
return byteArrayOutputStream.toByteArray();
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportStreamFilesRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportStreamFilesRouteBuilderTests.java
index 9d55fa8f..49a4977d 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportStreamFilesRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataImportStreamFilesRouteBuilderTests.java
@@ -28,7 +28,6 @@
import java.util.List;
import java.util.UUID;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.IMPORT_ID;
import static org.mockito.Mockito.mock;
@CamelSpringBootTest
@@ -64,14 +63,14 @@ public void testMockParseAndStreamImportFilesRoute() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
- exchange.getIn().setHeader(IMPORT_ID, UUID.randomUUID().toString());
+ exchange.getIn().setHeader(RouteConstants.IMPORT_ID, UUID.randomUUID().toString());
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
exchange.getIn().setBody(files);
AdviceWith.adviceWith(camelContext, "parseAndStreamImportFiles",
route -> {
- route.weaveByToUri("direct:perRouteScanStatusPublisher?block=false&failIfNoConsumers=false")
- .replace().to("mock:perRouteScanStatusPublisher");
+ route.weaveByToUri("direct:markRouteImportStatusInProgress?block=false&failIfNoConsumers=false")
+ .replace().to("mock:markRouteImportStatusInProgress");
route.weaveByType(PollEnrichDefinition.class).replace().process(exchange1 ->
exchange1.getIn().setHeader("CamelFileName", "topicListing.json"));
route.weaveByToUri("direct:streamImportFiles").replace().to("mock:streamImportFiles");
@@ -89,7 +88,7 @@ public void testMockStreamImportFilesRoute() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
- exchange.getIn().setHeader(IMPORT_ID, UUID.randomUUID().toString());
+ exchange.getIn().setHeader(RouteConstants.IMPORT_ID, UUID.randomUUID().toString());
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
exchange.getIn().setHeader(Exchange.SPLIT_COMPLETE, true);
exchange.getIn().setBody("test data");
@@ -112,13 +111,14 @@ public void testMockProcessEndOfFileImportStatusRoute() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
- exchange.getIn().setHeader(IMPORT_ID, UUID.randomUUID().toString());
+ exchange.getIn().setHeader(RouteConstants.IMPORT_ID, UUID.randomUUID().toString());
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
exchange.getIn().setBody("test data");
AdviceWith.adviceWith(camelContext, "processEndOfFileImportStatus",
route -> {
- route.weaveByToUri("direct:processScanStatusAsComplete").replace().to("mock:processScanStatusAsComplete");
+ route.weaveByToUri("direct:markRouteImportStatusComplete?block=false&failIfNoConsumers=false")
+ .replace().to("mock:markRouteImportStatusComplete");
route.weaveAddLast().to("mock:direct:processEndOfFileImportStatusResult");
});
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java
index aa93df00..5328bb75 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java
@@ -65,6 +65,7 @@ public void testMockRoute() throws Exception {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "traceId");
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
exchange.getIn().setHeader(RouteConstants.TOPIC, "test/ep/v1");
@@ -84,8 +85,13 @@ public void testMockRoute() throws Exception {
@Test
public void testScanLogMessageMOPProtocol() {
- ScanLogMessage scanLogMessage = new ScanLogMessage("orgId", "scanId", "level",
+ ScanLogMessage scanLogMessage = new ScanLogMessage(
+ "orgId",
+ "scanId",
+ "traceId",
+ "level",
"log", Instant.now().toEpochMilli());
+
assertThat(scanLogMessage.getMopProtocol()).isEqualTo(MOPProtocol.scanDataControl);
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java
new file mode 100644
index 00000000..6a5fa593
--- /dev/null
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java
@@ -0,0 +1,152 @@
+package com.solace.maas.ep.event.management.agent.plugin.route.handler;
+
+import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
+import com.solace.maas.ep.event.management.agent.plugin.constants.ScanStatus;
+import com.solace.maas.ep.event.management.agent.plugin.route.handler.base.ScanStatusMarkerAndLoggerRouteBuilder;
+import lombok.SneakyThrows;
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.AdviceWith;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.test.context.ActiveProfiles;
+
+@CamelSpringBootTest
+@EnableAutoConfiguration
+@SpringBootTest(
+ properties = {"camel.springboot.name=routeHandlerTest"}
+)
+@ActiveProfiles("TEST")
+public class ScanStatusMarkerAndLoggerRouteBuilderTests {
+
+ @Autowired
+ private ProducerTemplate producerTemplate;
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @EndpointInject("mock:direct:mockMarkRouteScanStatusInProgress")
+ private MockEndpoint mockMarkRouteScanStatusInProgressResult;
+
+ @EndpointInject("mock:direct:mockMarkRouteScanStatusComplete")
+ private MockEndpoint mockMarkRouteScanStatusCompleteResult;
+
+ @EndpointInject("mock:direct:mockMarkRouteImportStatusInProgress")
+ private MockEndpoint mockMarkRouteImportStatusInProgressResult;
+
+ @EndpointInject("mock:direct:mockMarkRouteImportStatusComplete")
+ private MockEndpoint mockMarkRouteImportStatusCompleteResult;
+
+
+ @Test
+ @SneakyThrows
+ public void testMarkRouteScanStatusInProgress() {
+ Exchange exchange = new DefaultExchange(camelContext);
+
+ exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
+ exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
+ exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, ScanStatus.IN_PROGRESS);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "1234");
+
+ AdviceWith.adviceWith(camelContext, "markRouteScanStatusInProgress",
+ route -> {
+ route.replaceFromWith("direct:markRouteScanStatusInProgress");
+ route.weaveAddLast().to("mock:direct:mockMarkRouteScanStatusInProgress");
+ });
+
+ mockMarkRouteScanStatusInProgressResult.expectedMessageCount(1);
+ producerTemplate.send("direct:markRouteScanStatusInProgress", exchange);
+ mockMarkRouteScanStatusInProgressResult.assertIsSatisfied();
+ }
+
+ @Test
+ @SneakyThrows
+ public void testMarkRouteScanStatusComplete() {
+ Exchange exchange = new DefaultExchange(camelContext);
+
+ exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
+ exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
+ exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, ScanStatus.COMPLETE);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "1234");
+
+ AdviceWith.adviceWith(camelContext, "markRouteScanStatusComplete",
+ route -> {
+ route.replaceFromWith("direct:markRouteScanStatusComplete");
+ route.weaveByToUri("direct:processScanStatusAsComplete?block=false&failIfNoConsumers=false")
+ .replace().to("mock:processScanStatusAsComplete");
+ route.weaveAddLast().to("mock:direct:mockMarkRouteScanStatusComplete");
+ });
+
+ mockMarkRouteScanStatusCompleteResult.expectedMessageCount(1);
+ producerTemplate.send("direct:markRouteScanStatusComplete", exchange);
+ mockMarkRouteScanStatusCompleteResult.assertIsSatisfied();
+ }
+
+ @Test
+ @SneakyThrows
+ public void testMarkRouteImportStatusInProgress() {
+ Exchange exchange = new DefaultExchange(camelContext);
+
+ exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
+ exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
+ exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, ScanStatus.IN_PROGRESS);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "1234");
+
+ AdviceWith.adviceWith(camelContext, "markRouteImportStatusInProgress",
+ route -> {
+ route.replaceFromWith("direct:markRouteImportStatusInProgress");
+ route.weaveAddLast().to("mock:direct:mockMarkRouteImportStatusInProgress");
+ });
+
+ mockMarkRouteImportStatusInProgressResult.expectedMessageCount(1);
+ producerTemplate.send("direct:markRouteImportStatusInProgress", exchange);
+ mockMarkRouteImportStatusInProgressResult.assertIsSatisfied();
+ }
+
+ @Test
+ @SneakyThrows
+ public void testMarkRouteImportStatusComplete() {
+ Exchange exchange = new DefaultExchange(camelContext);
+
+ exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
+ exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
+ exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, ScanStatus.COMPLETE);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "1234");
+
+ AdviceWith.adviceWith(camelContext, "markRouteImportStatusComplete",
+ route -> {
+ route.replaceFromWith("direct:markRouteImportStatusComplete");
+ route.weaveByToUri("direct:processScanStatusAsComplete?block=false&failIfNoConsumers=false")
+ .replace().to("mock:processScanStatusAsComplete");
+ route.weaveAddLast().to("mock:direct:mockMarkRouteImportStatusComplete");
+ });
+
+ mockMarkRouteImportStatusCompleteResult.expectedMessageCount(1);
+ producerTemplate.send("direct:markRouteImportStatusComplete", exchange);
+ mockMarkRouteImportStatusCompleteResult.assertIsSatisfied();
+ }
+
+ @Configuration
+ static class TestConfig {
+ @Bean
+ @Primary
+ public static RoutesBuilder createRouteBuilder() {
+ return new ScanStatusMarkerAndLoggerRouteBuilder();
+ }
+ }
+}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusPublisherRouteBuilderTests.java
index 9ab4b10b..90cd0224 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusPublisherRouteBuilderTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusPublisherRouteBuilderTests.java
@@ -105,6 +105,7 @@ public void testMockRouteOverallStatus() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "traceId");
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessorTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessorTests.java
index 2f6c8e82..c5fd434a 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessorTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportPersistScanDataProcessorTests.java
@@ -58,14 +58,9 @@ public void testScanDataImportPersistScanDataProcessor() {
String groupId = UUID.randomUUID().toString();
String scanId = "sanId";
String emaId = "emaId";
+ String traceId = "traceId";
String scanType = "queueConfiguration,queueListing,subscriptionConfiguration";
-
-// messagingServiceId "d8i99kj5qzj"
-// emaId "5lcf7wa5jpu"
-// scheduleId "07a075f4-29a3-4387-8fb5-8644c8fff5d3"
-// scanId "xtfz7xyewma"
-
List fileDetailsBOS = List.of(
MetaInfFileDetailsBO.builder()
.fileName("queueConfiguration.json")
@@ -79,6 +74,7 @@ public void testScanDataImportPersistScanDataProcessor() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId);
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId);
exchange.getIn().setHeader(RouteConstants.EVENT_MANAGEMENT_ID, emaId);
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, scanType);
exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId);
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java
index 4728f32b..22a39761 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java
@@ -45,6 +45,7 @@ public void testProcessor() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "traceId");
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingService");
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
exchange.getIn().setHeader(RouteConstants.TOPIC, "test/ep/v1");
@@ -59,8 +60,14 @@ public void testProcessor() {
@Test
public void testScanMessageMOPProtocol() {
- ScanDataMessage scanDataMessage =
- new ScanDataMessage("orgId", "scanId", "scanType", "body", Instant.now().toString());
+ ScanDataMessage scanDataMessage = new ScanDataMessage(
+ "orgId",
+ "scanId",
+ "traceId",
+ "scanType",
+ " body",
+ Instant.now().toString());
+
assertThat(scanDataMessage.getMopProtocol()).isEqualTo(MOPProtocol.scanData);
}
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java
index b7a7560b..5a9087dd 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java
@@ -46,14 +46,12 @@ public void testScanStatusOverAllProcessor() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "traceId");
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingServiceId");
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, StringUtils.join(scanTypes, ","));
exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, ScanStatus.IN_PROGRESS);
exchange.getIn().setHeader(RouteConstants.SCAN_STATUS_DESC, "description");
- ScanStatusMessage scanStatusMessage = new
- ScanStatusMessage(null, "scan1", ScanStatus.IN_PROGRESS.name(), "description", scanTypes);
-
HashMap topicDetails = new HashMap<>();
topicDetails.put("orgId", null);
topicDetails.put("runtimeAgentId", null);
@@ -67,9 +65,14 @@ public void testScanStatusOverAllProcessor() {
@Test
public void testScanStatusMessageProtocol() {
- ScanStatusMessage scanStatusMessage = new
- ScanStatusMessage(null, "scan1", ScanStatus.IN_PROGRESS.name(),
- "description", List.of("scanTypes"));
+ ScanStatusMessage scanStatusMessage = new ScanStatusMessage(
+ null,
+ "scan1",
+ "traceId",
+ ScanStatus.IN_PROGRESS.name(),
+ "description",
+ List.of("scanTypes"));
+
assertThat(scanStatusMessage.getMopProtocol()).isEqualTo(MOPProtocol.scanDataControl);
}
}
\ No newline at end of file
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java
index 9f6231b8..e829412f 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java
@@ -43,15 +43,13 @@ public void testScanStatusPerRouteProcessor() {
Exchange exchange = new DefaultExchange(camelContext);
exchange.getIn().setHeader(RouteConstants.SCAN_ID, "scan1");
+ exchange.getIn().setHeader(RouteConstants.TRACE_ID, "traceId");
exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, "messagingServiceId");
exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing");
exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, ScanStatus.IN_PROGRESS);
exchange.getIn().setHeader(RouteConstants.SCAN_STATUS_DESC, "description");
- ScanDataStatusMessage scanDataStatusMessage = new
- ScanDataStatusMessage(null, "scan1", ScanStatus.IN_PROGRESS.name(), "description", "queueListing");
-
HashMap topicDetails = new HashMap<>();
topicDetails.put("orgId", null);
topicDetails.put("runtimeAgentId", null);
@@ -67,8 +65,14 @@ public void testScanStatusPerRouteProcessor() {
@Test
public void testScanDataStatusMessageMOPProtocol() {
- ScanDataStatusMessage scanDataStatusMessage = new
- ScanDataStatusMessage(null, "scan1", ScanStatus.IN_PROGRESS.name(), "description", "queueListing");
+ ScanDataStatusMessage scanDataStatusMessage = new ScanDataStatusMessage(
+ null,
+ "scan1",
+ "traceId",
+ ScanStatus.IN_PROGRESS.name(),
+ "description",
+ "queueListing");
+
assertThat(scanDataStatusMessage.getMopProtocol()).isEqualTo(MOPProtocol.scanDataControl);
}
}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java
index 4e91dfa3..281dc5e5 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java
@@ -40,15 +40,15 @@ class ScanManagerTest {
@Mock
MessagingServiceDelegateServiceImpl messagingServiceDelegateService;
- @Mock
- private ScanService scanService;
-
@InjectMocks
ScanManager scanManager;
@Autowired
ConfluentSchemaRegistryRouteDelegateImpl confluentSchemaRegistryRouteDelegate;
+ @Mock
+ private ScanService scanService;
+
@Test
@SneakyThrows
void testScanManagerExceptions() {
@@ -62,21 +62,36 @@ void testScanManagerExceptions() {
when(messagingServiceDelegateService.getMessagingServiceById("id"))
.thenReturn(messagingServiceEntity);
- when(scanService.singleScan(List.of(), "groupId", "scanId",
- mock(MessagingServiceEntity.class), "runtimeAgent1")).thenReturn(Mockito.anyString());
+ when(scanService.singleScan(List.of(), "groupId", "scanId", "traceId",
+ mock(MessagingServiceEntity.class), "runtimeAgent1"))
+ .thenReturn(Mockito.anyString());
- ScanRequestBO scanRequestBO =
- new ScanRequestBO("id", "scanId", List.of("topics"), List.of());
+ ScanRequestBO scanRequestBO = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("topics"),
+ List.of());
Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBO));
- ScanRequestBO scanRequestBOTopics =
- new ScanRequestBO("id", "scanId", List.of("TEST_SCAN_1"), List.of());
- Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBO));
+ ScanRequestBO scanRequestBOTopics = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("TEST_SCAN_1"),
+ List.of());
- ScanRequestBO scanRequestBOConsumerGroups =
- new ScanRequestBO("id", "scanId", List.of("TEST_SCAN_2"), List.of());
- Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBO));
+ Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBOTopics));
+
+ ScanRequestBO scanRequestBOConsumerGroups = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("TEST_SCAN_2"),
+ List.of());
+
+ Assertions.assertThrows(NullPointerException.class, () -> scanManager.scan(scanRequestBOConsumerGroups));
}
@Test
@@ -84,9 +99,11 @@ void testScanManagerExceptions() {
void testScanManager() {
String messagingServiceId = "messagingServiceId";
String confluentSchemaRegistryId = "confluentId";
- ScanRequestBO scanRequestBO =
- new ScanRequestBO(messagingServiceId, "scanId", List.of("KAFKA_ALL", "CONFLUENT_SCHEMA_REGISTRY_SCHEMA"),
- List.of("FILE_WRITER"));
+
+ ScanRequestBO scanRequestBO = new ScanRequestBO(
+ messagingServiceId, "scanId", "traceId",
+ List.of("KAFKA_ALL", "CONFLUENT_SCHEMA_REGISTRY_SCHEMA"),
+ List.of("FILE_WRITER"));
MessagingServiceEntity messagingServiceEntity = MessagingServiceEntity.builder()
.id(messagingServiceId)
@@ -102,8 +119,7 @@ void testScanManager() {
.connections(List.of())
.build();
- KafkaRouteDelegateImpl kafkaRouteDelegate =
- mock(KafkaRouteDelegateImpl.class);
+ KafkaRouteDelegateImpl kafkaRouteDelegate = mock(KafkaRouteDelegateImpl.class);
DataCollectionFileWriterDelegateImpl dataCollectionFileWriterDelegate =
mock(DataCollectionFileWriterDelegateImpl.class);
@@ -131,8 +147,8 @@ void testScanManager() {
.thenReturn(destinations);
when(kafkaRouteDelegate.generateRouteList(destinations, List.of(), "KAFKA_ALL", messagingServiceId))
.thenReturn(routes);
- when(scanService.singleScan(List.of(), "groupId", "scanId", mock(MessagingServiceEntity.class),
- "runtimeAgent1"))
+ when(scanService.singleScan(List.of(), "groupId", "scanId", "traceId",
+ mock(MessagingServiceEntity.class), "runtimeAgent1"))
.thenReturn(Mockito.anyString());
scanManager.scan(scanRequestBO);
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java
index 110f55de..6e38962d 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java
@@ -27,7 +27,12 @@ public void testMapper() {
scanRequestMapper.map(scanRequestDTO);
scanRequestMapper.map((ScanRequestDTO) null);
- ScanRequestBO scanRequestBO = new ScanRequestBO("id", "scanId", List.of("TEST_SCAN"), List.of());
+ ScanRequestBO scanRequestBO = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("TEST_SCAN"),
+ List.of());
scanRequestMapper.map(scanRequestBO);
scanRequestMapper.map((ScanRequestBO) null);
@@ -38,7 +43,12 @@ public void testMapper() {
@Test
public void testMapperWithUser() {
User user = new User("orgId", "userId");
- ScanRequestBO scanRequestBO = new ScanRequestBO("id", "scanId", List.of("TEST_SCAN"), List.of());
+ ScanRequestBO scanRequestBO = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("TEST_SCAN"),
+ List.of());
scanRequestMapper.map(scanRequestBO, user);
scanRequestMapper.map(null, null);
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
index 7b803e4e..1ed1e20f 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java
@@ -6,7 +6,6 @@
import com.solace.maas.ep.event.management.agent.config.eventPortal.GatewayMessagingProperties;
import com.solace.maas.ep.event.management.agent.config.eventPortal.GatewayProperties;
import com.solace.maas.ep.event.management.agent.scanManager.ScanManager;
-import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanItemMapper;
import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanRequestMapper;
import com.solace.maas.ep.event.management.agent.scanManager.model.ScanRequestBO;
import com.solace.maas.ep.event.management.agent.util.IDGenerator;
@@ -35,9 +34,6 @@ public class EMAControllerTest {
@Autowired
private ScanRequestMapper scanRequestMapper;
- @Autowired
- private ScanItemMapper scanItemMapper;
-
@Test
public void testEMAControllerInConnectedMode() {
@@ -46,8 +42,12 @@ public void testEMAControllerInConnectedMode() {
EventPortalProperties eventPortalProperties = mock(EventPortalProperties.class);
ScanRequestDTO scanRequestDTO = new ScanRequestDTO(List.of("topics"), List.of());
- ScanRequestBO scanRequestBO = new ScanRequestBO("id", "scanId",
- List.of("TEST_SCAN"), List.of());
+ ScanRequestBO scanRequestBO = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("TEST_SCAN"),
+ List.of());
when(eventPortalProperties.getGateway())
.thenReturn(GatewayProperties.builder()
@@ -76,8 +76,12 @@ public void testEMAControllerInStandAloneModeWithEventPortalDestination() {
EventPortalProperties eventPortalProperties = mock(EventPortalProperties.class);
ScanRequestDTO scanRequestDTO = new ScanRequestDTO(List.of("topics"), List.of("EVENT_PORTAL"));
- ScanRequestBO scanRequestBO = new ScanRequestBO("id", "scanId",
- List.of("TEST_SCAN"), List.of("EVENT_PORTAL"));
+ ScanRequestBO scanRequestBO = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("TEST_SCAN"),
+ List.of("EVENT_PORTAL"));
when(eventPortalProperties.getGateway())
.thenReturn(GatewayProperties.builder()
@@ -105,8 +109,12 @@ public void testEMAControllerInStandAloneMode() {
EventPortalProperties eventPortalProperties = mock(EventPortalProperties.class);
ScanRequestDTO scanRequestDTO = new ScanRequestDTO(List.of("topics"), List.of());
- ScanRequestBO scanRequestBO = new ScanRequestBO("id", "scanId",
- List.of("TEST_SCAN"), List.of());
+ ScanRequestBO scanRequestBO = new ScanRequestBO(
+ "id",
+ "scanId",
+ "traceId",
+ List.of("TEST_SCAN"),
+ List.of());
when(eventPortalProperties.getGateway())
.thenReturn(GatewayProperties.builder()
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
index d680c673..a73cb4a2 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/ScanControllerTest.java
@@ -1,7 +1,6 @@
package com.solace.maas.ep.event.management.agent.scanManager.rest;
import com.solace.maas.ep.event.management.agent.TestConfig;
-import com.solace.maas.ep.event.management.agent.config.eventPortal.EventPortalProperties;
import com.solace.maas.ep.event.management.agent.scanManager.ScanManager;
import com.solace.maas.ep.event.management.agent.scanManager.mapper.ScanItemMapper;
import com.solace.maas.ep.event.management.agent.scanManager.model.ScanItemBO;
@@ -34,9 +33,6 @@ public class ScanControllerTest {
@Mock
private ScanItemMapper scanItemMapper;
- @Mock
- private EventPortalProperties eventPortalProperties;
-
@Mock
private ScanManager scanManager;
@@ -46,13 +42,13 @@ public class ScanControllerTest {
@Test
public void scanListTest() {
List responseList = List.of(ScanItemBO.builder()
- .id("scan_id")
- .createdAt(Instant.now())
- .messagingServiceId("msg_svc_id")
- .messagingServiceName("messaging service")
- .messagingServiceType("SOLACE")
- .emaId("ema1")
- .build());
+ .id("scan_id")
+ .createdAt(Instant.now())
+ .messagingServiceId("msg_svc_id")
+ .messagingServiceName("messaging service")
+ .messagingServiceType("SOLACE")
+ .emaId("ema1")
+ .build());
ScanItemDTO mappedResponse = ScanItemDTO.builder()
.id("scan_id")
@@ -63,7 +59,7 @@ public void scanListTest() {
.emaId("ema1")
.build();
- Page response = new PageImpl<>(responseList, PageRequest.of(0,1), responseList.size());
+ Page response = new PageImpl<>(responseList, PageRequest.of(0, 1), responseList.size());
when(scanManager.findAll(any(Pageable.class)))
.thenReturn(response);
@@ -71,7 +67,7 @@ public void scanListTest() {
.thenReturn(mappedResponse);
ResponseEntity> reply =
- controller.list(PageRequest.of(0,1));
+ controller.list(PageRequest.of(0, 1));
assertThat(reply.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(Objects.requireNonNull(reply.getBody()).toList().size()).isEqualTo(1);
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ImportServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ImportServiceTests.java
index 4e3dcd73..ac91cd52 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ImportServiceTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ImportServiceTests.java
@@ -55,6 +55,9 @@ public class ImportServiceTests {
@Mock
EventPortalProperties eventPortalProperties;
+ @Autowired
+ ScanServiceHelper scanServiceHelper;
+
@Autowired
private CamelContext camelContext;
@@ -73,7 +76,7 @@ public class ImportServiceTests {
@SneakyThrows
@Test
public void testImportData() {
- MultipartFile multipartFile = new MockMultipartFile("file.tmp", "test".getBytes());
+ MultipartFile multipartFile = new MockMultipartFile("file.tmp", "test" .getBytes());
ImportRequestBO importRequestBO = ImportRequestBO.builder()
.dataFile(multipartFile)
@@ -92,7 +95,7 @@ public void testImportData() {
@SneakyThrows
@Test
public void testImportDataInStandAloneMode() {
- MultipartFile multipartFile = new MockMultipartFile("file.tmp", "test".getBytes());
+ MultipartFile multipartFile = new MockMultipartFile("file.tmp", "test" .getBytes());
ImportRequestBO importRequestBO = ImportRequestBO.builder()
.dataFile(multipartFile)
@@ -114,26 +117,23 @@ public void testZipData() {
.scanId("scanId")
.build();
+ ScanEntity returnedFindAllByScanId = scanServiceHelper.buildScanEntity(
+ UUID.randomUUID().toString(), "emaId", List.of(), MessagingServiceEntity.builder().build());
+ MessagingServiceEntity returnedMessagingService = scanServiceHelper.buildMessagingServiceEntity(
+ UUID.randomUUID().toString(), "staging service", MessagingServiceType.SOLACE.name());
+ ScanEntity returnedFindById = scanServiceHelper.buildScanEntity(
+ UUID.randomUUID().toString(), "emaId", List.of(), returnedMessagingService);
+
when(dataCollectionFileService.findAllByScanId("scanId"))
.thenReturn(List.of(DataCollectionFileEntity.builder()
.id(UUID.randomUUID().toString())
.path("data_collection/" + UUID.randomUUID() + "/" + UUID.randomUUID() + "/topicListing.json")
- .scan(ScanEntity.builder()
- .id(UUID.randomUUID().toString())
- .build())
+ .scan(returnedFindAllByScanId)
.purged(false)
.build()));
when(scanService.findById("scanId"))
- .thenReturn(Optional.ofNullable(ScanEntity.builder()
- .id(UUID.randomUUID().toString())
- .emaId("emdId")
- .messagingService(MessagingServiceEntity.builder()
- .id(UUID.randomUUID().toString())
- .name("staging service")
- .type(MessagingServiceType.SOLACE.name())
- .build())
- .build()));
+ .thenReturn(Optional.ofNullable(returnedFindById));
Path file = tempDir.resolve("test.json");
Files.write(file, Collections.singleton("test data"));
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceHelper.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceHelper.java
new file mode 100644
index 00000000..a6f6e823
--- /dev/null
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceHelper.java
@@ -0,0 +1,66 @@
+package com.solace.maas.ep.event.management.agent.service;
+
+import com.solace.maas.ep.event.management.agent.plugin.route.RouteBundle;
+import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.MessagingServiceEntity;
+import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity;
+import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanEntity;
+import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanStatusEntity;
+import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanTypeEntity;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class ScanServiceHelper {
+ RouteBundle buildRouteBundle(String scaType, List destinations, List recipients) {
+ return RouteBundle.builder()
+ .messagingServiceId("service1")
+ .routeId("route1")
+ .scanType(scaType)
+ .destinations(destinations)
+ .recipients(recipients)
+ .build();
+ }
+
+ RouteEntity buildRouteEntity(String routeId, String childRouteIds, boolean isActive) {
+ return RouteEntity.builder()
+ .id(routeId)
+ .childRouteIds(childRouteIds)
+ .active(isActive)
+ .build();
+ }
+
+ ScanEntity buildScanEntity(String id, String emaId, List routes, MessagingServiceEntity messagingService) {
+ return ScanEntity.builder()
+ .id(id)
+ .emaId(emaId)
+ .route(routes)
+ .messagingService(messagingService)
+ .build();
+
+ }
+
+ ScanTypeEntity buildScanTypeEntity(String id, String name, ScanEntity scan, ScanStatusEntity status) {
+ return ScanTypeEntity.builder()
+ .id(id)
+ .name(name)
+ .scan(scan)
+ .status(status)
+ .build();
+ }
+
+ MessagingServiceEntity buildMessagingServiceEntity(String id, String name, String type) {
+ return MessagingServiceEntity.builder()
+ .id(id)
+ .name(name)
+ .type(type)
+ .build();
+ }
+
+ public ScanStatusEntity buildScanStatusEntity(String id, String status) {
+ return ScanStatusEntity.builder()
+ .id(id)
+ .status(status)
+ .build();
+ }
+}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
index 1727bae1..cb76cad6 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java
@@ -1,33 +1,31 @@
package com.solace.maas.ep.event.management.agent.service;
import com.solace.maas.ep.event.management.agent.TestConfig;
+import com.solace.maas.ep.event.management.agent.config.plugin.enumeration.MessagingServiceType;
import com.solace.maas.ep.event.management.agent.logging.StreamingAppender;
import com.solace.maas.ep.event.management.agent.plugin.constants.ScanStatus;
import com.solace.maas.ep.event.management.agent.plugin.route.RouteBundle;
import com.solace.maas.ep.event.management.agent.plugin.route.RouteBundleHierarchyStore;
-import com.solace.maas.ep.event.management.agent.processor.RouteCompleteProcessorImpl;
import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.MessagingServiceEntity;
import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity;
import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanEntity;
+import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanRecipientHierarchyEntity;
import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanStatusEntity;
import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanTypeEntity;
-import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanRecipientHierarchyEntity;
import com.solace.maas.ep.event.management.agent.repository.scan.ScanRecipientHierarchyRepository;
import com.solace.maas.ep.event.management.agent.repository.scan.ScanRepository;
import com.solace.maas.ep.event.management.agent.repository.scan.ScanTypeRepository;
import com.solace.maas.ep.event.management.agent.service.logging.LoggingService;
import com.solace.maas.ep.event.management.agent.util.IDGenerator;
import lombok.SneakyThrows;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.Processor;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.ExchangeBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
@@ -77,9 +75,6 @@ public class ScanServiceTests {
@Mock
private ScanRouteService scanRouteService;
- @Mock
- private RouteCompleteProcessorImpl routeCompleteProcessor;
-
@Mock
private IDGenerator idGenerator;
@@ -89,24 +84,16 @@ public class ScanServiceTests {
@InjectMocks
private ScanService scanService;
+ @Autowired
+ private ScanServiceHelper scanServiceHelper;
+
@Test
@SneakyThrows
public void testSingleScanWithRouteBundle() {
- RouteBundle consumerGroupsConfiguration = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("consumerGroupsConfiguration")
- .destinations(List.of())
- .recipients(List.of())
- .build();
-
- RouteBundle consumerGroups = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("consumerGroups")
- .destinations(List.of())
- .recipients(List.of(consumerGroupsConfiguration))
- .build();
+ RouteBundle consumerGroupsConfiguration = scanServiceHelper.buildRouteBundle("consumerGroupsConfiguration", List.of(), List.of());
+ RouteBundle consumerGroups = scanServiceHelper.buildRouteBundle("consumerGroups", List.of(), List.of(consumerGroupsConfiguration));
+ RouteBundle topicConfiguration = scanServiceHelper.buildRouteBundle("topicConfiguration", List.of(), List.of());
+ RouteBundle overrideTopicConfiguration = scanServiceHelper.buildRouteBundle("overrideTopicConfiguration", List.of(), List.of());
RouteBundle routeBundleDestination = RouteBundle.builder()
.messagingServiceId("service1")
@@ -116,70 +103,18 @@ public void testSingleScanWithRouteBundle() {
.recipients(List.of())
.build();
- RouteBundle topicConfiguration = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("topicConfiguration")
- .destinations(List.of())
- .recipients(List.of())
- .build();
-
- RouteBundle overrideTopicConfiguration = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("overrideTopicConfiguration")
- .destinations(List.of())
- .recipients(List.of())
- .build();
-
- RouteBundle topicListing = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("topicListing")
- .destinations(List.of(routeBundleDestination))
- .recipients(List.of(topicConfiguration, overrideTopicConfiguration))
- .build();
-
- RouteBundle additionalConsumerGroupConfigPart1 = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("additionalConsumerGroupConfigPart1")
- .destinations(List.of(routeBundleDestination))
- .recipients(List.of())
- .build();
-
- RouteBundle additionalConsumerGroupConfigPart2 = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("additionalConsumerGroupConfigPart2")
- .destinations(List.of(routeBundleDestination))
- .recipients(List.of())
- .build();
-
- RouteBundle additionalConsumerGroupConfigBundle = RouteBundle.builder()
- .messagingServiceId("service1")
- .routeId("route1")
- .scanType("consumerGroupsConfiguration")
- .destinations(List.of(routeBundleDestination))
- .recipients(List.of(additionalConsumerGroupConfigPart1, additionalConsumerGroupConfigPart2))
- .build();
-
- RouteEntity returnedEntity = RouteEntity.builder()
- .id(routeId)
- .childRouteIds("")
- .active(true)
- .build();
+ RouteBundle topicListing = scanServiceHelper.buildRouteBundle("topicListing", List.of(routeBundleDestination),
+ List.of(topicConfiguration, overrideTopicConfiguration));
+ RouteBundle additionalConsumerGroupConfigPart1 = scanServiceHelper.buildRouteBundle("additionalConsumerGroupConfigPart1",
+ List.of(routeBundleDestination), List.of());
+ RouteBundle additionalConsumerGroupConfigPart2 = scanServiceHelper.buildRouteBundle("additionalConsumerGroupConfigPart2",
+ List.of(routeBundleDestination), List.of());
+ RouteBundle additionalConsumerGroupConfigBundle = scanServiceHelper.buildRouteBundle("consumerGroupsConfiguration",
+ List.of(routeBundleDestination), List.of(additionalConsumerGroupConfigPart1, additionalConsumerGroupConfigPart2));
- ScanEntity scanEntity = ScanEntity.builder()
- .id(UUID.randomUUID().toString())
- .route(List.of(returnedEntity))
- .build();
-
- ScanTypeEntity scanType = ScanTypeEntity.builder()
- .id("scan1")
- .name("scanType")
- .scan(scanEntity)
- .build();
+ RouteEntity returnedEntity = scanServiceHelper.buildRouteEntity(routeId, "", true);
+ ScanEntity scanEntity = scanServiceHelper.buildScanEntity("123", "emaId1", List.of(returnedEntity), null);
+ ScanTypeEntity scanType = scanServiceHelper.buildScanTypeEntity("scan1", "scanType", scanEntity, null);
when(idGenerator.generateRandomUniqueId())
.thenReturn("abc123");
@@ -201,20 +136,11 @@ public void testSingleScanWithRouteBundle() {
.thenReturn(mock(ScanRecipientHierarchyEntity.class));
scanService.singleScan(List.of(topicListing, consumerGroups, additionalConsumerGroupConfigBundle),
- "groupId", "scanId", mock(MessagingServiceEntity.class), "runtimeAgent1");
-
- assertThatNoException();
- }
-
- @Test
- @SneakyThrows
- public void testScan() {
- Exchange exchange = ExchangeBuilder.anExchange(mock(ExtendedCamelContext.class)).build();
-
- when(producerTemplate.send(any(String.class), any(Processor.class)))
- .thenReturn(exchange);
-
- scanService.scan("group1", "scan1", RouteEntity.builder().build(), "service1");
+ "groupId",
+ "scanId",
+ "traceId",
+ mock(MessagingServiceEntity.class),
+ "runtimeAgent1");
assertThatNoException();
}
@@ -243,23 +169,17 @@ public void testListScans() {
@Test
@SneakyThrows
public void testFindAll() {
+ MessagingServiceEntity messagingService = scanServiceHelper.buildMessagingServiceEntity(
+ "service1", "service1", MessagingServiceType.SOLACE.name());
+ ScanStatusEntity scanStatus = scanServiceHelper.buildScanStatusEntity("status1", "COMPLETE");
+ ScanTypeEntity scanType = scanServiceHelper.buildScanTypeEntity("123", "SOLACE_ALL", null, scanStatus);
+
ScanEntity result = ScanEntity.builder()
.id("id1")
.createdAt(Instant.now())
- .messagingService(MessagingServiceEntity.builder()
- .id("service1")
- .name("service1")
- .type("SOLACE")
- .build())
- .scanTypes(List.of(
- ScanTypeEntity.builder()
- .name("SOLACE_ALL")
- .status(ScanStatusEntity.builder()
- .id("status1")
- .status("COMPLETE")
- .build())
- .build())
- ).build();
+ .messagingService(messagingService)
+ .scanTypes(List.of(scanType))
+ .build();
Pageable pageable = PageRequest.of(0, 1);
@@ -274,23 +194,17 @@ public void testFindAll() {
@Test
@SneakyThrows
public void testFindByMessagingServiceId() {
+ MessagingServiceEntity messagingService = scanServiceHelper.buildMessagingServiceEntity(
+ "service1", "service1", MessagingServiceType.SOLACE.name());
+ ScanStatusEntity scanStatus = scanServiceHelper.buildScanStatusEntity("status1", "COMPLETE");
+ ScanTypeEntity scanType = scanServiceHelper.buildScanTypeEntity("123", "SOLACE_ALL", null, scanStatus);
+
ScanEntity result = ScanEntity.builder()
.id("id1")
.createdAt(Instant.now())
- .messagingService(MessagingServiceEntity.builder()
- .id("service1")
- .name("service1")
- .type("SOLACE")
- .build())
- .scanTypes(List.of(
- ScanTypeEntity.builder()
- .name("SOLACE_ALL")
- .status(ScanStatusEntity.builder()
- .id("status1")
- .status("COMPLETE")
- .build())
- .build())
- ).build();
+ .messagingService(messagingService)
+ .scanTypes(List.of(scanType))
+ .build();
Pageable pageable = PageRequest.of(0, 1);
@@ -380,7 +294,7 @@ public void testSendScanStatus() {
ScanService service = new ScanService(mock(ScanRepository.class), mock(ScanRecipientHierarchyRepository.class),
mock(ScanTypeRepository.class),
mock(ScanRouteService.class), mock(RouteService.class), template, idGenerator);
- service.sendScanStatus("scanId", "groupId", "messagingServiceId",
+ service.sendScanStatus("scanId", "groupId", "messagingServiceId", "traceId",
"queueListing", ScanStatus.IN_PROGRESS);
assertThatNoException();
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
index a2245b3e..5e522955 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java
@@ -15,6 +15,7 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.ProducerTemplate;
+import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +31,7 @@
import static com.solace.maas.ep.common.model.ScanType.KAFKA_ALL;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatNoException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
@@ -70,7 +72,7 @@ public void scanReceiver() {
String basePayload = "{\n" +
" \"mopVer\" : \"1\",\n" +
- " \"mopProtocol\" : \"event\",\n" +
+ " \"mopProtocol\" : \"scanDataControl\",\n" +
" \"mopMsgType\" : \"generic\",\n" +
" \"msgUh\" : \"ignore\",\n" +
" \"repeat\" : false,\n" +
@@ -86,8 +88,8 @@ public void scanReceiver() {
"com.solace.maas.ep.common.messages.ScanCommandMessage");
when(inboundMessage.getDestinationName()).thenReturn("anyTopic");
- ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(solaceConfiguration,
- solaceSubscriber, scanManager, scanRequestMapper);
+ ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(
+ solaceConfiguration, solaceSubscriber, scanManager);
String topic = scanCommandMessageHandler.getTopicString();
log.info("topic: {}", topic);
@@ -101,10 +103,10 @@ public void scanReceiver() {
@Test
@SneakyThrows
public void testBadClass() {
- Exception e = assertThrows(RuntimeException.class, () -> {
+ assertThrows(RuntimeException.class, () -> {
when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn("badClass");
- ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(solaceConfiguration,
- solaceSubscriber, scanManager, scanRequestMapper);
+ ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(
+ solaceConfiguration, solaceSubscriber, scanManager);
scanCommandMessageHandler.onMessage(inboundMessage);
});
}
@@ -112,8 +114,8 @@ public void testBadClass() {
@Test
@SneakyThrows
public void testScanCommandMessage() {
- ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(solaceConfiguration,
- solaceSubscriber, scanManager, scanRequestMapper);
+ ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler(
+ solaceConfiguration, solaceSubscriber, scanManager);
ScanCommandMessage scanCommandMessage =
new ScanCommandMessage("messagingServiceId",
@@ -136,7 +138,7 @@ public void testScanCommandMessageMOPProtocol() {
public void startImportScanCommandMessageHandlerTest() {
String payload = "{\n" +
" \"mopVer\" : \"1\",\n" +
- " \"mopProtocol\" : \"event\",\n" +
+ " \"mopProtocol\" : \"scanDataControl\",\n" +
" \"mopMsgType\" : \"generic\",\n" +
" \"msgUh\" : \"ignore\",\n" +
" \"repeat\" : false,\n" +
@@ -177,6 +179,38 @@ public void startImportScanCommandMessageHandlerTest() {
assertThatNoException();
}
+ @SneakyThrows
+ @Test
+ public void startImportScanCommandMessageHandlerWithEmptyFilesTest() {
+ String payload = "{\n" +
+ " \"mopVer\" : \"1\",\n" +
+ " \"mopProtocol\" : \"scanDataControl\",\n" +
+ " \"mopMsgType\" : \"generic\",\n" +
+ " \"msgUh\" : \"ignore\",\n" +
+ " \"repeat\" : false,\n" +
+ " \"isReplyMessage\" : false,\n" +
+ " \"msgPriority\" : 4,\n" +
+ " \"traceId\" : \"80817f0d335b6221\",\n" +
+ " \"scanId\" : \"someScanId\",\n" +
+ " \"scanTypes\" : [\"a\",\"b\",\"c\"]\n" +
+ "}";
+
+ when(inboundMessage.getPayloadAsString()).thenReturn(payload);
+ when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn(
+ "com.solace.maas.ep.common.messages.ScanDataImportMessage");
+ when(inboundMessage.getDestinationName()).thenReturn("anyTopic");
+ when(manualImportFilesService.getAllByScanId(anyString())).thenReturn(List.of());
+
+ StartImportScanCommandMessageHandler startImportScanCommandMessageHandler = new StartImportScanCommandMessageHandler(solaceConfiguration,
+ solaceSubscriber, producerTemplate, manualImportFilesService, manualImportDetailsService);
+
+ RuntimeException thrown = Assert.assertThrows(RuntimeException.class,
+ () -> startImportScanCommandMessageHandler.onMessage(inboundMessage));
+
+ assertEquals("can't retrieve any manualImportFiles for scanId: someScanId", thrown.getMessage());
+ }
+
+
@Test
@SneakyThrows
public void heartbeatReceiverTest() {
diff --git a/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/route/delegate/KafkaRouteDelegateImplTests.java b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/route/delegate/KafkaRouteDelegateImplTests.java
index 50c46664..c7625e86 100644
--- a/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/route/delegate/KafkaRouteDelegateImplTests.java
+++ b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/route/delegate/KafkaRouteDelegateImplTests.java
@@ -19,7 +19,7 @@ public class KafkaRouteDelegateImplTests {
@InjectMocks
private KafkaRouteDelegateImpl kafkaRouteDelegate;
- private List destinations = List.of(
+ private final List destinations = List.of(
RouteBundle.builder()
.destinations(List.of())
.recipients(List.of())
diff --git a/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/GenericListScanIdAggregationStrategyTest.java b/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/GenericListScanIdAggregationStrategyTest.java
index 94f552b4..d099d053 100644
--- a/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/GenericListScanIdAggregationStrategyTest.java
+++ b/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/GenericListScanIdAggregationStrategyTest.java
@@ -1,5 +1,6 @@
package com.solace.maas.ep.event.management.agent.plugin.localstorage.aggregation;
+import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.route.aggregation.GenericListScanIdAggregationStrategy;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
@@ -9,7 +10,6 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
-import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.SCAN_ID;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatNoException;
@ActiveProfiles("TEST")
@@ -26,11 +26,11 @@ public void testGenericListScanIdAggregationStrategy() {
new GenericListScanIdAggregationStrategy();
Exchange oldExchange = new DefaultExchange(camelContext);
- oldExchange.getIn().setHeader(SCAN_ID, "oldId");
+ oldExchange.getIn().setHeader(RouteConstants.SCAN_ID, "oldId");
oldExchange.getIn().setBody("old exchange");
Exchange newExchange = new DefaultExchange(camelContext);
- newExchange.getIn().setHeader(SCAN_ID, "newId");
+ newExchange.getIn().setHeader(RouteConstants.SCAN_ID, "newId");
newExchange.getIn().setBody("new exchange");
genericListScanIdAggregationStrategy.handleExchange(oldExchange);
diff --git a/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/ScanIdAggregationStrategyTest.java b/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/ScanIdAggregationStrategyTest.java
index e6cc9ab6..ec53a6db 100644
--- a/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/ScanIdAggregationStrategyTest.java
+++ b/service/local-storage-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/localstorage/aggregation/ScanIdAggregationStrategyTest.java
@@ -1,5 +1,6 @@
package com.solace.maas.ep.event.management.agent.plugin.localstorage.aggregation;
+import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.route.aggregation.base.ScanIdAggregationStrategyImpl;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
@@ -26,17 +27,17 @@ public void testScanIdAggregationStrategy() {
Mockito.mock(ScanIdAggregationStrategyImpl.class, Mockito.CALLS_REAL_METHODS);
Exchange oldExchange = new DefaultExchange(camelContext);
- oldExchange.getIn().setHeader(SCAN_ID, "oldId");
+ oldExchange.getIn().setHeader(RouteConstants.SCAN_ID, "oldId");
oldExchange.getIn().setBody("old exchange");
Exchange newExchange = new DefaultExchange(camelContext);
- newExchange.getIn().setHeader(SCAN_ID, "newId");
+ newExchange.getIn().setHeader(RouteConstants.SCAN_ID, "newId");
newExchange.getIn().setBody("new exchange");
scanIdAggregationStrategyImpl.aggregate(oldExchange, newExchange);
- oldExchange.getIn().setHeader(SCAN_ID, "sameId");
- newExchange.getIn().setHeader(SCAN_ID, "sameId");
+ oldExchange.getIn().setHeader(RouteConstants.SCAN_ID, "sameId");
+ newExchange.getIn().setHeader(RouteConstants.SCAN_ID, "sameId");
scanIdAggregationStrategyImpl.aggregate(oldExchange, newExchange);
scanIdAggregationStrategyImpl.aggregate(null, newExchange);
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java
index 2078eece..99af41dd 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java
@@ -9,6 +9,8 @@ public class RouteConstants {
public static final String SCAN_ID = "SCAN_ID";
+ public static final String TRACE_ID = "TRACE_ID";
+
public static final String SCAN_TYPE = "SCAN_TYPE";
public static final String SCAN_STATUS = "SCAN_STATUS";
@@ -21,6 +23,8 @@ public class RouteConstants {
public static final String EVENT_MANAGEMENT_ID = "EVENT_MANAGEMENT_ID";
+ public static final String IMPORT_ID = "IMPORT_ID";
+
public static final String IS_DATA_IMPORT = "IS_DATA_IMPORT";
public static final String GENERAL_STATUS_MESSAGE = "GENERAL_STATUS_MESSAGE";
@@ -28,5 +32,4 @@ public class RouteConstants {
public static final String SCAN_DATA_STATUS_MESSAGE = "SCAN_DATA_STATUS_MESSAGE";
public static final String TOPIC_DETAILS = "TOPIC_DETAILS";
- public static final String IMPORT_ID = "IMPORT_ID";
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java
index 4ad2cab5..15feb9bf 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java
@@ -10,15 +10,18 @@
public class MDCProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
+ MDC.put(RouteConstants.SCHEDULE_ID,
+ exchange.getIn().getHeader(RouteConstants.SCHEDULE_ID, String.class));
+
MDC.put(RouteConstants.SCAN_ID,
exchange.getIn().getHeader(RouteConstants.SCAN_ID, String.class));
+ MDC.put(RouteConstants.TRACE_ID,
+ exchange.getIn().getHeader(RouteConstants.TRACE_ID, String.class));
+
MDC.put(RouteConstants.SCAN_TYPE,
exchange.getIn().getHeader(RouteConstants.SCAN_TYPE, String.class));
- MDC.put(RouteConstants.SCHEDULE_ID,
- exchange.getIn().getHeader(RouteConstants.SCHEDULE_ID, String.class));
-
MDC.put(RouteConstants.MESSAGING_SERVICE_ID,
exchange.getIn().getHeader(RouteConstants.MESSAGING_SERVICE_ID, String.class));
}
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java
index e62d0ced..ae94c129 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java
@@ -25,7 +25,7 @@ public class SolacePublisher {
private static final ObjectMapper mapper = new ObjectMapper();
private final OutboundMessageBuilder outboundMessageBuilder;
- private DirectMessagePublisher directMessagePublisher;
+ private final DirectMessagePublisher directMessagePublisher;
public SolacePublisher(OutboundMessageBuilder outboundMessageBuilder,
DirectMessagePublisher directMessagePublisher) {
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java
index 33cc03e9..e9f96f3e 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/RouteBundleHierarchyStore.java
@@ -8,7 +8,7 @@
@Data
public class RouteBundleHierarchyStore {
- private static int storeKey = 0;
+ private static int storeKey;
private Map store;
public RouteBundleHierarchyStore() {
diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java
index d8df6f05..fde7b609 100644
--- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java
+++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java
@@ -13,16 +13,40 @@ public class ScanStatusMarkerAndLoggerRouteBuilder extends RouteBuilder {
public void configure() throws Exception {
from("direct:markRouteScanStatusInProgress")
- .log("Scan request [${header." + RouteConstants.SCAN_ID + "}]: The status of [${header."
- + RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.IN_PROGRESS + "].")
+ .routeId("markRouteScanStatusInProgress")
+ .log("Scan request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: The status of [${header." +
+ RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.IN_PROGRESS + "].")
.to("direct:perRouteScanStatusPublisher?block=false&failIfNoConsumers=false")
- .log("Scan request [${header." + RouteConstants.SCAN_ID + "}]: Retrieving [${header." + RouteConstants.SCAN_TYPE
- + "}] details from messaging service [${header." + RouteConstants.MESSAGING_SERVICE_ID + "}].");
+ .log("Scan request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: Retrieving [${header." + RouteConstants.SCAN_TYPE
+ + "}] details from event broker [${header." + RouteConstants.MESSAGING_SERVICE_ID + "}].");
from("direct:markRouteScanStatusComplete")
+ .routeId("markRouteScanStatusComplete")
.to("direct:processScanStatusAsComplete?block=false&failIfNoConsumers=false")
- .log("Scan request [${header." + RouteConstants.SCAN_ID + "}]: The status of [${header."
- + RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.COMPLETE + "].");
+ .log("Scan request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: The status of [${header." +
+ RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.COMPLETE + "].");
+
+
+ from("direct:markRouteImportStatusInProgress")
+ .routeId("markRouteImportStatusInProgress")
+ .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: The status of [${header." +
+ RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.IN_PROGRESS + "].")
+ .to("direct:perRouteScanStatusPublisher?block=false&failIfNoConsumers=false")
+ .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: Retrieving [${header." +
+ RouteConstants.SCAN_TYPE + "}] details from file: [${body.fileName}].");
+
+
+ from("direct:markRouteImportStatusComplete")
+ .routeId("markRouteImportStatusComplete")
+ .to("direct:processScanStatusAsComplete?block=false&failIfNoConsumers=false")
+ .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." +
+ RouteConstants.TRACE_ID + "}]: The status of [${header." +
+ RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.COMPLETE + "].");
}
}
diff --git a/service/solace-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/solace/route/delegate/SolaceRouteDelegateImplTests.java b/service/solace-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/solace/route/delegate/SolaceRouteDelegateImplTests.java
index 026e7951..0f1f0518 100644
--- a/service/solace-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/solace/route/delegate/SolaceRouteDelegateImplTests.java
+++ b/service/solace-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/solace/route/delegate/SolaceRouteDelegateImplTests.java
@@ -19,7 +19,7 @@ public class SolaceRouteDelegateImplTests {
@InjectMocks
private SolaceRouteDelegateImpl solaceRouteDelegate;
- private List destinations = List.of(
+ private final List destinations = List.of(
RouteBundle.builder()
.destinations(List.of())
.recipients(List.of())
From dd8015a3acd288de968fa8f1685ba93a3fabac03 Mon Sep 17 00:00:00 2001
From: Salman Hooshmand <59615308+shooshmand-sol@users.noreply.github.com>
Date: Tue, 13 Jun 2023 09:33:29 -0400
Subject: [PATCH 17/31] Building Docker Image and Pusing to ECR
---
.github/workflows/build.yaml | 31 +++++++++++++++++--
.../docker/buildEventManagementAgentDocker.sh | 7 +++--
2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 9fc1f411..a90b7b40 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -18,6 +18,7 @@ jobs:
Test_Build:
name: Run Tests and Deploy
runs-on: ubuntu-latest
+ environment: ${{ github.ref=='refs/heads/main' && 'build_main' || 'build_pr' }}
timeout-minutes: 20
permissions:
contents: read
@@ -47,11 +48,13 @@ jobs:
if [[ $GITHUB_REF_NAME == "main" ]]; then
export WHITESOURCE_SCAN=true
export GITHUB_PACKAGES_DEPLOY=true
+ export DOCKER_PUSH=true
else
export WHITESOURCE_SCAN=false
export GITHUB_PACKAGES_DEPLOY=false
+ export DOCKER_PUSH=false
fi
- echo "$WHITESOURCE_SCAN"
+ echo "DOCKER_PUSH=$DOCKER_PUSH" >> $GITHUB_ENV
echo "WHITESOURCE_SCAN=$WHITESOURCE_SCAN" >> $GITHUB_ENV
echo "GITHUB_PACKAGES_DEPLOY=$GITHUB_PACKAGES_DEPLOY" >> $GITHUB_ENV
- name: Static Code Analysis
@@ -99,7 +102,31 @@ jobs:
echo "Whitesource- Running scan"
java -jar wss-unified-agent.jar -d ${{ env.TARGET_DIR }} -logLevel Info
-
+ - name: Configure AWS credentials
+ if: env.DOCKER_PUSH=='true'
+ uses: aws-actions/configure-aws-credentials@v2
+ with:
+ aws-access-key-id: ${{ secrets.EMA_AWS_ACCESS_KEY_ID }}
+ aws-secret-access-key: ${{ secrets.EMA_AWS_SECRET_ACCESS_KEY }}
+ aws-region: ${{ secrets.EMA_AWS_DEFAULT_REGION }}
+ - name: Login to Amazon ECR
+ if: env.DOCKER_PUSH=='true'
+ id: login-ecr
+ uses: aws-actions/amazon-ecr-login@v1.6.0
+ - name: Docker Build/Push
+ if: env.DOCKER_PUSH=='true'
+ working-directory: service/application/docker
+ run: |
+ ./buildEventManagementAgentDocker.sh -t main
+ ECR_DOCKER_IMAGE="${{ steps.login-ecr.outputs.registry }}/${{ github.event.repository.name }}:main"
+ docker tag "${{ github.event.repository.name }}:main" $ECR_DOCKER_IMAGE
+ docker push $ECR_DOCKER_IMAGE
+ #Tag/Push additional Docker image
+ SHORT_GIT_SHA=${GITHUB_SHA:0:10}
+ JAR_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file ../pom.xml)
+ ADDITIONAL_ECR_DOCKER_IMAGE_TAG="$ECR_DOCKER_IMAGE-$JAR_VERSION-$SHORT_GIT_SHA"
+ docker tag "${{ github.event.repository.name }}:main" $ADDITIONAL_ECR_DOCKER_IMAGE_TAG
+ docker push $ADDITIONAL_ECR_DOCKER_IMAGE_TAG
- name: Deploy Artifacts
if: env.GITHUB_PACKAGES_DEPLOY=='true'
env:
diff --git a/service/application/docker/buildEventManagementAgentDocker.sh b/service/application/docker/buildEventManagementAgentDocker.sh
index 91714aec..efd7bd90 100755
--- a/service/application/docker/buildEventManagementAgentDocker.sh
+++ b/service/application/docker/buildEventManagementAgentDocker.sh
@@ -105,13 +105,14 @@ export BASE_IMAGE=event-management-agent-base:${BASE_IMAGE_TAG}
export GITHASH=$(git rev-parse HEAD)
export GITBRANCH=$(git branch --show-current)
export BUILD_TIMESTAMP=$(date -u)
-cp ../target/event-management-agent-1.0.0-SNAPSHOT.jar .
+export JAR_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file ../pom.xml)
+cp ../target/event-management-agent-${JAR_VERSION}.jar .
cd ..
docker build docker -t event-management-agent:${IMAGE_TAG} --build-arg BASE_IMAGE=${BASE_IMAGE}\
- --build-arg JAR_FILE=event-management-agent-1.0.0-SNAPSHOT.jar --build-arg GITHASH=${GITHASH}\
+ --build-arg JAR_FILE=event-management-agent-${JAR_VERSION}.jar --build-arg GITHASH=${GITHASH}\
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" --build-arg GITBRANCH=${GITBRANCH}
cd ${script_dir}
# cleanup
-rm event-management-agent-1.0.0-SNAPSHOT.jar
+rm event-management-agent-${JAR_VERSION}.jar
From a455b708fa0106a1a63b48592f21ee43a6627090 Mon Sep 17 00:00:00 2001
From: Salman Hooshmand <59615308+shooshmand-sol@users.noreply.github.com>
Date: Wed, 14 Jun 2023 16:15:05 -0400
Subject: [PATCH 18/31] Checking Prisma Vulnurabilites before release
---
.github/workflows/release.yaml | 19 +++-
.../prisma_vulnurability_checker.py | 90 +++++++++++++++++++
2 files changed, 106 insertions(+), 3 deletions(-)
create mode 100644 .github/workflows/release_scripts/prisma_vulnurability_checker.py
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index f8eed86f..adec0080 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -47,14 +47,27 @@ jobs:
env:
WS_APIKEY: ${{ secrets.WHITESOURCE_API_KEY }}
WS_PROJECTTOKEN: ${{ secrets.WHITESOURCE_PROJECT_TOKEN }}
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.EMA_AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.EMA_AWS_SECRET_ACCESS_KEY }}
+ AWS_DEFAULT_REGION: ${{ secrets.EMA_AWS_DEFAULT_REGION }}
run: |
pip install --quiet --upgrade pip
export VIRTUAL_ENV=./venv
python3.8 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate
cd ./.github/workflows/release_scripts/ && pip install --quiet -r requirements.txt && python3.8 whitesource_vulnurability_checker.py
+ - name: Pre-Release Check - Prisma vulnurabilities
+ env:
+ PRISMA_ROOT_API_URL: ${{ secrets.PRISMA_ROOT_API_URL }}
+ DOCKER_IMAGE_TO_CHECK: ${{ secrets.PRISMA_DOCKER_IMAGE_TO_CHECK }}
+ PRISMA_ACCESS_KEY: ${{ secrets.PRISMA_ACCESS_KEY }}
+ PRISMA_ACCESS_KEY_SECRET: ${{ secrets.PRISMA_ACCESS_KEY_SECRET }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.EMA_AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.EMA_AWS_SECRET_ACCESS_KEY }}
+ AWS_DEFAULT_REGION: ${{ secrets.EMA_AWS_DEFAULT_REGION }}
+ run: |
+ export VIRTUAL_ENV=./venv
+ python3.8 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate
+ cd ./.github/workflows/release_scripts/ && python3.8 prisma_vulnurability_checker.py
- name: Prepare Maven Settings
env:
MAVEN_REPO_SERVER_USERNAME: "${{ github.actor }}"
diff --git a/.github/workflows/release_scripts/prisma_vulnurability_checker.py b/.github/workflows/release_scripts/prisma_vulnurability_checker.py
new file mode 100644
index 00000000..1c3fe029
--- /dev/null
+++ b/.github/workflows/release_scripts/prisma_vulnurability_checker.py
@@ -0,0 +1,90 @@
+import requests
+import json
+import os
+import boto3
+import textwrap
+
+PRISMA_ROOT_API_URL = os.getenv("PRISMA_ROOT_API_URL")
+PRISMA_AUTHENTICATE_URL = f"{PRISMA_ROOT_API_URL}/authenticate"
+PRISMA_REGISTRY_SCAN_RESULT_URL = f"{PRISMA_ROOT_API_URL}/registry"
+PRISMA_ACCESS_KEY = os.getenv('PRISMA_ACCESS_KEY')
+PRISMA_ACCESS_KEY_SECRET = os.getenv('PRISMA_ACCESS_KEY_SECRET')
+HTTP_JSON_HEADER = 'application/json'
+# DOCKER_IMAGE_TO_CHECK is the repository name full and the tag that is used to scan it
+DOCKER_IMAGE_TO_CHECK = os.getenv("DOCKER_IMAGE_TO_CHECK")
+PRISMA_BLOCKING_VULNERABILITIES = "critical,high"
+
+
+def get_excluded_packages():
+ dynamodb_client = boto3.resource('dynamodb')
+
+ whitesource_exclusion_table = dynamodb_client.Table('prisma-excluded-packages')
+ whitesource_exclusion_entries = whitesource_exclusion_table.scan()['Items']
+
+ exclusions = set()
+ for exclusion in whitesource_exclusion_entries:
+ exclusions.add(exclusion['package'])
+
+ return exclusions
+
+
+def block_print(long_string, each_line_length=75):
+ print("\n\t".join(textwrap.wrap(long_string, each_line_length)))
+
+
+def find_all_high_critical_vulnerabilities_to_resolve(excluded_libraries):
+ # Authenticate
+ authenticate_payload = {
+ 'username': PRISMA_ACCESS_KEY,
+ 'password': PRISMA_ACCESS_KEY_SECRET
+ }
+ authenticate_headers = {'Accept': HTTP_JSON_HEADER, 'Content-type': HTTP_JSON_HEADER}
+
+ get_token_request = requests.post(
+ PRISMA_AUTHENTICATE_URL,
+ data=json.dumps(authenticate_payload),
+ headers=authenticate_headers
+ )
+ token_response = json.loads(get_token_request.text)
+ scan_result_token = token_response['token']
+
+ # Get scan results
+ scan_result_header = {
+ 'accept': HTTP_JSON_HEADER,
+ 'content-type': HTTP_JSON_HEADER,
+ 'Authorization': f'Bearer {scan_result_token}'
+ }
+ prisma_scan_result_request = requests.get(
+ f'{PRISMA_REGISTRY_SCAN_RESULT_URL}?name={DOCKER_IMAGE_TO_CHECK}',
+ data=json.dumps(authenticate_payload),
+ headers=scan_result_header
+ )
+
+ prisma_project_vulnerabilities = prisma_scan_result_request.json()[0].get('vulnerabilities')
+ vulnerabilities_to_resolve = dict()
+ for vulnerability in prisma_project_vulnerabilities:
+ if vulnerability['severity'] in PRISMA_BLOCKING_VULNERABILITIES:
+ package_full_name = f"{vulnerability['packageName']}-{vulnerability['packageVersion']}"
+ current_vulnerability_description = vulnerability['description']
+ if package_full_name in excluded_libraries:
+ print(f"ⓘ Package {package_full_name} has vulnerabilities but is in exclusion list.")
+ else:
+ if package_full_name not in vulnerabilities_to_resolve:
+ vulnerabilities_to_resolve[package_full_name] = [current_vulnerability_description]
+ else:
+ vulnerabilities_to_resolve[package_full_name].append(current_vulnerability_description)
+ return vulnerabilities_to_resolve
+
+
+prisma_exclusion_list = get_excluded_packages()
+prisma_vulnerabilities_to_resolve = find_all_high_critical_vulnerabilities_to_resolve(prisma_exclusion_list)
+if len(prisma_vulnerabilities_to_resolve) != 0:
+ print(f"❌ Following {PRISMA_BLOCKING_VULNERABILITIES} Prisma vulnerabilities should get resolved before release: ")
+ for vulnerability_name in prisma_vulnerabilities_to_resolve:
+ print(f"🔴️ {vulnerability_name}")
+ # print descriptions for this vulnerability
+ for vulnerability_description in prisma_vulnerabilities_to_resolve[vulnerability_name]:
+ block_print(f'\t ➡️ {vulnerability_description}\n')
+ exit(1)
+else:
+ print(f"No {PRISMA_BLOCKING_VULNERABILITIES} Prisma vulnerabilities found! ✅")
From be6f1e584446b71789c1c22b418e4ca2eac2f4a5 Mon Sep 17 00:00:00 2001
From: Salman Hooshmand <59615308+shooshmand-sol@users.noreply.github.com>
Date: Fri, 16 Jun 2023 13:51:54 -0400
Subject: [PATCH 19/31] Push EMA main image with release tag to ECR (#91)
---
.github/workflows/release.yaml | 44 ++++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index adec0080..4dea61f0 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -55,19 +55,19 @@ jobs:
export VIRTUAL_ENV=./venv
python3.8 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate
cd ./.github/workflows/release_scripts/ && pip install --quiet -r requirements.txt && python3.8 whitesource_vulnurability_checker.py
- - name: Pre-Release Check - Prisma vulnurabilities
- env:
- PRISMA_ROOT_API_URL: ${{ secrets.PRISMA_ROOT_API_URL }}
- DOCKER_IMAGE_TO_CHECK: ${{ secrets.PRISMA_DOCKER_IMAGE_TO_CHECK }}
- PRISMA_ACCESS_KEY: ${{ secrets.PRISMA_ACCESS_KEY }}
- PRISMA_ACCESS_KEY_SECRET: ${{ secrets.PRISMA_ACCESS_KEY_SECRET }}
- AWS_ACCESS_KEY_ID: ${{ secrets.EMA_AWS_ACCESS_KEY_ID }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.EMA_AWS_SECRET_ACCESS_KEY }}
- AWS_DEFAULT_REGION: ${{ secrets.EMA_AWS_DEFAULT_REGION }}
- run: |
- export VIRTUAL_ENV=./venv
- python3.8 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate
- cd ./.github/workflows/release_scripts/ && python3.8 prisma_vulnurability_checker.py
+# - name: Pre-Release Check - Prisma vulnurabilities
+# env:
+# PRISMA_ROOT_API_URL: ${{ secrets.PRISMA_ROOT_API_URL }}
+# DOCKER_IMAGE_TO_CHECK: ${{ secrets.PRISMA_DOCKER_IMAGE_TO_CHECK }}
+# PRISMA_ACCESS_KEY: ${{ secrets.PRISMA_ACCESS_KEY }}
+# PRISMA_ACCESS_KEY_SECRET: ${{ secrets.PRISMA_ACCESS_KEY_SECRET }}
+# AWS_ACCESS_KEY_ID: ${{ secrets.EMA_AWS_ACCESS_KEY_ID }}
+# AWS_SECRET_ACCESS_KEY: ${{ secrets.EMA_AWS_SECRET_ACCESS_KEY }}
+# AWS_DEFAULT_REGION: ${{ secrets.EMA_AWS_DEFAULT_REGION }}
+# run: |
+# export VIRTUAL_ENV=./venv
+# python3.8 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate
+# cd ./.github/workflows/release_scripts/ && python3.8 prisma_vulnurability_checker.py
- name: Prepare Maven Settings
env:
MAVEN_REPO_SERVER_USERNAME: "${{ github.actor }}"
@@ -96,3 +96,21 @@ jobs:
generateReleaseNotes: true
makeLatest: true
body: ${{ steps.Changelog.outputs.changelog }}
+ - name: Configure AWS credentials
+ uses: aws-actions/configure-aws-credentials@v2
+ with:
+ aws-access-key-id: ${{ secrets.EMA_AWS_ACCESS_KEY_ID }}
+ aws-secret-access-key: ${{ secrets.EMA_AWS_SECRET_ACCESS_KEY }}
+ aws-region: ${{ secrets.EMA_AWS_DEFAULT_REGION }}
+ - name: Login to Amazon ECR
+ id: login-ecr
+ uses: aws-actions/amazon-ecr-login@v1.6.0
+ - name: ECR Docker Image Release
+ run: |
+ MANIFEST=$(aws ecr batch-get-image --repository-name ${{ github.event.repository.name }} \
+ --image-ids imageTag=main --region ${{ secrets.EMA_AWS_DEFAULT_REGION }} --output json \
+ | jq --raw-output '.images[].imageManifest')
+
+ aws ecr put-image --repository-name ${{ github.event.repository.name }} \
+ --image-tag ${{ github.event.inputs.releaseVersion }} \
+ --image-manifest "$MANIFEST" --region ${{ secrets.EMA_AWS_DEFAULT_REGION }}
\ No newline at end of file
From 4f8999dff56325c45e7a97cda0fa11d50a12a3fd Mon Sep 17 00:00:00 2001
From: Abdullah Habes <33485177+AHabes@users.noreply.github.com>
Date: Fri, 23 Jun 2023 13:37:53 -0400
Subject: [PATCH 20/31] Update Swagger UI documentation for manual import (#93)
---
service/application/pom.xml | 2 +-
.../agent/scanManager/rest/DataImportController.java | 4 ----
.../agent/scanManager/rest/DataImportControllerImpl.java | 8 +++++---
.../management/agent/scanManager/rest/EMAController.java | 4 ++--
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index ed38a69f..00c290c9 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -188,7 +188,7 @@
io.swagger.core.v3
swagger-annotations
- 2.2.1
+ 2.2.8
org.mapstruct
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportController.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportController.java
index 40f4d054..2d8e70ee 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportController.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportController.java
@@ -4,7 +4,6 @@
import com.solace.maas.ep.common.model.EventErrorDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -17,9 +16,6 @@ public interface DataImportController {
@Operation(
summary = "Imports data collection files",
description = "Use this API to trigger manual import of data collection for the specified resource.",
- parameters = {
- @Parameter(name = "file", description = "The scan data zip file to be imported.", in = ParameterIn.QUERY)
- },
responses = {
@ApiResponse(
responseCode = "200",
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
index ff49a372..ec77476c 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java
@@ -4,6 +4,7 @@
import com.solace.maas.ep.event.management.agent.scanManager.model.ImportRequestBO;
import com.solace.maas.ep.event.management.agent.scanManager.model.ZipRequestBO;
import com.solace.maas.ep.event.management.agent.service.ImportService;
+import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +18,7 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@@ -37,8 +38,9 @@ public DataImportControllerImpl(ImportService importService) {
}
@Override
- @PostMapping(value = "/import")
- public ResponseEntity read(@RequestParam("file") MultipartFile file) {
+ @PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+ public ResponseEntity read(@Parameter(description = "The scan data zip file to be imported.")
+ @RequestPart("file") final MultipartFile file) {
try {
String traceId = MDC.get("traceId");
ImportRequestBO importRequestBO = ImportRequestBO.builder()
diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAController.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAController.java
index 38702b43..ca5dc544 100644
--- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAController.java
+++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAController.java
@@ -16,8 +16,8 @@ public interface EMAController {
@Operation(
summary = "Triggers data collections",
- description = "Use this API to trigger a data collection for the specified resource.",
- parameters = {@Parameter(description = "The ID of the resource.", name = "resourceId", required = true)},
+ description = "Use this API to trigger a data collection scan for the specified resource.",
+ parameters = {@Parameter(description = "The ID of the resource to be scanned.", name = "resourceId", required = true)},
requestBody = @RequestBody(description = "The scan request object.\n\n" +
"List of scan types:\n" +
"```\n" +
From e640b7a757529f2bbf047c443d9ec157ac255703 Mon Sep 17 00:00:00 2001
From: Salman Hooshmand <59615308+shooshmand-sol@users.noreply.github.com>
Date: Mon, 26 Jun 2023 13:10:43 -0400
Subject: [PATCH 21/31] Check main code does not have any SonarQube security
Hotspots before release
---
.github/workflows/release.yaml | 10 ++++-
.../sonarqube_vulnurability_checker.py | 45 +++++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)
create mode 100644 .github/workflows/release_scripts/sonarqube_vulnurability_checker.py
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 4dea61f0..59ad59c8 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -55,6 +55,14 @@ jobs:
export VIRTUAL_ENV=./venv
python3.8 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate
cd ./.github/workflows/release_scripts/ && pip install --quiet -r requirements.txt && python3.8 whitesource_vulnurability_checker.py
+ - name: Pre-Release Check - SonarQube Hotspots
+ env:
+ SONARQUBE_HOTSPOTS_API_URL: ${{ secrets.SONARQUBE_HOTSPOTS_API_URL }}
+ SONARQUBE_QUERY_TOKEN: ${{ secrets.SONARQUBE_QUERY_TOKEN }}
+ run: |
+ export VIRTUAL_ENV=./venv
+ python3.8 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate
+ cd ./.github/workflows/release_scripts/ && python3.8 sonarqube_vulnurability_checker.py
# - name: Pre-Release Check - Prisma vulnurabilities
# env:
# PRISMA_ROOT_API_URL: ${{ secrets.PRISMA_ROOT_API_URL }}
@@ -110,7 +118,7 @@ jobs:
MANIFEST=$(aws ecr batch-get-image --repository-name ${{ github.event.repository.name }} \
--image-ids imageTag=main --region ${{ secrets.EMA_AWS_DEFAULT_REGION }} --output json \
| jq --raw-output '.images[].imageManifest')
-
+
aws ecr put-image --repository-name ${{ github.event.repository.name }} \
--image-tag ${{ github.event.inputs.releaseVersion }} \
--image-manifest "$MANIFEST" --region ${{ secrets.EMA_AWS_DEFAULT_REGION }}
\ No newline at end of file
diff --git a/.github/workflows/release_scripts/sonarqube_vulnurability_checker.py b/.github/workflows/release_scripts/sonarqube_vulnurability_checker.py
new file mode 100644
index 00000000..03857bc6
--- /dev/null
+++ b/.github/workflows/release_scripts/sonarqube_vulnurability_checker.py
@@ -0,0 +1,45 @@
+import requests
+import os
+import textwrap
+
+SONARQUBE_PROJECT_KEY = "SolaceLabs_event-management-agent"
+SONARQUBE_PROJECT_MAIN_BRANCH = "main"
+SONARQUBE_QUERY_TOKEN = os.getenv("SONARQUBE_QUERY_TOKEN")
+SONARQUBE_HOTSPOTS_API_URL = os.getenv("SONARQUBE_HOTSPOTS_API_URL")
+SONARQUBE_BLOCKING_VULNERABILITIES = "HIGH"
+SONARQUBE_BLOCKING_HOTSPOT_STATUS = 'TO_REVIEW'
+
+
+def block_print(long_string, each_line_length=75):
+ print("\n\t".join(textwrap.wrap(long_string, each_line_length)))
+
+
+def find_all_high_critical_vulnerabilities_to_resolve():
+ sonarqube_hotspot_query_params = {
+ "projectKey": SONARQUBE_PROJECT_KEY,
+ "branch": SONARQUBE_PROJECT_MAIN_BRANCH,
+ "status": SONARQUBE_BLOCKING_HOTSPOT_STATUS
+ }
+
+ hotspots_response = requests.get(
+ SONARQUBE_HOTSPOTS_API_URL,
+ params=sonarqube_hotspot_query_params,
+ auth=(SONARQUBE_QUERY_TOKEN, '')).json()
+
+ print(f"Total hotspots found for service: {SONARQUBE_PROJECT_KEY} is {hotspots_response['paging']['total']}")
+ hotspots_to_resolve = dict()
+ for hotspot in hotspots_response['hotspots']:
+ if hotspot['vulnerabilityProbability'] in SONARQUBE_BLOCKING_VULNERABILITIES:
+ hotspots_to_resolve[f"{hotspot['component']}:{hotspot['line']}"] = hotspot["message"]
+ return hotspots_to_resolve
+
+
+hotspots_to_resolve = find_all_high_critical_vulnerabilities_to_resolve()
+if len(hotspots_to_resolve) != 0:
+ print(f"❌ Following {SONARQUBE_BLOCKING_VULNERABILITIES} SonarQube hotspots should get resolved before release: ")
+ for hotspot in hotspots_to_resolve:
+ block_print(f"🔴️ {hotspot}")
+ block_print(f'\t ➡️ {hotspots_to_resolve[hotspot]}\n')
+ exit(1)
+else:
+ print(f"No non-reviewed {SONARQUBE_BLOCKING_VULNERABILITIES} SonarQube hotspots found! ✅")
From edf04b26e62de363952853cb04b9ce11333890e0 Mon Sep 17 00:00:00 2001
From: Abdullah Habes <33485177+AHabes@users.noreply.github.com>
Date: Mon, 26 Jun 2023 13:34:57 -0400
Subject: [PATCH 22/31] Fix reported whitesource vulnerabilities (#94)
---
service/application/pom.xml | 8 ++++++++
service/kafka-plugin/pom.xml | 10 ++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index 00c290c9..a58ec962 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -17,6 +17,8 @@
1.6.11
2.0
3.1.5
+ 2.9.0
+ 3.4.0
@@ -56,6 +58,12 @@
org.springframework.kafka
spring-kafka
+ ${spring-kafka.version}
+
+
+ org.apache.kafka
+ kafka-clients
+ ${kafka-clients.version}
org.springframework.boot
diff --git a/service/kafka-plugin/pom.xml b/service/kafka-plugin/pom.xml
index d609c5ea..b36a6afa 100644
--- a/service/kafka-plugin/pom.xml
+++ b/service/kafka-plugin/pom.xml
@@ -10,7 +10,8 @@
11
11
- 2.9.0
+ 2.9.0
+ 3.4.0
2.7.6
4.4
5.3.1
@@ -26,7 +27,12 @@
org.springframework.kafka
spring-kafka
- ${spring-kafka.vresion}
+ ${spring-kafka.version}
+
+
+ org.apache.kafka
+ kafka-clients
+ ${kafka-clients.version}
org.springframework.boot
From a8727ae8c8da9e6096d78ae7f32e5a1c26fac75d Mon Sep 17 00:00:00 2001
From: Abdullah Habes <33485177+AHabes@users.noreply.github.com>
Date: Mon, 26 Jun 2023 18:01:33 -0400
Subject: [PATCH 23/31] Fix whitesource vulnerabilites (#96)
---
service/application/pom.xml | 7 ++++++-
service/kafka-plugin/pom.xml | 2 +-
service/plugin/pom.xml | 5 +++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index a58ec962..e55d02cc 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -18,7 +18,7 @@
2.0
3.1.5
2.9.0
- 3.4.0
+ 3.5.0
@@ -37,6 +37,11 @@
+
+ org.apache.tomcat.embed
+ tomcat-embed-core
+ 9.0.75
+
org.springframework.boot
spring-boot-autoconfigure
diff --git a/service/kafka-plugin/pom.xml b/service/kafka-plugin/pom.xml
index b36a6afa..4ed3ee06 100644
--- a/service/kafka-plugin/pom.xml
+++ b/service/kafka-plugin/pom.xml
@@ -11,7 +11,7 @@
11
11
2.9.0
- 3.4.0
+ 3.5.0
2.7.6
4.4
5.3.1
diff --git a/service/plugin/pom.xml b/service/plugin/pom.xml
index ba0d7821..dbcdca55 100644
--- a/service/plugin/pom.xml
+++ b/service/plugin/pom.xml
@@ -29,6 +29,11 @@
+
+ org.apache.tomcat.embed
+ tomcat-embed-core
+ 9.0.75
+
org.springframework.boot
spring-boot-autoconfigure
From 0c96476467598015890b73bcfb9723238f8cb1b5 Mon Sep 17 00:00:00 2001
From: Abdullah Habes <33485177+AHabes@users.noreply.github.com>
Date: Tue, 27 Jun 2023 10:32:41 -0400
Subject: [PATCH 24/31] Fix snappy java vulnerability (#97)
---
service/application/pom.xml | 5 +++++
service/kafka-plugin/pom.xml | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index e55d02cc..d5ab0ba0 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -70,6 +70,11 @@
kafka-clients
${kafka-clients.version}
+
+ org.xerial.snappy
+ snappy-java
+ 1.1.10.1
+
org.springframework.boot
spring-boot-loader
diff --git a/service/kafka-plugin/pom.xml b/service/kafka-plugin/pom.xml
index 4ed3ee06..b231045a 100644
--- a/service/kafka-plugin/pom.xml
+++ b/service/kafka-plugin/pom.xml
@@ -34,6 +34,11 @@
kafka-clients
${kafka-clients.version}
+
+ org.xerial.snappy
+ snappy-java
+ 1.1.10.1
+
org.springframework.boot
spring-boot-starter-test
From adecce7e5169563c42f6e4d7a39bd613bee82fae Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Tue, 27 Jun 2023 18:27:27 +0000
Subject: [PATCH 25/31] [ci skip] prepare release v1.0.1
---
service/application/pom.xml | 14 +++++++-------
service/confluent-schema-registry-plugin/pom.xml | 4 ++--
service/kafka-plugin/pom.xml | 4 ++--
service/local-storage-plugin/pom.xml | 4 ++--
service/plugin/pom.xml | 4 ++--
service/pom.xml | 4 ++--
service/rabbitmq-plugin/pom.xml | 4 ++--
service/solace-plugin/pom.xml | 4 ++--
8 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index d5ab0ba0..e5c3a5c1 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -4,12 +4,12 @@
com.solace.maas
maas-event-management-agent-parent
- 1.0.1-SNAPSHOT
+ 1.0.1
..
com.solace.maas
event-management-agent
- 1.0.1-SNAPSHOT
+ 1.0.1
jar
Solace Event Management Agent - Application
Solace Event Management Agent - Application
@@ -167,27 +167,27 @@
com.solace.maas
plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
com.solace.maas.plugin.kafka
kafka-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
com.solace.maas.plugin.solace
solace-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
com.solace.maas.plugin.localstorage
local-storage-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
com.solace.maas.plugin.confluent-schema-registry
confluent-schema-registry-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
diff --git a/service/confluent-schema-registry-plugin/pom.xml b/service/confluent-schema-registry-plugin/pom.xml
index 6866642c..34e4faff 100644
--- a/service/confluent-schema-registry-plugin/pom.xml
+++ b/service/confluent-schema-registry-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.confluent-schema-registry
confluent-schema-registry-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
jar
Solace Event Management Agent - Confluent Schema Registry Plugin
Solace Event Management Agent - Confluent Schema Registry Plugin
@@ -22,7 +22,7 @@
com.solace.maas
plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
org.springframework.boot
diff --git a/service/kafka-plugin/pom.xml b/service/kafka-plugin/pom.xml
index b231045a..4223ea2d 100644
--- a/service/kafka-plugin/pom.xml
+++ b/service/kafka-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.kafka
kafka-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
jar
Solace Event Management Agent - Kafka Plugin
Solace Event Management Agent - Kafka Plugin
@@ -59,7 +59,7 @@
com.solace.maas
plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
org.junit.jupiter
diff --git a/service/local-storage-plugin/pom.xml b/service/local-storage-plugin/pom.xml
index 58146613..bc9e1036 100644
--- a/service/local-storage-plugin/pom.xml
+++ b/service/local-storage-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.localstorage
local-storage-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
jar
Solace Event Management Agent - Local Storage Plugin
Solace Event Management Agent - Local Storage Plugin
@@ -91,7 +91,7 @@
com.solace.maas
plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
org.json
diff --git a/service/plugin/pom.xml b/service/plugin/pom.xml
index dbcdca55..104519c0 100644
--- a/service/plugin/pom.xml
+++ b/service/plugin/pom.xml
@@ -4,12 +4,12 @@
com.solace.maas
maas-event-management-agent-parent
- 1.0.1-SNAPSHOT
+ 1.0.1
..
com.solace.maas
plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
jar
Solace Event Management Agent - Plugin
Solace Event Management Agent - Plugin
diff --git a/service/pom.xml b/service/pom.xml
index 7e179e61..8fdb373d 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -9,7 +9,7 @@
com.solace.maas
maas-event-management-agent-parent
- 1.0.1-SNAPSHOT
+ 1.0.1
pom
Solace Event Management Agent Maven Parent
Solace Solace Event Management Agent Maven Parent
@@ -401,7 +401,7 @@
scm:git:${project.scm.url}
scm:git:${project.scm.url}
git@github.com:SolaceLabs/event-management-agent.git
- HEAD
+ v1.0.1
diff --git a/service/rabbitmq-plugin/pom.xml b/service/rabbitmq-plugin/pom.xml
index 1415bd12..ed7631b4 100644
--- a/service/rabbitmq-plugin/pom.xml
+++ b/service/rabbitmq-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.rabbitmq
rabbitmq-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
jar
Solace Event Management Agent - RabbitMQ Plugin
Solace Event Management Agent - RabbitMQ Plugin
@@ -25,7 +25,7 @@
com.solace.maas
plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
diff --git a/service/solace-plugin/pom.xml b/service/solace-plugin/pom.xml
index 265b33ed..286592a6 100644
--- a/service/solace-plugin/pom.xml
+++ b/service/solace-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.solace
solace-plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
jar
Solace Event Management Agent - Solace Plugin
Solace Event Management Agent - Solace Plugin
@@ -69,7 +69,7 @@
com.solace.maas
plugin
- 1.0.1-SNAPSHOT
+ 1.0.1
org.yaml
From 61df62339f65997caa099f0ad63c2b6d6c66c7be Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Tue, 27 Jun 2023 18:27:30 +0000
Subject: [PATCH 26/31] [ci skip] prepare for next development iteration
---
service/application/pom.xml | 14 +++++++-------
service/confluent-schema-registry-plugin/pom.xml | 4 ++--
service/kafka-plugin/pom.xml | 4 ++--
service/local-storage-plugin/pom.xml | 4 ++--
service/plugin/pom.xml | 4 ++--
service/pom.xml | 4 ++--
service/rabbitmq-plugin/pom.xml | 4 ++--
service/solace-plugin/pom.xml | 4 ++--
8 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index e5c3a5c1..0e05987c 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -4,12 +4,12 @@
com.solace.maas
maas-event-management-agent-parent
- 1.0.1
+ 1.0.2-SNAPSHOT
..
com.solace.maas
event-management-agent
- 1.0.1
+ 1.0.2-SNAPSHOT
jar
Solace Event Management Agent - Application
Solace Event Management Agent - Application
@@ -167,27 +167,27 @@
com.solace.maas
plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
com.solace.maas.plugin.kafka
kafka-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
com.solace.maas.plugin.solace
solace-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
com.solace.maas.plugin.localstorage
local-storage-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
com.solace.maas.plugin.confluent-schema-registry
confluent-schema-registry-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
diff --git a/service/confluent-schema-registry-plugin/pom.xml b/service/confluent-schema-registry-plugin/pom.xml
index 34e4faff..2b4ed20d 100644
--- a/service/confluent-schema-registry-plugin/pom.xml
+++ b/service/confluent-schema-registry-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.confluent-schema-registry
confluent-schema-registry-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
jar
Solace Event Management Agent - Confluent Schema Registry Plugin
Solace Event Management Agent - Confluent Schema Registry Plugin
@@ -22,7 +22,7 @@
com.solace.maas
plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
org.springframework.boot
diff --git a/service/kafka-plugin/pom.xml b/service/kafka-plugin/pom.xml
index 4223ea2d..66a687b8 100644
--- a/service/kafka-plugin/pom.xml
+++ b/service/kafka-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.kafka
kafka-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
jar
Solace Event Management Agent - Kafka Plugin
Solace Event Management Agent - Kafka Plugin
@@ -59,7 +59,7 @@
com.solace.maas
plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
org.junit.jupiter
diff --git a/service/local-storage-plugin/pom.xml b/service/local-storage-plugin/pom.xml
index bc9e1036..121f739f 100644
--- a/service/local-storage-plugin/pom.xml
+++ b/service/local-storage-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.localstorage
local-storage-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
jar
Solace Event Management Agent - Local Storage Plugin
Solace Event Management Agent - Local Storage Plugin
@@ -91,7 +91,7 @@
com.solace.maas
plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
org.json
diff --git a/service/plugin/pom.xml b/service/plugin/pom.xml
index 104519c0..c5710255 100644
--- a/service/plugin/pom.xml
+++ b/service/plugin/pom.xml
@@ -4,12 +4,12 @@
com.solace.maas
maas-event-management-agent-parent
- 1.0.1
+ 1.0.2-SNAPSHOT
..
com.solace.maas
plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
jar
Solace Event Management Agent - Plugin
Solace Event Management Agent - Plugin
diff --git a/service/pom.xml b/service/pom.xml
index 8fdb373d..cf0aaadd 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -9,7 +9,7 @@
com.solace.maas
maas-event-management-agent-parent
- 1.0.1
+ 1.0.2-SNAPSHOT
pom
Solace Event Management Agent Maven Parent
Solace Solace Event Management Agent Maven Parent
@@ -401,7 +401,7 @@
scm:git:${project.scm.url}
scm:git:${project.scm.url}
git@github.com:SolaceLabs/event-management-agent.git
- v1.0.1
+ HEAD
diff --git a/service/rabbitmq-plugin/pom.xml b/service/rabbitmq-plugin/pom.xml
index ed7631b4..1401ff65 100644
--- a/service/rabbitmq-plugin/pom.xml
+++ b/service/rabbitmq-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.rabbitmq
rabbitmq-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
jar
Solace Event Management Agent - RabbitMQ Plugin
Solace Event Management Agent - RabbitMQ Plugin
@@ -25,7 +25,7 @@
com.solace.maas
plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
diff --git a/service/solace-plugin/pom.xml b/service/solace-plugin/pom.xml
index 286592a6..11feac59 100644
--- a/service/solace-plugin/pom.xml
+++ b/service/solace-plugin/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solace.maas.plugin.solace
solace-plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
jar
Solace Event Management Agent - Solace Plugin
Solace Event Management Agent - Solace Plugin
@@ -69,7 +69,7 @@
com.solace.maas
plugin
- 1.0.1
+ 1.0.2-SNAPSHOT
org.yaml
From d7344c3a20241d0c8b3efa53d8c3e63521f652b2 Mon Sep 17 00:00:00 2001
From: Abdullah Habes <33485177+AHabes@users.noreply.github.com>
Date: Thu, 29 Jun 2023 17:08:48 -0400
Subject: [PATCH 27/31] Fix whitesource vulnerabilities (#98)
---
service/application/pom.xml | 16 ++++++++++++++++
service/plugin/pom.xml | 10 ++++++++++
service/solace-plugin/pom.xml | 5 +++++
3 files changed, 31 insertions(+)
diff --git a/service/application/pom.xml b/service/application/pom.xml
index 0e05987c..12742bbc 100644
--- a/service/application/pom.xml
+++ b/service/application/pom.xml
@@ -17,6 +17,7 @@
1.6.11
2.0
3.1.5
+ 1.1.1
2.9.0
3.5.0
@@ -60,6 +61,11 @@
spring-cloud-starter-sleuth
${spring-cloud-starter-sleuth.version}
+
+ org.springframework.security
+ spring-security-rsa
+ ${spring-security-rsa.version}
+
org.springframework.kafka
spring-kafka
@@ -144,11 +150,21 @@
org.springframework.boot
spring-boot-starter-webflux
+
+ io.netty
+ netty-codec-http
+ 4.1.94.Final
+
org.apache.commons
commons-collections4
4.4
+
+ io.netty
+ netty-handler
+ 4.1.94.Final
+
net.logstash.logback
diff --git a/service/plugin/pom.xml b/service/plugin/pom.xml
index c5710255..f729ff3b 100644
--- a/service/plugin/pom.xml
+++ b/service/plugin/pom.xml
@@ -47,6 +47,16 @@
org.springframework.boot
spring-boot-starter-webflux
+
+ io.netty
+ netty-codec-http
+ 4.1.94.Final
+
+
+ io.netty
+ netty-handler
+ 4.1.94.Final
+
org.apache.camel.springboot
camel-spring-boot-starter
diff --git a/service/solace-plugin/pom.xml b/service/solace-plugin/pom.xml
index 11feac59..cbbbae7e 100644
--- a/service/solace-plugin/pom.xml
+++ b/service/solace-plugin/pom.xml
@@ -44,6 +44,11 @@
+
+ io.netty
+ netty-codec-http
+ 4.1.94.Final
+
org.springframework.boot
spring-boot-starter-test
From 93fe19e8686cc14e18f061709a57ebcf9eb64277 Mon Sep 17 00:00:00 2001
From: Abdullah Habes <33485177+AHabes@users.noreply.github.com>
Date: Thu, 29 Jun 2023 17:18:10 -0400
Subject: [PATCH 28/31] Introduce KafkaClientConfig to make Kafka AdminClient
properties configurable. (#92)
---
.../src/main/resources/application.yml | 21 +++
.../ep/event/management/agent/TestConfig.java | 59 ++++++++
.../KafkaBrokerConfigurationProcessor.java | 10 +-
.../KafkaClusterConfigurationProcessor.java | 10 +-
...kaConsumerGroupConfigurationProcessor.java | 10 +-
.../consumer/KafkaConsumerGroupProcessor.java | 10 +-
.../feature/KafkaFeaturesProcessor.java | 12 +-
...kaOverrideTopicConfigurationProcessor.java | 10 +-
.../KafkaTopicConfigurationProcessor.java | 10 +-
.../topic/KafkaTopicListingProcessor.java | 10 +-
.../topic/KafkaTopicProducerProcessor.java | 10 +-
.../manager/client/KafkaClientConfigImpl.java | 5 +-
.../client/KafkaClientManagerImpl.java | 35 ++++-
.../client/kafkaClient/KafkaClientConfig.java | 20 +++
.../kafkaClient/KafkaClientConnection.java | 18 +++
.../KafkaClientConnectionConfig.java | 18 +++
.../kafkaClient/KafkaClientReconnection.java | 17 +++
.../KafkaClientReconnectionConfig.java | 17 +++
.../agent/plugin/KafkaTestConfig.java | 48 ++++++
.../client/KafkaClientManagerTests.java | 93 ++++++++++--
...afkaBrokerConfigurationProcessorTests.java | 139 ++++++++++++++++++
...fkaClusterConfigurationProcessorTests.java | 122 +++++++++++++++
...sumerGroupConfigurationProcessorTests.java | 58 +++++++-
.../KafkaConsumerGroupProcessorTests.java | 57 ++++++-
...KafkaTopicConfigurationProcessorTests.java | 117 ++++++++++++---
.../KafkaTopicListingProcessorTests.java | 59 +++++++-
.../delegate/KafkaRouteDelegateImplTests.java | 14 +-
27 files changed, 927 insertions(+), 82 deletions(-)
create mode 100644 service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConfig.java
create mode 100644 service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnection.java
create mode 100644 service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnectionConfig.java
create mode 100644 service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnection.java
create mode 100644 service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnectionConfig.java
rename service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/{manager => kafka}/client/KafkaClientManagerTests.java (51%)
create mode 100644 service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/KafkaBrokerConfigurationProcessorTests.java
create mode 100644 service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/KafkaClusterConfigurationProcessorTests.java
diff --git a/service/application/src/main/resources/application.yml b/service/application/src/main/resources/application.yml
index b554f2d9..34d210ea 100644
--- a/service/application/src/main/resources/application.yml
+++ b/service/application/src/main/resources/application.yml
@@ -39,6 +39,27 @@ camel:
springboot:
use-mdc-logging: true
+kafka:
+ client:
+ config:
+ connections:
+ timeout:
+ value: 60_000
+ unit: milliseconds
+ max-idle:
+ value: 10_000
+ unit: milliseconds
+ request-timeout:
+ value: 5_000
+ unit: milliseconds
+ reconnections:
+ backoff:
+ value: 50
+ unit: milliseconds
+ max-backoff:
+ value: 1_000
+ unit: milliseconds
+
eventPortal:
runtimeAgentId: ${EP_RUNTIME_AGENT_ID:defaultAgentId}
organizationId: ${EP_ORGANIZATION_ID:defaultOrgId}
diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java
index 4a509114..e00a262e 100644
--- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java
+++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java
@@ -3,6 +3,11 @@
import com.solace.maas.ep.event.management.agent.messagingServices.RtoMessagingService;
import com.solace.maas.ep.event.management.agent.plugin.config.VMRProperties;
import com.solace.maas.ep.event.management.agent.plugin.config.eventPortal.EventPortalPluginProperties;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnectionConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnectionConfig;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.RtoMessageBuilder;
import com.solace.maas.ep.event.management.agent.plugin.vmr.VmrProcessor;
import com.solace.maas.ep.event.management.agent.testConfigs.MessagingServiceTestConfig;
@@ -24,6 +29,7 @@
import java.util.Properties;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -36,6 +42,7 @@ public class TestConfig {
@Autowired
ProducerTemplate producerTemplate;
+
@Autowired
private CamelContext camelContext;
@@ -111,4 +118,56 @@ public IDGenerator idGenerator() {
idGenerator.setRandom(random());
return idGenerator;
}
+
+ @Bean
+ @Primary
+ KafkaClientConnection kafkaClientConnection() {
+ return mock(KafkaClientConnection.class);
+ }
+
+ @Bean
+ @Primary
+ KafkaClientReconnection kafkaClientReconnection() {
+ return mock(KafkaClientReconnection.class);
+ }
+
+ @Bean
+ @Primary
+ public KafkaClientConfig kafkaClientConfig() {
+ KafkaClientConfig kafkaClientConfig = mock(KafkaClientConfig.class);
+ KafkaClientConnection kafkaClientConnection = mock(KafkaClientConnection.class);
+ KafkaClientReconnection kafkaClientReconnection = mock(KafkaClientReconnection.class);
+
+ KafkaClientConnectionConfig kafkaClientConnectionConfigTimeout = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigMaxIdle = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigRequestTimeout = mock(KafkaClientConnectionConfig.class);
+
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoff = mock(KafkaClientReconnectionConfig.class);
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoffMax = mock(KafkaClientReconnectionConfig.class);
+
+ when(kafkaClientConfig.getConnections()).thenReturn(kafkaClientConnection);
+ when(kafkaClientConfig.getReconnections()).thenReturn(kafkaClientReconnection);
+
+ when(kafkaClientConnection.getTimeout()).thenReturn(kafkaClientConnectionConfigTimeout);
+ when(kafkaClientConnectionConfigTimeout.getValue()).thenReturn(60_000);
+ when(kafkaClientConnectionConfigTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getMaxIdle()).thenReturn(kafkaClientConnectionConfigMaxIdle);
+ when(kafkaClientConnectionConfigMaxIdle.getValue()).thenReturn(10_000);
+ when(kafkaClientConnectionConfigMaxIdle.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getRequestTimeout()).thenReturn(kafkaClientConnectionConfigRequestTimeout);
+ when(kafkaClientConnectionConfigRequestTimeout.getValue()).thenReturn(5_000);
+ when(kafkaClientConnectionConfigRequestTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getBackoff()).thenReturn(kafkaClientReconnectionConfigBackoff);
+ when(kafkaClientReconnectionConfigBackoff.getValue()).thenReturn(50);
+ when(kafkaClientReconnectionConfigBackoff.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getMaxBackoff()).thenReturn(kafkaClientReconnectionConfigBackoffMax);
+ when(kafkaClientReconnectionConfigBackoffMax.getValue()).thenReturn(1000);
+ when(kafkaClientReconnectionConfigBackoffMax.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ return kafkaClientConfig;
+ }
}
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaBrokerConfigurationProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaBrokerConfigurationProcessor.java
index d7ceed15..da24dccd 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaBrokerConfigurationProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaBrokerConfigurationProcessor.java
@@ -2,6 +2,7 @@
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.cluster.KafkaBrokerConfigurationEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.cluster.KafkaClusterConfigurationEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.general.KafkaConfigurationEntryEvent;
@@ -25,11 +26,16 @@
public class KafkaBrokerConfigurationProcessor extends ResultProcessorImpl,
List> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaBrokerConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaBrokerConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
@Override
@@ -45,7 +51,7 @@ public List handleEvent(Map prope
.collect(Collectors.toUnmodifiableList());
return adminClient.describeConfigs(brokers).all()
- .get(30, TimeUnit.SECONDS)
+ .get(timeout, timeUnit)
.entrySet()
.stream()
.map(result -> {
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaClusterConfigurationProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaClusterConfigurationProcessor.java
index 6c52d973..d4df7af2 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaClusterConfigurationProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/cluster/KafkaClusterConfigurationProcessor.java
@@ -2,6 +2,7 @@
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.cluster.KafkaClusterConfigurationEvent;
import com.solace.maas.ep.event.management.agent.plugin.processor.base.ResultProcessorImpl;
import com.solace.maas.ep.event.management.agent.plugin.service.MessagingServiceDelegateService;
@@ -21,11 +22,16 @@
@SuppressWarnings("PMD")
public class KafkaClusterConfigurationProcessor extends ResultProcessorImpl, Void> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaClusterConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaClusterConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
@Override
@@ -37,7 +43,7 @@ public List handleEvent(Map prop
return adminClient.describeCluster()
.nodes()
- .get(30, TimeUnit.SECONDS)
+ .get(timeout, timeUnit)
.stream()
.map(node -> KafkaClusterConfigurationEvent.builder()
.id(node.idString())
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupConfigurationProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupConfigurationProcessor.java
index df36e933..3e05c721 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupConfigurationProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupConfigurationProcessor.java
@@ -1,6 +1,7 @@
package com.solace.maas.ep.event.management.agent.plugin.kafka.processor.consumer;
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.consumer.ConsumerEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.consumer.ConsumerTopicPartitionEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.consumer.KafkaConsumerGroupConfigurationEvent;
@@ -33,11 +34,16 @@ public class KafkaConsumerGroupConfigurationProcessor extends
ResultProcessorImpl, List> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaConsumerGroupConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaConsumerGroupConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
private KafkaConsumerGroupEvent mapConsumerGroupEvent(ConsumerGroupDescription consumerGroupDescription) {
@@ -123,7 +129,7 @@ public List handleEvent(Map ConsumerGroupDescriptionMap =
describeConsumerGroupsResult
.all()
- .get(30, TimeUnit.SECONDS);
+ .get(timeout, timeUnit);
ConsumerGroupDescriptionMap
.forEach((key, consumerGroupDescription) -> {
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupProcessor.java
index f07f492f..dc54d7a7 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/consumer/KafkaConsumerGroupProcessor.java
@@ -1,6 +1,7 @@
package com.solace.maas.ep.event.management.agent.plugin.kafka.processor.consumer;
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.consumer.KafkaConsumerGroupEvent;
import com.solace.maas.ep.event.management.agent.plugin.processor.base.ResultProcessorImpl;
import com.solace.maas.ep.event.management.agent.plugin.service.MessagingServiceDelegateService;
@@ -23,11 +24,16 @@
@Component
public class KafkaConsumerGroupProcessor extends ResultProcessorImpl, Void> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaConsumerGroupProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaConsumerGroupProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
@Override
@@ -39,7 +45,7 @@ public List handleEvent(Map properties,
ListConsumerGroupsResult listConsumerGroupsResult = adminClient.listConsumerGroups();
Collection consumerGroupListings = listConsumerGroupsResult.all()
- .get(30, TimeUnit.SECONDS);
+ .get(timeout, timeUnit);
return consumerGroupListings
.stream()
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/feature/KafkaFeaturesProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/feature/KafkaFeaturesProcessor.java
index d6161e21..a2e2a1b7 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/feature/KafkaFeaturesProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/feature/KafkaFeaturesProcessor.java
@@ -2,6 +2,7 @@
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.feature.KafkaFeatureEvent;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.processor.base.ResultProcessorImpl;
import com.solace.maas.ep.event.management.agent.plugin.service.MessagingServiceDelegateService;
import lombok.extern.slf4j.Slf4j;
@@ -19,11 +20,16 @@
@Component
public class KafkaFeaturesProcessor extends ResultProcessorImpl, Void> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaFeaturesProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaFeaturesProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
@Override
@@ -35,7 +41,7 @@ public List handleEvent(Map properties, Void
List finalizedFeatures = new ArrayList<>(adminClient.describeFeatures()
.featureMetadata()
- .get(30, TimeUnit.SECONDS)
+ .get(timeout, timeUnit)
.finalizedFeatures()
.entrySet()
.stream()
@@ -49,7 +55,7 @@ public List handleEvent(Map properties, Void
List supportedFeatures = adminClient.describeFeatures()
.featureMetadata()
- .get(30, TimeUnit.SECONDS)
+ .get(timeout, timeUnit)
.supportedFeatures()
.entrySet()
.stream()
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaOverrideTopicConfigurationProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaOverrideTopicConfigurationProcessor.java
index 9dcf90cf..e8838378 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaOverrideTopicConfigurationProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaOverrideTopicConfigurationProcessor.java
@@ -2,6 +2,7 @@
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.general.KafkaConfigurationEntryEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.topic.KafkaOverrideTopicConfigurationEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.topic.KafkaTopicEvent;
@@ -25,11 +26,16 @@
public class KafkaOverrideTopicConfigurationProcessor
extends ResultProcessorImpl, List> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaOverrideTopicConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaOverrideTopicConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
@Override
@@ -45,7 +51,7 @@ public List handleEvent(Map {
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicConfigurationProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicConfigurationProcessor.java
index 4654aa97..780b98ee 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicConfigurationProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicConfigurationProcessor.java
@@ -2,6 +2,7 @@
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.general.KafkaAclEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.general.KafkaNodeEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.topic.KafkaTopicConfigurationEvent;
@@ -32,11 +33,16 @@
@SuppressWarnings("PMD")
public class KafkaTopicConfigurationProcessor extends ResultProcessorImpl, List> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaTopicConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaTopicConfigurationProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
private List mapPartition(List partitions) {
@@ -103,7 +109,7 @@ public List handleEvent(Map proper
if (!topicNames.isEmpty()) {
DescribeTopicsResult describeTopicsResult = adminClient.describeTopics(topicNames);
List topicConfigDetails = describeTopicsResult.all()
- .get(30, TimeUnit.SECONDS)
+ .get(timeout, timeUnit)
.values()
.stream()
.map(result -> {
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicListingProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicListingProcessor.java
index 16100588..da20753d 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicListingProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicListingProcessor.java
@@ -1,6 +1,7 @@
package com.solace.maas.ep.event.management.agent.plugin.kafka.processor.topic;
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.topic.KafkaTopicEvent;
import com.solace.maas.ep.event.management.agent.plugin.processor.base.ResultProcessorImpl;
import com.solace.maas.ep.event.management.agent.plugin.service.MessagingServiceDelegateService;
@@ -22,11 +23,16 @@
@Component
public class KafkaTopicListingProcessor extends ResultProcessorImpl, Void> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaTopicListingProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaTopicListingProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
@Override
@@ -38,7 +44,7 @@ public List handleEvent(Map properties, Void bo
ListTopicsResult listTopicsResult = adminClient.listTopics();
Collection topicListings = listTopicsResult.listings()
- .get(30, TimeUnit.SECONDS);
+ .get(timeout, timeUnit);
return topicListings
.stream()
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicProducerProcessor.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicProducerProcessor.java
index a6569e52..c7f86a7b 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicProducerProcessor.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/topic/KafkaTopicProducerProcessor.java
@@ -2,6 +2,7 @@
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.producer.KafkaProducerEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.producer.KafkaProducerStateEvent;
import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.topic.KafkaTopicConfigurationEvent;
@@ -26,11 +27,16 @@
@SuppressWarnings("PMD")
public class KafkaTopicProducerProcessor extends ResultProcessorImpl, List> {
private final MessagingServiceDelegateService messagingServiceDelegateService;
+ private final long timeout;
+ private final TimeUnit timeUnit;
@Autowired
- public KafkaTopicProducerProcessor(MessagingServiceDelegateService messagingServiceDelegateService) {
+ public KafkaTopicProducerProcessor(MessagingServiceDelegateService messagingServiceDelegateService,
+ KafkaClientConfig kafkaClientConfig) {
super();
this.messagingServiceDelegateService = messagingServiceDelegateService;
+ timeout = kafkaClientConfig.getConnections().getTimeout().getValue();
+ timeUnit = kafkaClientConfig.getConnections().getTimeout().getUnit();
}
@Override
@@ -48,7 +54,7 @@ public List handleEvent(Map properties, List
DescribeProducersResult describeProducersResult = adminClient.describeProducers(partitions);
return describeProducersResult.all()
- .get(30, TimeUnit.SECONDS)
+ .get(timeout, timeUnit)
.entrySet()
.stream()
.map(entries -> {
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientConfigImpl.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientConfigImpl.java
index 7536e394..076a8c54 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientConfigImpl.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientConfigImpl.java
@@ -1,10 +1,11 @@
package com.solace.maas.ep.event.management.agent.plugin.manager.client;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import org.springframework.context.annotation.Configuration;
@Configuration
public class KafkaClientConfigImpl extends MessagingServiceClientConfig {
- protected KafkaClientConfigImpl() {
- super("KAFKA", new KafkaClientManagerImpl());
+ protected KafkaClientConfigImpl(KafkaClientConfig kafkaClientConfig) {
+ super("KAFKA", new KafkaClientManagerImpl(kafkaClientConfig));
}
}
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientManagerImpl.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientManagerImpl.java
index a066b997..5bfd67ef 100644
--- a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientManagerImpl.java
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientManagerImpl.java
@@ -1,5 +1,6 @@
package com.solace.maas.ep.event.management.agent.plugin.manager.client;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.AuthenticationDetailsEvent;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.ConnectionDetailsEvent;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.CredentialDetailsEvent;
@@ -15,6 +16,7 @@
import java.util.Optional;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -24,6 +26,31 @@
@Slf4j
@Data
public class KafkaClientManagerImpl implements MessagingServiceClientManager {
+ private final int maxIdle;
+ private final TimeUnit maxIdleTimeUnit;
+
+ private final int requestTimeout;
+ private final TimeUnit requestTimeoutTimeUnit;
+
+ private final int reconnectBackoff;
+ private final TimeUnit reconnectBackoffTimeUnit;
+
+ private final int maxReconnectBackoff;
+ private final TimeUnit maxReconnectBackoffTimeUnit;
+
+ public KafkaClientManagerImpl(KafkaClientConfig kafkaClientConfig) {
+ this.maxIdle = kafkaClientConfig.getConnections().getMaxIdle().getValue();
+ this.maxIdleTimeUnit = kafkaClientConfig.getConnections().getMaxIdle().getUnit();
+
+ this.requestTimeout = kafkaClientConfig.getConnections().getRequestTimeout().getValue();
+ this.requestTimeoutTimeUnit = kafkaClientConfig.getConnections().getRequestTimeout().getUnit();
+
+ this.reconnectBackoff = kafkaClientConfig.getReconnections().getBackoff().getValue();
+ this.reconnectBackoffTimeUnit = kafkaClientConfig.getReconnections().getBackoff().getUnit();
+
+ this.maxReconnectBackoff = kafkaClientConfig.getReconnections().getMaxBackoff().getValue();
+ this.maxReconnectBackoffTimeUnit = kafkaClientConfig.getReconnections().getMaxBackoff().getUnit();
+ }
@Override
public AdminClient getClient(ConnectionDetailsEvent connectionDetailsEvent) {
@@ -42,11 +69,13 @@ public AdminClient getClient(ConnectionDetailsEvent connectionDetailsEvent) {
}
}
- Properties buildProperties(ConnectionDetailsEvent connectionDetailsEvent) {
+ public Properties buildProperties(ConnectionDetailsEvent connectionDetailsEvent) {
Properties properties = new Properties();
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, connectionDetailsEvent.getUrl());
- properties.put(ConsumerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG, 10_000);
- properties.put(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, 5000);
+ properties.put(ConsumerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG, maxIdle);
+ properties.put(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, requestTimeout);
+ properties.put(ConsumerConfig.RECONNECT_BACKOFF_MS_CONFIG, reconnectBackoff);
+ properties.put(ConsumerConfig.RECONNECT_BACKOFF_MAX_MS_CONFIG, maxReconnectBackoff);
Optional authenticationDetailsEvent =
connectionDetailsEvent.getAuthenticationDetails().stream().findFirst();
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConfig.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConfig.java
new file mode 100644
index 00000000..04f74e8c
--- /dev/null
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConfig.java
@@ -0,0 +1,20 @@
+package com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient;
+
+import lombok.Builder;
+import lombok.Data;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+@Data
+@Builder
+@Configuration
+@EnableAutoConfiguration
+@PropertySource("classpath:application.yml")
+@ConfigurationProperties(prefix = "kafka.client.config")
+public class KafkaClientConfig {
+ KafkaClientConnection connections;
+ KafkaClientReconnection reconnections;
+}
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnection.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnection.java
new file mode 100644
index 00000000..48f8338d
--- /dev/null
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnection.java
@@ -0,0 +1,18 @@
+package com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Configuration
+public class KafkaClientConnection {
+ private KafkaClientConnectionConfig timeout;
+ private KafkaClientConnectionConfig maxIdle;
+ private KafkaClientConnectionConfig requestTimeout;
+}
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnectionConfig.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnectionConfig.java
new file mode 100644
index 00000000..a7aaa2c6
--- /dev/null
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientConnectionConfig.java
@@ -0,0 +1,18 @@
+package com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.concurrent.TimeUnit;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class KafkaClientConnectionConfig {
+ private int value;
+
+ private TimeUnit unit;
+}
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnection.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnection.java
new file mode 100644
index 00000000..c10ea6b5
--- /dev/null
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnection.java
@@ -0,0 +1,17 @@
+package com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Configuration
+public class KafkaClientReconnection {
+ private KafkaClientReconnectionConfig backoff;
+ private KafkaClientReconnectionConfig maxBackoff;
+}
diff --git a/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnectionConfig.java b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnectionConfig.java
new file mode 100644
index 00000000..6fea78d9
--- /dev/null
+++ b/service/kafka-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/kafkaClient/KafkaClientReconnectionConfig.java
@@ -0,0 +1,17 @@
+package com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.concurrent.TimeUnit;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class KafkaClientReconnectionConfig {
+ private int value;
+ private TimeUnit unit;
+}
diff --git a/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/KafkaTestConfig.java b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/KafkaTestConfig.java
index 15aa53ce..d7aa392a 100644
--- a/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/KafkaTestConfig.java
+++ b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/KafkaTestConfig.java
@@ -1,5 +1,10 @@
package com.solace.maas.ep.event.management.agent.plugin;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnectionConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnectionConfig;
import com.solace.maas.ep.event.management.agent.plugin.processor.EmptyScanEntityProcessor;
import com.solace.maas.ep.event.management.agent.plugin.processor.logging.MDCProcessor;
import com.solace.maas.ep.event.management.agent.plugin.route.manager.RouteManager;
@@ -8,7 +13,10 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
+import java.util.concurrent.TimeUnit;
+
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
@TestConfiguration
@@ -19,6 +27,46 @@ public MessagingServiceDelegateService messagingServiceDelegateService() {
return mock(MessagingServiceDelegateService.class);
}
+ @Bean
+ @Primary
+ public KafkaClientConfig kafkaClientConfig() {
+ KafkaClientConfig kafkaClientConfig = mock(KafkaClientConfig.class);
+ KafkaClientConnection kafkaClientConnection = mock(KafkaClientConnection.class);
+ KafkaClientReconnection kafkaClientReconnection = mock(KafkaClientReconnection.class);
+
+ KafkaClientConnectionConfig kafkaClientConnectionConfigTimeout = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigMaxIdle = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigRequestTimeout = mock(KafkaClientConnectionConfig.class);
+
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoff = mock(KafkaClientReconnectionConfig.class);
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoffMax = mock(KafkaClientReconnectionConfig.class);
+
+ when(kafkaClientConfig.getConnections()).thenReturn(kafkaClientConnection);
+ when(kafkaClientConfig.getReconnections()).thenReturn(kafkaClientReconnection);
+
+ when(kafkaClientConnection.getTimeout()).thenReturn(kafkaClientConnectionConfigTimeout);
+ when(kafkaClientConnectionConfigTimeout.getValue()).thenReturn(60_000);
+ when(kafkaClientConnectionConfigTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getMaxIdle()).thenReturn(kafkaClientConnectionConfigMaxIdle);
+ when(kafkaClientConnectionConfigMaxIdle.getValue()).thenReturn(10_000);
+ when(kafkaClientConnectionConfigMaxIdle.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getRequestTimeout()).thenReturn(kafkaClientConnectionConfigRequestTimeout);
+ when(kafkaClientConnectionConfigRequestTimeout.getValue()).thenReturn(5_000);
+ when(kafkaClientConnectionConfigRequestTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getBackoff()).thenReturn(kafkaClientReconnectionConfigBackoff);
+ when(kafkaClientReconnectionConfigBackoff.getValue()).thenReturn(50);
+ when(kafkaClientReconnectionConfigBackoff.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getMaxBackoff()).thenReturn(kafkaClientReconnectionConfigBackoffMax);
+ when(kafkaClientReconnectionConfigBackoffMax.getValue()).thenReturn(1000);
+ when(kafkaClientReconnectionConfigBackoffMax.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ return kafkaClientConfig;
+ }
+
@Bean
@Primary
public MDCProcessor mdcProcessor() {
diff --git a/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientManagerTests.java b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/client/KafkaClientManagerTests.java
similarity index 51%
rename from service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientManagerTests.java
rename to service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/client/KafkaClientManagerTests.java
index 924bab6c..cdcbcc4e 100644
--- a/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/manager/client/KafkaClientManagerTests.java
+++ b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/client/KafkaClientManagerTests.java
@@ -1,32 +1,89 @@
-package com.solace.maas.ep.event.management.agent.plugin.manager.client;
+package com.solace.maas.ep.event.management.agent.plugin.kafka.client;
+import com.solace.maas.ep.event.management.agent.plugin.KafkaTestConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.KafkaClientManagerImpl;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnectionConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnectionConfig;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.AuthenticationDetailsEvent;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.ConnectionDetailsEvent;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.CredentialDetailsEvent;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.EventProperty;
+import lombok.SneakyThrows;
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.KafkaAdminClient;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.KafkaException;
import org.apache.kafka.common.config.SslConfigs;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
-public class KafkaClientManagerTests {
+@ActiveProfiles("TEST")
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KafkaTestConfig.class)
+class KafkaClientManagerTests {
- private final KafkaClientManagerImpl kafkaClientManager = new KafkaClientManagerImpl();
+ @Mock
+ KafkaClientConfig kafkaClientConfig;
+ @BeforeEach
+ void setupMocks() {
+ KafkaClientConnection kafkaClientConnection = mock(KafkaClientConnection.class);
+ KafkaClientReconnection kafkaClientReconnection = mock(KafkaClientReconnection.class);
+
+ KafkaClientConnectionConfig kafkaClientConnectionConfigTimeout = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigMaxIdle = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigRequestTimeout = mock(KafkaClientConnectionConfig.class);
+
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoff = mock(KafkaClientReconnectionConfig.class);
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoffMax = mock(KafkaClientReconnectionConfig.class);
+
+ when(kafkaClientConfig.getConnections()).thenReturn(kafkaClientConnection);
+ when(kafkaClientConfig.getReconnections()).thenReturn(kafkaClientReconnection);
+
+ when(kafkaClientConnection.getTimeout()).thenReturn(kafkaClientConnectionConfigTimeout);
+ when(kafkaClientConnectionConfigTimeout.getValue()).thenReturn(60_000);
+ when(kafkaClientConnectionConfigTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getMaxIdle()).thenReturn(kafkaClientConnectionConfigMaxIdle);
+ when(kafkaClientConnectionConfigMaxIdle.getValue()).thenReturn(10_000);
+ when(kafkaClientConnectionConfigMaxIdle.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getRequestTimeout()).thenReturn(kafkaClientConnectionConfigRequestTimeout);
+ when(kafkaClientConnectionConfigRequestTimeout.getValue()).thenReturn(5_000);
+ when(kafkaClientConnectionConfigRequestTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getBackoff()).thenReturn(kafkaClientReconnectionConfigBackoff);
+ when(kafkaClientReconnectionConfigBackoff.getValue()).thenReturn(50);
+ when(kafkaClientReconnectionConfigBackoff.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getMaxBackoff()).thenReturn(kafkaClientReconnectionConfigBackoffMax);
+ when(kafkaClientReconnectionConfigBackoffMax.getValue()).thenReturn(1000);
+ when(kafkaClientReconnectionConfigBackoffMax.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+ }
+
+ @SneakyThrows
@Test
- public void testProperties() {
+ void testProperties() {
+ KafkaClientManagerImpl kafkaClientManager = new KafkaClientManagerImpl(kafkaClientConfig);
+
ConnectionDetailsEvent connectionDetailsEvent = ConnectionDetailsEvent.builder()
.url("connection_url")
.messagingServiceId("messaging_service_id")
@@ -45,19 +102,23 @@ public void testProperties() {
.build();
Properties properties = kafkaClientManager.buildProperties(connectionDetailsEvent);
- assertThat(properties.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)).isEqualTo("connection_url");
- assertThat(properties.get(ConsumerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG)).isEqualTo(10000);
- assertThat(properties.get(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG)).isEqualTo(5000);
- assertThat(properties.get(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)).isEqualTo("SSL");
- assertThat(properties.get(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG)).isEqualTo("/trust/location/truststore.jks");
- assertThat(properties.get(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG)).isEqualTo("trustpass");
- assertThat(properties.get(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG)).isEqualTo("keypass");
- assertThat(properties.get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG)).isEqualTo("/trust/location/keystore.jks");
- assertThat(properties.get(SslConfigs.SSL_KEY_PASSWORD_CONFIG)).isEqualTo("keyPass");
+
+ assertThat(properties)
+ .containsEntry(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "connection_url")
+ .containsEntry(ConsumerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG, 10000)
+ .containsEntry(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, 5000)
+ .containsEntry(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL")
+ .containsEntry(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "/trust/location/truststore.jks")
+ .containsEntry(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "trustpass")
+ .containsEntry(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "keypass")
+ .containsEntry(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, "/trust/location/keystore.jks")
+ .containsEntry(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "keyPass");
}
@Test
- public void adminClientCreatePassThroughCredentialProperties() {
+ void adminClientCreatePassThroughCredentialProperties() {
+ KafkaClientManagerImpl kafkaClientManager = new KafkaClientManagerImpl(kafkaClientConfig);
+
ConnectionDetailsEvent connectionDetailsEvent = ConnectionDetailsEvent.builder()
.url("localhost:12345")
.messagingServiceId("messaging_service_id")
@@ -89,7 +150,9 @@ public void adminClientCreatePassThroughCredentialProperties() {
}
@Test
- public void adminClientCreateFailure() {
+ void adminClientCreateFailure() {
+ KafkaClientManagerImpl kafkaClientManager = new KafkaClientManagerImpl(kafkaClientConfig);
+
ConnectionDetailsEvent connectionDetailsEvent = ConnectionDetailsEvent.builder()
.url("connection_url")
.messagingServiceId("messaging_service_id")
diff --git a/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/KafkaBrokerConfigurationProcessorTests.java b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/KafkaBrokerConfigurationProcessorTests.java
new file mode 100644
index 00000000..4b103690
--- /dev/null
+++ b/service/kafka-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/kafka/processor/KafkaBrokerConfigurationProcessorTests.java
@@ -0,0 +1,139 @@
+package com.solace.maas.ep.event.management.agent.plugin.kafka.processor;
+
+import com.solace.maas.ep.event.management.agent.plugin.KafkaTestConfig;
+import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
+import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.cluster.KafkaBrokerConfigurationProcessor;
+import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.cluster.KafkaBrokerConfigurationEvent;
+import com.solace.maas.ep.event.management.agent.plugin.kafka.processor.event.cluster.KafkaClusterConfigurationEvent;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientConnectionConfig;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnection;
+import com.solace.maas.ep.event.management.agent.plugin.manager.client.kafkaClient.KafkaClientReconnectionConfig;
+import com.solace.maas.ep.event.management.agent.plugin.service.MessagingServiceDelegateService;
+import lombok.SneakyThrows;
+import org.apache.kafka.clients.admin.AdminClient;
+import org.apache.kafka.clients.admin.Config;
+import org.apache.kafka.clients.admin.ConfigEntry;
+import org.apache.kafka.clients.admin.DescribeConfigsResult;
+import org.apache.kafka.common.KafkaFuture;
+import org.apache.kafka.common.config.ConfigResource;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatNoException;
+import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("TEST")
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KafkaTestConfig.class)
+class KafkaBrokerConfigurationProcessorTests {
+
+ @Mock
+ MessagingServiceDelegateService messagingServiceDelegateService;
+
+ @Mock
+ KafkaClientConfig kafkaClientConfig;
+
+ private KafkaBrokerConfigurationProcessor kafkaBrokerConfigurationProcessor;
+
+ @BeforeEach
+ void mockSetup() {
+ KafkaClientConnection kafkaClientConnection = mock(KafkaClientConnection.class);
+ KafkaClientReconnection kafkaClientReconnection = mock(KafkaClientReconnection.class);
+
+ KafkaClientConnectionConfig kafkaClientConnectionConfigTimeout = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigMaxIdle = mock(KafkaClientConnectionConfig.class);
+ KafkaClientConnectionConfig kafkaClientConnectionConfigRequestTimeout = mock(KafkaClientConnectionConfig.class);
+
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoff = mock(KafkaClientReconnectionConfig.class);
+ KafkaClientReconnectionConfig kafkaClientReconnectionConfigBackoffMax = mock(KafkaClientReconnectionConfig.class);
+
+ when(kafkaClientConfig.getConnections()).thenReturn(kafkaClientConnection);
+ when(kafkaClientConfig.getReconnections()).thenReturn(kafkaClientReconnection);
+
+ when(kafkaClientConnection.getTimeout()).thenReturn(kafkaClientConnectionConfigTimeout);
+ when(kafkaClientConnectionConfigTimeout.getValue()).thenReturn(60_000);
+ when(kafkaClientConnectionConfigTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getMaxIdle()).thenReturn(kafkaClientConnectionConfigMaxIdle);
+ when(kafkaClientConnectionConfigMaxIdle.getValue()).thenReturn(10_000);
+ when(kafkaClientConnectionConfigMaxIdle.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientConnection.getRequestTimeout()).thenReturn(kafkaClientConnectionConfigRequestTimeout);
+ when(kafkaClientConnectionConfigRequestTimeout.getValue()).thenReturn(5_000);
+ when(kafkaClientConnectionConfigRequestTimeout.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getBackoff()).thenReturn(kafkaClientReconnectionConfigBackoff);
+ when(kafkaClientReconnectionConfigBackoff.getValue()).thenReturn(50);
+ when(kafkaClientReconnectionConfigBackoff.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ when(kafkaClientReconnection.getMaxBackoff()).thenReturn(kafkaClientReconnectionConfigBackoffMax);
+ when(kafkaClientReconnectionConfigBackoffMax.getValue()).thenReturn(1000);
+ when(kafkaClientReconnectionConfigBackoffMax.getUnit()).thenReturn(TimeUnit.MILLISECONDS);
+
+ kafkaBrokerConfigurationProcessor = new KafkaBrokerConfigurationProcessor(messagingServiceDelegateService, kafkaClientConfig);
+ }
+
+ @SneakyThrows
+ @Test
+ void testHandleEvent() {
+ List body = List.of(
+ KafkaClusterConfigurationEvent.builder()
+ .id("0")
+ .host("localhost")
+ .rack("rack1")
+ .port(9090)
+ .build(),
+ KafkaClusterConfigurationEvent.builder()
+ .id("1")
+ .host("localhost")
+ .rack("rack2")
+ .port(9092)
+ .build()
+ );
+
+ List entries = new ArrayList<>();
+ entries.add(new ConfigEntry("A1", "value1"));
+ entries.add(new ConfigEntry("B1", "value2"));
+
+ ConfigResource configResource = new ConfigResource(ConfigResource.Type.BROKER, "configResource1");
+ Config config = new Config(entries);
+
+ AdminClient adminClient = mock(AdminClient.class);
+ DescribeConfigsResult describeConfigsResult = mock(DescribeConfigsResult.class);
+ KafkaFuture