Switched from Dropwizard to Springboot 60/130260/2
authorGuangrongFu <fu.guangrong@zte.com.cn>
Sat, 18 Dec 2021 07:08:14 +0000 (15:08 +0800)
committerGuangrong Fu <fu.guangrong@zte.com.cn>
Thu, 11 Aug 2022 10:51:35 +0000 (18:51 +0800)
Issue-ID: HOLMES-511

Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Change-Id: I72b53ad4073e0a07a4c6a234781dc0d139584dda

43 files changed:
engine-d-standalone/pom.xml
engine-d-standalone/src/main/assembly/bin/run.sh
engine-d-standalone/src/main/assembly/conf/application.yaml [new file with mode: 0644]
engine-d/pom.xml
engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java
engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
engine-d/src/main/java/org/onap/holmes/engine/EngineDAppConfig.java [deleted file]
engine-d/src/main/java/org/onap/holmes/engine/Initializer.java
engine-d/src/main/java/org/onap/holmes/engine/db/AlarmInfoDaoService.java [moved from engine-d/src/main/java/org/onap/holmes/engine/db/AlarmInfoDao.java with 55% similarity]
engine-d/src/main/java/org/onap/holmes/engine/db/CorrelationRuleDaoService.java [new file with mode: 0644]
engine-d/src/main/java/org/onap/holmes/engine/db/DaoProvider.java [new file with mode: 0644]
engine-d/src/main/java/org/onap/holmes/engine/db/jdbi/AlarmInfoDao.java [new file with mode: 0644]
engine-d/src/main/java/org/onap/holmes/engine/db/jdbi/CorrelationRuleDao.java [moved from engine-d/src/main/java/org/onap/holmes/engine/db/CorrelationRuleDao.java with 58% similarity]
engine-d/src/main/java/org/onap/holmes/engine/dcae/ConfigFileScanningTask.java
engine-d/src/main/java/org/onap/holmes/engine/dcae/DcaeConfigurationPolling.java
engine-d/src/main/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPolling.java
engine-d/src/main/java/org/onap/holmes/engine/dmaap/SubscriberAction.java
engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java
engine-d/src/main/java/org/onap/holmes/engine/manager/status/EntityStatusRefreshTask.java
engine-d/src/main/java/org/onap/holmes/engine/request/CompileRuleRequest.java
engine-d/src/main/java/org/onap/holmes/engine/request/DeployRuleRequest.java
engine-d/src/main/java/org/onap/holmes/engine/request/DmaapConfigRequest.java
engine-d/src/main/java/org/onap/holmes/engine/resources/DmaapConfigurationService.java
engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java
engine-d/src/main/java/org/onap/holmes/engine/resources/HealthCheck.java
engine-d/src/main/java/org/onap/holmes/engine/resources/SwaggerResource.java
engine-d/src/main/java/org/onap/holmes/engine/response/CorrelationRuleResponse.java
engine-d/src/main/java/org/onap/holmes/engine/utils/AlarmUtil.java
engine-d/src/main/java/org/onap/holmes/engine/wrapper/RuleMgtWrapper.java
engine-d/src/main/resources/logback-spring.xml [new file with mode: 0644]
engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java
engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/SubscriberTest.java
engine-d/src/test/java/org/onap/holmes/engine/EnginedAppConfigTest.java [deleted file]
engine-d/src/test/java/org/onap/holmes/engine/InitializerTest.java
engine-d/src/test/java/org/onap/holmes/engine/db/AlarmInfoDaoTest.java
engine-d/src/test/java/org/onap/holmes/engine/db/CorrelationRuleDaoTest.java
engine-d/src/test/java/org/onap/holmes/engine/dcae/ConfigFileScanningTaskTest.java
engine-d/src/test/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPollingTest.java
engine-d/src/test/java/org/onap/holmes/engine/manager/DroolsEngineTest.java
engine-d/src/test/java/org/onap/holmes/engine/resources/EngineResourcesTest.java
engine-d/src/test/java/org/onap/holmes/engine/wrapper/RuleMgtWrapperTest.java
pom.xml

index 5a56c18..e5a84e0 100644 (file)
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.onap.holmes.engine-management</groupId>
         <artifactId>holmes-engine-parent</artifactId>
-        <version>1.3.7-SNAPSHOT</version>
+        <version>1.3.8-SNAPSHOT</version>
     </parent>
 
     <artifactId>holmes-engine-d-standalone</artifactId>
@@ -60,6 +60,7 @@
                 </executions>
                 <configuration>
                     <outputDirectory>${linux64outputdir}/lib</outputDirectory>
+                    <overWriteIfNewer>true</overWriteIfNewer>
                     <includeScope>runtime</includeScope>
                 </configuration>
             </plugin>
@@ -87,6 +88,9 @@
                                 </resource>
                                 <resource>
                                     <directory>../engine-d/src/main/resources</directory>
+                                    <excludes>
+                                        <exclude>logback-spring.xml</exclude>
+                                    </excludes>
                                     <filtering>false</filtering>
                                 </resource>
                             </resources>
index 55f58dd..2c58d35 100644 (file)
@@ -47,13 +47,19 @@ if [ -z ${DB_NAME} ]; then
     echo "No database is name is specified. Use the default value \"$DB_NAME\"."
 fi
 
+export DB_PORT=5432
+if [ ! -z ${URL_JDBC} ] && [ `expr index $URL_JDBC :` != 0 ]; then
+    export DB_PORT="${URL_JDBC##*:}"
+fi
+echo DB_PORT=$DB_PORT
+
 # if deployed using helm, use the helm-generated configuration file.
 if [ -d /opt/hemconfig ]; then
-    cp /opt/hemconfig/engine-d.yml "$main_path/conf/engine-d.yml"
+    cp /opt/hemconfig/application.yaml "$main_path/conf/application.yaml"
 else
-    sed -i "s|url:.*|url: jdbc:postgresql://$URL_JDBC/$DB_NAME|" "$main_path/conf/engine-d.yml"
-    sed -i "s|user:.*|user: $JDBC_USERNAME|" "$main_path/conf/engine-d.yml"
-    sed -i "s|password:.*|password: $JDBC_PASSWORD|" "$main_path/conf/engine-d.yml"
+    sed -i "s|url:.*|url: jdbc:postgresql://$URL_JDBC:$DB_PORT/$DB_NAME|" "$main_path/conf/application.yaml"
+    sed -i "s|username:.*|username: $JDBC_USERNAME|" "$main_path/conf/application.yaml"
+    sed -i "s|password:.*|password: $JDBC_PASSWORD|" "$main_path/conf/application.yaml"
 fi
 
 export SERVICE_IP=`hostname -i | awk '{print $1}'`
@@ -65,18 +71,12 @@ else
     export HOSTNAME=${SERVICE_IP}:9102
 fi
 
-export DB_PORT=5432
-if [ ! -z ${URL_JDBC} ] && [ `expr index $URL_JDBC :` != 0 ]; then
-    export DB_PORT="${URL_JDBC##*:}"
-fi
-echo DB_PORT=$DB_PORT
-
 if [ -z ${ENABLE_ENCRYPT} ]; then
     export ENABLE_ENCRYPT=true
 fi
 echo ENABLE_ENCRYPT=$ENABLE_ENCRYPT
 
-KEY_PATH="/opt/onap/conf/holmes.keystore"
+KEY_PATH="$main_path/conf/holmes.keystore"
 KEY_PASSWORD="holmes"
 
 if [ -f "/opt/app/osaaf/local/org.onap.holmes-engine-mgmt.p12" ]; then
@@ -88,8 +88,8 @@ echo "KEY_PATH=$KEY_PATH"
 echo "KEY_PASS=$KEY_PASSWORD"
 
 #HTTPS Configurations
-sed -i "s|keyStorePath:.*|keyStorePath: $KEY_PATH|" "$main_path/conf/engine-d.yml"
-sed -i "s|keyStorePassword:.*|keyStorePassword: $KEY_PASSWORD|" "$main_path/conf/engine-d.yml"
+sed -i "s|key-store:.*|key-store: $KEY_PATH|" "$main_path/conf/application.yaml"
+sed -i "s|key-store-password:.*|key-store-password: $KEY_PASSWORD|" "$main_path/conf/application.yaml"
 
 if [ "${ENABLE_ENCRYPT}"x = "true"x ]; then
     sed -i "s|type:\s*https\?$|type: https|" "$main_path/conf/engine-d.yml"
@@ -105,9 +105,10 @@ else
     sed -i "s|#\?validatePeers|#validatePeers|" "$main_path/conf/engine-d.yml"
 fi
 
-cat "$main_path/conf/engine-d.yml"
+cat "$main_path/conf/application.yaml"
 
 ${RUNHOME}/initDB.sh "$JDBC_USERNAME" "$JDBC_PASSWORD" "$DB_NAME" "$DB_PORT" "${URL_JDBC%:*}"
 
-"$JAVA" $JAVA_OPTS -classpath "$class_path" org.onap.holmes.engine.EngineDActiveApp server "$main_path/conf/engine-d.yml"
+JAR=`ls -lt $main_path/lib | grep -e "holmes-engine-.*jar$" | awk '{print $9}'`
+"$JAVA" $JAVA_OPTS -jar "$main_path/lib/$JAR" -classpath "$class_path" --spring.config.location="$main_path/conf/application.yaml"
 
diff --git a/engine-d-standalone/src/main/assembly/conf/application.yaml b/engine-d-standalone/src/main/assembly/conf/application.yaml
new file mode 100644 (file)
index 0000000..ed760ed
--- /dev/null
@@ -0,0 +1,23 @@
+server:
+  port: 9102
+  servlet:
+    context-path: /api/holmes-engine-mgmt/v1
+  ssl:
+    key-store: /opt/onap/conf/holmes.keystore
+    key-store-password: holmes
+    #PKCS12
+    key-store-type: JKS
+
+logging:
+  config: classpath:logback-spring.xml
+
+spring:
+  application:
+    name: Holmes Engine Management
+  datasource:
+    dirver-class-name: org.postgresql.Driver
+    url: jdbc:postgresql://localhost:5432/holmes
+    username: holmes
+    password: holmespwd
+  mvc:
+    throw-exception-if-no-handler-found: true
\ No newline at end of file
index 6fc236f..1ff46dc 100644 (file)
     <parent>
         <groupId>org.onap.holmes.engine-management</groupId>
         <artifactId>holmes-engine-parent</artifactId>
-        <version>1.3.7-SNAPSHOT</version>
+        <version>1.3.8-SNAPSHOT</version>
     </parent>
 
     <artifactId>holmes-engine-d</artifactId>
     <name>holmes-engine-d-service</name>
     <packaging>jar</packaging>
 
+    <properties>
+        <main-class>org.onap.holmes.engine.EngineDActiveApp</main-class>
+    </properties>
+
     <build>
         <resources>
             <resource>
             </resource>
             <resource>
                 <directory>src/main/resources</directory>
+                <excludes>
+                    <exclude>swagger.json</exclude>
+                </excludes>
             </resource>
         </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${springboot.version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <mainClass>${main-class}</mainClass>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.0</version>
+                <configuration>
+                    <source>8</source>
+                    <target>8</target>
+                    <release>11</release>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>${jacoco.version}</version>
+                <executions>
+                    <execution>
+                        <id>prepare-agent</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>report</id>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                        <configuration>
+                            <dataFile>${project.build.directory}/code-coverage/jacoco.exec</dataFile>
+                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
     </build>
 
     <profiles>
                     <version>1.5.0</version>
                 </dependency>
             </dependencies>
-
             <build>
                 <plugins>
                     <plugin>
index 394dc08..4abf296 100644 (file)
  */
 package org.onap.holmes.dsa.dmaappolling;
 
+import com.google.gson.Gson;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.api.stat.VesAlarm;
 import org.onap.holmes.common.api.stat.AlarmAdditionalField;
-import com.google.gson.Gson;
+import org.onap.holmes.common.api.stat.VesAlarm;
+import org.springframework.stereotype.Component;
 
-import java.util.Map;
-import java.util.TimeZone;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 
 import static org.onap.holmes.common.utils.GsonUtil.*;
 
-@Service
+@Component
 public class DMaaPResponseUtil {
 
     public VesAlarm convertJsonToVesAlarm(String responseJson) {
index af772fb..4fd52ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,11 +20,10 @@ import lombok.Getter;
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 import org.onap.holmes.common.api.stat.VesAlarm;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.JerseyClient;
+import org.onap.holmes.common.utils.SpringContextUtil;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
@@ -34,8 +33,7 @@ import java.util.UUID;
 @Slf4j
 public class Subscriber {
 
-    private DMaaPResponseUtil dMaaPResponseUtil = ServiceLocatorHolder.getLocator()
-            .getService(DMaaPResponseUtil.class);
+    private DMaaPResponseUtil dMaaPResponseUtil = SpringContextUtil.getBean(DMaaPResponseUtil.class);
 
     /**
      * The number of milliseconds to wait for messages if none are immediately available. This
index b1cc335..f5d6d8a 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2017-2021 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package org.onap.holmes.engine;
 
-import io.dropwizard.setup.Environment;
 import lombok.extern.slf4j.Slf4j;
 import org.onap.holmes.common.ConfigFileScanner;
-import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
-import org.onap.holmes.common.utils.transactionid.TransactionIdFilter;
 import org.onap.holmes.engine.dcae.ConfigFileScanningTask;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.context.annotation.ComponentScan;
 
-import javax.servlet.DispatcherType;
-import java.util.EnumSet;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 @Slf4j
-public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
-
-    public static void main(String[] args) throws Exception {
-        new EngineDActiveApp().run(args);
+@SpringBootApplication
+@ServletComponentScan
+@ComponentScan(basePackages = {"org.onap.holmes"})
+public class EngineDActiveApp implements ApplicationRunner {
+    public static void main(String[] args) {
+        SpringApplication.run(EngineDActiveApp.class, args);
     }
 
     @Override
-    public void run(EngineDAppConfig configuration, Environment environment) throws Exception {
-        super.run(configuration, environment);
-
-
+    public void run(ApplicationArguments args) {
         ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
         service.scheduleAtFixedRate(
                 new ConfigFileScanningTask(new ConfigFileScanner()), 60L,
                 ConfigFileScanningTask.POLLING_PERIOD, TimeUnit.SECONDS);
 
-
-        environment.servlets().addFilter("logFilter", new TransactionIdFilter()).addMappingForUrlPatterns(EnumSet
-                .allOf(DispatcherType.class), true, "/*");
-
         Initializer.setReadyForMsbReg(true);
     }
 }
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/EngineDAppConfig.java b/engine-d/src/main/java/org/onap/holmes/engine/EngineDAppConfig.java
deleted file mode 100644 (file)
index 836912f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.engine;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import io.dropwizard.Configuration;
-import io.dropwizard.db.DataSourceFactory;
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-import org.jvnet.hk2.annotations.Service;
-
-@Service
-public class EngineDAppConfig extends Configuration {
-
-    private String apidescription = "Holmes rule management rest API";
-
-    @Valid
-    @NotNull
-    private DataSourceFactory database = new DataSourceFactory();
-
-    @JsonProperty("database")
-    public DataSourceFactory getDataSourceFactory() {
-        return database;
-    }
-
-    @JsonProperty("database")
-    public void setDataSourceFactory(DataSourceFactory dataSourceFactory) {
-        this.database = dataSourceFactory;
-    }
-
-    public String getApidescription() {
-        return apidescription;
-    }
-
-    public void setApidescription(String apidescription) {
-        this.apidescription = apidescription;
-    }
-}
index 4474fec..60869a1 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2017-2018 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
 
 package org.onap.holmes.engine;
 
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.CommonUtils;
 import org.onap.holmes.common.utils.MsbRegister;
@@ -24,32 +23,33 @@ import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
 import org.onap.msb.sdk.discovery.entity.Node;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
 
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
-import static org.onap.holmes.common.config.MicroServiceConfig.POD_IP;
 import static org.onap.holmes.common.config.MicroServiceConfig.getMicroServiceIpAndPort;
 import static org.onap.holmes.common.utils.CommonUtils.getEnv;
 import static org.onap.holmes.common.utils.CommonUtils.isIpAddress;
 
-@Service
-public class Initializer {
+@Component
+public class Initializer implements ApplicationRunner {
     private static final Logger logger = LoggerFactory.getLogger(Initializer.class);
     private volatile static boolean readyForMsbReg = false;
     private MsbRegister msbRegister;
 
-    @Inject
+    @Autowired
     public Initializer(MsbRegister msbRegister) {
         this.msbRegister = msbRegister;
     }
 
-    @PostConstruct
-    private void init() {
+    @Override
+    public void run(ApplicationArguments args) {
         Executors.newSingleThreadExecutor().execute(() -> {
             waitUntilReady();
             try {
@@ -93,7 +93,7 @@ public class Initializer {
         msinfo.setEnable_ssl(CommonUtils.isHttpsEnabled());
         Set<Node> nodes = new HashSet<>();
         Node node = new Node();
-        node.setIp(isIpAddress(serviceIpAndPort[0]) ? serviceIpAndPort[0] : getEnv(POD_IP));
+        node.setIp(isIpAddress(serviceIpAndPort[0]) ? serviceIpAndPort[0] : getEnv("HOLMES_ENGINE_MGMT_SERVICE_HOST"));
         node.setPort("9102");
         /* Following codes will cause an unregistration from MSB (due to MSB malfunction), comment them for now
         String msbAddrTemplate = (CommonUtils.isHttpsEnabled() ? "https" : "http")
@@ -1,70 +1,62 @@
-/**\r
- * Copyright 2017 ZTE Corporation.\r
- * <p>\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * <p>\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * <p>\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onap.holmes.engine.db;\r
-\r
-import org.onap.holmes.common.api.entity.AlarmInfo;\r
-import org.onap.holmes.common.exception.AlarmInfoException;\r
-import org.onap.holmes.common.utils.AlarmInfoMapper;\r
-import org.skife.jdbi.v2.sqlobject.*;\r
-import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;\r
-\r
-import java.util.List;\r
-\r
-@RegisterMapper(AlarmInfoMapper.class)\r
-public abstract class AlarmInfoDao {\r
-\r
-    @GetGeneratedKeys\r
-    @SqlUpdate("INSERT INTO ALARM_INFO  (EVENTID,EVENTNAME,STARTEPOCHMICROSEC,SOURCEID,SOURCENAME,SEQUENCE,ALARMISCLEARED,ROOTFLAG,LASTEPOCHMICROSEC) VALUES (:eventId,:eventName,:startEpochMicroSec,:sourceId,:sourceName,:sequence,:alarmIsCleared,:rootFlag,:lastEpochMicroSec)")\r
-    protected abstract String addAlarm(@BindBean AlarmInfo alarmInfo);\r
-\r
-    @SqlQuery("SELECT * FROM ALARM_INFO")\r
-    protected abstract List<AlarmInfo> queryAlarm();\r
-\r
-    @SqlUpdate("DELETE FROM ALARM_INFO WHERE EVENTNAME=:eventName AND SOURCEID=:sourceId AND SOURCENAME=:sourceName")\r
-    protected abstract int deleteAlarmByAlarmIsCleared(@Bind("eventName") String eventName,\r
-                                                       @Bind("sourceId") String sourceId,\r
-                                                       @Bind("sourceName") String sourceName);\r
-\r
-    public AlarmInfo saveAlarm(AlarmInfo alarmInfo) throws AlarmInfoException {\r
-        try {\r
-            addAlarm(alarmInfo);\r
-            return alarmInfo;\r
-        } catch (Exception e) {\r
-            throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);\r
-        }\r
-    }\r
-\r
-    public List<AlarmInfo> queryAllAlarm() throws AlarmInfoException {\r
-        try {\r
-            return queryAlarm();\r
-        } catch (Exception e) {\r
-            throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);\r
-        }\r
-    }\r
-\r
-    public void deleteAlarm(AlarmInfo alarmInfo) {\r
-        if (alarmInfo.getAlarmIsCleared() != 1) {\r
-            return;\r
-        }\r
-\r
-        String sourceId = alarmInfo.getSourceId();\r
-        String sourceName = alarmInfo.getSourceName();\r
-        String eventName = alarmInfo.getEventName();\r
-        eventName = eventName.substring(0, eventName.lastIndexOf("Cleared"));\r
-\r
-        deleteAlarmByAlarmIsCleared(eventName, sourceId, sourceName);\r
-    }\r
-}\r
+/**
+ * Copyright 2021-2022 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.engine.db;
+
+import org.onap.holmes.common.api.entity.AlarmInfo;
+import org.onap.holmes.common.exception.AlarmInfoException;
+import org.onap.holmes.engine.db.jdbi.AlarmInfoDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+
+public class AlarmInfoDaoService {
+
+    @Autowired
+    private AlarmInfoDao alarmInfoDao;
+
+    public AlarmInfo saveAlarm(AlarmInfo alarmInfo) throws AlarmInfoException {
+        try {
+            alarmInfoDao.addAlarm(alarmInfo);
+            return alarmInfo;
+        } catch (Exception e) {
+            throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);
+        }
+    }
+
+    public List<AlarmInfo> queryAllAlarm() throws AlarmInfoException {
+        try {
+            return alarmInfoDao.queryAlarm();
+        } catch (Exception e) {
+            throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);
+        }
+    }
+
+    public void deleteAlarm(AlarmInfo alarmInfo) {
+        if (alarmInfo.getAlarmIsCleared() != 1) {
+            return;
+        }
+
+        String sourceId = alarmInfo.getSourceId();
+        String sourceName = alarmInfo.getSourceName();
+        String eventName = alarmInfo.getEventName();
+        eventName = eventName.substring(0, eventName.lastIndexOf("Cleared"));
+
+        alarmInfoDao.deleteAlarmByAlarmIsCleared(eventName, sourceId, sourceName);
+    }
+}
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/db/CorrelationRuleDaoService.java b/engine-d/src/main/java/org/onap/holmes/engine/db/CorrelationRuleDaoService.java
new file mode 100644 (file)
index 0000000..a80a255
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2021 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.engine.db;
+
+import org.onap.holmes.common.api.entity.CorrelationRule;
+import org.onap.holmes.engine.db.jdbi.CorrelationRuleDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class CorrelationRuleDaoService {
+
+    @Autowired
+    private CorrelationRuleDao correlationRuleDao;
+
+    public List<CorrelationRule> queryRuleByRuleEnable(int enable) {
+        return correlationRuleDao.queryRuleByEnable(enable);
+    }
+}
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/db/DaoProvider.java b/engine-d/src/main/java/org/onap/holmes/engine/db/DaoProvider.java
new file mode 100644 (file)
index 0000000..3a52fd0
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2022 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.engine.db;
+
+import org.jdbi.v3.core.Jdbi;
+import org.onap.holmes.engine.db.jdbi.AlarmInfoDao;
+import org.onap.holmes.engine.db.jdbi.CorrelationRuleDao;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class DaoProvider {
+
+    @Bean
+    public AlarmInfoDao alarmInfoDao(Jdbi jdbi) {
+        return jdbi.onDemand(AlarmInfoDao.class);
+    }
+
+    @Bean
+    public CorrelationRuleDao correlationRuleDao(Jdbi jdbi) {
+        return jdbi.onDemand(CorrelationRuleDao.class);
+    }
+}
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/db/jdbi/AlarmInfoDao.java b/engine-d/src/main/java/org/onap/holmes/engine/db/jdbi/AlarmInfoDao.java
new file mode 100644 (file)
index 0000000..e4b2f1a
--- /dev/null
@@ -0,0 +1,43 @@
+/**\r
+ * Copyright 2017-2022 ZTE Corporation.\r
+ * <p>\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.onap.holmes.engine.db.jdbi;\r
+\r
+import org.jdbi.v3.sqlobject.config.RegisterRowMapper;\r
+import org.jdbi.v3.sqlobject.customizer.Bind;\r
+import org.jdbi.v3.sqlobject.customizer.BindBean;\r
+import org.jdbi.v3.sqlobject.statement.GetGeneratedKeys;\r
+import org.jdbi.v3.sqlobject.statement.SqlQuery;\r
+import org.jdbi.v3.sqlobject.statement.SqlUpdate;\r
+import org.onap.holmes.common.api.entity.AlarmInfo;\r
+import org.onap.holmes.common.utils.AlarmInfoMapper;\r
+\r
+import java.util.List;\r
+\r
+@RegisterRowMapper(AlarmInfoMapper.class)\r
+public interface AlarmInfoDao {\r
+\r
+    @GetGeneratedKeys\r
+    @SqlUpdate("INSERT INTO ALARM_INFO  (EVENTID,EVENTNAME,STARTEPOCHMICROSEC,SOURCEID,SOURCENAME,SEQUENCE,ALARMISCLEARED,ROOTFLAG,LASTEPOCHMICROSEC) VALUES (:eventId,:eventName,:startEpochMicroSec,:sourceId,:sourceName,:sequence,:alarmIsCleared,:rootFlag,:lastEpochMicroSec)")\r
+    String addAlarm(@BindBean AlarmInfo alarmInfo);\r
+\r
+    @SqlQuery("SELECT * FROM ALARM_INFO")\r
+    List<AlarmInfo> queryAlarm();\r
+\r
+    @SqlUpdate("DELETE FROM ALARM_INFO WHERE EVENTNAME=:eventName AND SOURCEID=:sourceId AND SOURCENAME=:sourceName")\r
+    int deleteAlarmByAlarmIsCleared(@Bind("eventName") String eventName,\r
+                                    @Bind("sourceId") String sourceId,\r
+                                    @Bind("sourceName") String sourceName);\r
+}\r
@@ -1,37 +1,32 @@
 /**
  * Copyright 2017 ZTE Corporation.
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onap.holmes.engine.db;
+package org.onap.holmes.engine.db.jdbi;
 
 
-import java.util.List;
+import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
+import org.jdbi.v3.sqlobject.customizer.Bind;
+import org.jdbi.v3.sqlobject.statement.SqlQuery;
 import org.onap.holmes.common.api.entity.CorrelationRule;
 import org.onap.holmes.common.utils.CorrelationRuleMapper;
-import org.skife.jdbi.v2.sqlobject.Bind;
-import org.skife.jdbi.v2.sqlobject.SqlQuery;
-import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
-
-@RegisterMapper(CorrelationRuleMapper.class)
-public abstract class CorrelationRuleDao {
 
+import java.util.List;
 
+@RegisterRowMapper(CorrelationRuleMapper.class)
+public interface CorrelationRuleDao {
     @SqlQuery("SELECT * FROM APLUS_RULE WHERE enable=:enable")
-    public abstract List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable);
-
-    public List<CorrelationRule> queryRuleByRuleEnable(int enable) {
-        return queryRuleByEnable(enable);
-    }
+    public List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable);
 }
 
index 15cb327..85e4a74 100644 (file)
@@ -20,14 +20,15 @@ import org.onap.holmes.common.ConfigFileScanner;
 import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
 import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
 import org.onap.holmes.common.dcae.utils.DcaeConfigurationParser;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.Md5Util;
+import org.onap.holmes.common.utils.SpringContextUtil;
 import org.onap.holmes.dsa.dmaappolling.Subscriber;
 import org.onap.holmes.engine.dmaap.SubscriberAction;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.HashMap;
 import java.util.Map;
 
 public class ConfigFileScanningTask implements Runnable {
@@ -35,7 +36,7 @@ public class ConfigFileScanningTask implements Runnable {
     final private static Logger LOGGER = LoggerFactory.getLogger(ConfigFileScanningTask.class);
     private String configFile = "/opt/hemtopics/cfy.json";
     private ConfigFileScanner configFileScanner;
-    private String prevConfigMd5 = Md5Util.md5(null);
+    private String prevConfigMd5 = Md5Util.md5(new HashMap<String, String>());
 
     public ConfigFileScanningTask(ConfigFileScanner configFileScanner) {
         this.configFileScanner = configFileScanner;
@@ -76,8 +77,7 @@ public class ConfigFileScanningTask implements Runnable {
     }
 
     private void addSubscribers(DcaeConfigurations dcaeConfigurations) {
-        SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
-                .getService(SubscriberAction.class);
+        SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
         for (String key : dcaeConfigurations.getSubKeys()) {
             Subscriber subscriber = new Subscriber();
             subscriber.setTopic(key);
index 15d77d6..6009b20 100644 (file)
@@ -1,12 +1,12 @@
 /**
  * Copyright 2017 - 2021 ZTE Corporation.
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,9 +19,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.onap.holmes.common.dcae.DcaeConfigurationQuery;
 import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
 import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.Md5Util;
+import org.onap.holmes.common.utils.SpringContextUtil;
 import org.onap.holmes.dsa.dmaappolling.Subscriber;
 import org.onap.holmes.engine.dmaap.SubscriberAction;
 
@@ -45,7 +45,7 @@ public class DcaeConfigurationPolling implements Runnable {
         try {
             dcaeConfigurations = DcaeConfigurationQuery.getDcaeConfigurations(hostname);
             String md5 = Md5Util.md5(dcaeConfigurations);
-            if (prevConfigMd5.equals(md5)){
+            if (prevConfigMd5.equals(md5)) {
                 log.info("Operation aborted due to identical Configurations.");
                 return;
             }
@@ -62,8 +62,7 @@ public class DcaeConfigurationPolling implements Runnable {
     }
 
     private void addSubscribers(DcaeConfigurations dcaeConfigurations) {
-        SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
-                .getService(SubscriberAction.class);
+        SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
         for (String key : dcaeConfigurations.getSubKeys()) {
             Subscriber subscriber = new Subscriber();
             subscriber.setTopic(key);
index e2ad89c..5e8da83 100644 (file)
@@ -21,10 +21,9 @@ import org.onap.holmes.common.api.stat.VesAlarm;
 import org.onap.holmes.common.exception.AlarmInfoException;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.dsa.dmaappolling.Subscriber;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
 import org.onap.holmes.engine.manager.DroolsEngine;
 
-import java.util.ArrayList;
 import java.util.List;
 
 @Slf4j
@@ -33,13 +32,13 @@ public class DMaaPAlarmPolling implements Runnable {
     private Subscriber subscriber;
     private DroolsEngine droolsEngine;
     private volatile boolean isAlive = true;
-    private AlarmInfoDao alarmInfoDao;
+    private AlarmInfoDaoService alarmInfoDaoService;
 
 
-    public DMaaPAlarmPolling(Subscriber subscriber, DroolsEngine droolsEngine, AlarmInfoDao alarmInfoDao) {
+    public DMaaPAlarmPolling(Subscriber subscriber, DroolsEngine droolsEngine, AlarmInfoDaoService alarmInfoDaoService) {
         this.subscriber = subscriber;
         this.droolsEngine = droolsEngine;
-        this.alarmInfoDao = alarmInfoDao;
+        this.alarmInfoDaoService = alarmInfoDaoService;
     }
 
     public void run() {
@@ -51,9 +50,9 @@ public class DMaaPAlarmPolling implements Runnable {
                     try {
                         AlarmInfo alarmInfo = getAlarmInfo(vesAlarm);
                         if (alarmInfo.getAlarmIsCleared() != 1) {
-                            alarmInfoDao.saveAlarm(alarmInfo);
+                            alarmInfoDaoService.saveAlarm(alarmInfo);
                         } else {
-                            alarmInfoDao.deleteAlarm(alarmInfo);
+                            alarmInfoDaoService.deleteAlarm(alarmInfo);
                         }
                         droolsEngine.putRaisedIntoStream(vesAlarm);
 
index 1297f11..21f5961 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 - 2021 ZTE Corporation.
+ * Copyright 2017 - 2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package org.onap.holmes.engine.dmaap;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
+import jakarta.annotation.PreDestroy;
 import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.onap.holmes.common.database.DbDaoUtil;
 import org.onap.holmes.dsa.dmaappolling.Subscriber;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
+import org.onap.holmes.engine.db.jdbi.AlarmInfoDao;
 import org.onap.holmes.engine.manager.DroolsEngine;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
-@Service
+@Component
 @Slf4j
 public class SubscriberAction {
 
-    @Inject
+    @Autowired
     private DroolsEngine droolsEngine;
-    @Inject
+    @Autowired
     private DbDaoUtil daoUtil;
+    @Autowired
+    private AlarmInfoDaoService alarmInfoDaoService;
+
     private HashMap<String, DMaaPAlarmPolling> pollingTasks = new HashMap<>();
 
     public synchronized void addSubscriber(Subscriber subscriber) {
@@ -44,7 +49,7 @@ public class SubscriberAction {
                 removeSubscriber(subscriber);
             }
             AlarmInfoDao alarmInfoDao = daoUtil.getJdbiDaoByOnDemand(AlarmInfoDao.class);
-            DMaaPAlarmPolling pollingTask = new DMaaPAlarmPolling(subscriber, droolsEngine, alarmInfoDao);
+            DMaaPAlarmPolling pollingTask = new DMaaPAlarmPolling(subscriber, droolsEngine, alarmInfoDaoService);
             Thread thread = new Thread(pollingTask);
             thread.start();
             pollingTasks.put(topic, pollingTask);
@@ -67,7 +72,7 @@ public class SubscriberAction {
     public void stopPollingTasks() {
         Iterator iterator = pollingTasks.entrySet().iterator();
         while (iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry)iterator.next();
+            Map.Entry entry = (Map.Entry) iterator.next();
             String key = (String) entry.getKey();
             pollingTasks.get(key).stopTask();
         }
index cbda858..5970b59 100644 (file)
@@ -18,7 +18,6 @@ package org.onap.holmes.engine.manager;
 import lombok.extern.slf4j.Slf4j;
 import org.drools.compiler.kie.builder.impl.InternalKieModule;
 import org.drools.core.util.StringUtils;
-import org.jvnet.hk2.annotations.Service;
 import org.kie.api.KieServices;
 import org.kie.api.builder.*;
 import org.kie.api.builder.Message.Level;
@@ -37,14 +36,15 @@ import org.onap.holmes.common.config.MicroServiceConfig;
 import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
 import org.onap.holmes.common.exception.AlarmInfoException;
 import org.onap.holmes.common.exception.CorrelationException;
-import org.onap.holmes.common.utils.DbDaoUtil;
 import org.onap.holmes.common.utils.ExceptionUtil;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
 import org.onap.holmes.engine.request.DeployRuleRequest;
 import org.onap.holmes.engine.wrapper.RuleMgtWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
 
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -52,15 +52,13 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
 @Slf4j
-@Service
-public class DroolsEngine {
-
+@Component
+public class DroolsEngine implements ApplicationRunner {
     private final static int ENABLE = 1;
     private final Map<String, String> deployed = new ConcurrentHashMap<>();
     private RuleMgtWrapper ruleMgtWrapper;
-    private DbDaoUtil daoUtil;
     private ClosedLoopControlNameCache closedLoopControlNameCache;
-    private AlarmInfoDao alarmInfoDao;
+    private AlarmInfoDaoService alarmInfoDaoService;
     private KieServices ks = KieServices.Factory.get();
     private ReleaseId releaseId = ks.newReleaseId("org.onap.holmes", "rules", "1.0.0-SNAPSHOT");
     private ReleaseId compilationRelease = ks.newReleaseId("org.onap.holmes", "compilation", "1.0.0-SNAPSHOT");
@@ -68,24 +66,23 @@ public class DroolsEngine {
     private KieSession session;
     private String instanceIp;
 
-    @Inject
-    public void setRuleMgtWrapper(RuleMgtWrapper ruleMgtWrapper) {
-        this.ruleMgtWrapper = ruleMgtWrapper;
+    @Autowired
+    public void setAlarmInfoDaoService(AlarmInfoDaoService alarmInfoDaoService) {
+        this.alarmInfoDaoService = alarmInfoDaoService;
     }
 
-    @Inject
-    public void setDaoUtil(DbDaoUtil daoUtil) {
-        this.daoUtil = daoUtil;
+    @Autowired
+    public void setRuleMgtWrapper(RuleMgtWrapper ruleMgtWrapper) {
+        this.ruleMgtWrapper = ruleMgtWrapper;
     }
 
-    @Inject
+    @Autowired
     public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
         this.closedLoopControlNameCache = closedLoopControlNameCache;
     }
 
-    @PostConstruct
-    private void init() {
-        alarmInfoDao = daoUtil.getJdbiDaoByOnDemand(AlarmInfoDao.class);
+    @Override
+    public void run(ApplicationArguments args) {
         instanceIp = MicroServiceConfig.getMicroServiceIpAndPort()[0];
         try {
             log.info("Drools engine initializing...");
@@ -146,7 +143,7 @@ public class DroolsEngine {
     }
 
     public void syncAlarms() throws AlarmInfoException {
-        alarmInfoDao.queryAllAlarm().forEach(alarmInfo -> putRaisedIntoStream(convertAlarmInfo2VesAlarm(alarmInfo)));
+        alarmInfoDaoService.queryAllAlarm().forEach(alarmInfo -> putRaisedIntoStream(convertAlarmInfo2VesAlarm(alarmInfo)));
     }
 
     public String deployRule(DeployRuleRequest rule) throws CorrelationException {
@@ -330,5 +327,4 @@ public class DroolsEngine {
         Resource jarRes = ks.getResources().newByteArrayResource(jar);
         return ks.getRepository().addKieModule(jarRes);
     }
-
 }
index 0b15999..0e65a28 100644 (file)
 
 package org.onap.holmes.engine.manager.status;
 
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.config.MicroServiceConfig;
 import org.onap.holmes.common.engine.entity.EngineEntity;
 import org.onap.holmes.common.engine.service.EngineEntityService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
-import javax.inject.Inject;
 import java.util.Optional;
 import java.util.Timer;
 import java.util.TimerTask;
 
 import static java.util.concurrent.TimeUnit.SECONDS;
 
-@Service
+@Component
 public class EntityStatusRefreshTask extends TimerTask {
     private static final Logger logger = LoggerFactory.getLogger(EntityStatusRefreshTask.class);
     private final long INTERVAL = SECONDS.toMillis(15);
@@ -39,7 +39,7 @@ public class EntityStatusRefreshTask extends TimerTask {
     private Timer timer = new Timer("EntityStatusRefreshTimer", true);
     private EngineEntityService engineEntityService;
 
-    @Inject
+    @Autowired
     public EntityStatusRefreshTask(EngineEntityService engineEntityService) {
         this.engineEntityService = engineEntityService;
     }
index b38ee5f..1baa8ad 100644 (file)
@@ -1,12 +1,12 @@
 /**
  * Copyright 2017 ZTE Corporation.
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  */
 package org.onap.holmes.engine.request;
 
-import javax.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotNull;
+
 @Getter
 @Setter
 public class CompileRuleRequest {
index f2ef369..3e1b6ca 100644 (file)
@@ -1,12 +1,12 @@
 /**
- * Copyright 2017 ZTE Corporation.
- *
+ * Copyright 2017-2021 ZTE Corporation.
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  */
 package org.onap.holmes.engine.request;
 
-import javax.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotNull;
+
 @Getter
 @Setter
 public class DeployRuleRequest {
@@ -26,6 +27,7 @@ public class DeployRuleRequest {
     @NotNull
     private String content;
 
+    @NotNull
     private String engineId;
 
     @NotNull
index 6fa1928..ede1d71 100644 (file)
 
 package org.onap.holmes.engine.request;
 
-import javax.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotNull;
+
 @Getter
 @Setter
 public class DmaapConfigRequest {
index 548b9b2..576170f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,45 +18,35 @@ package org.onap.holmes.engine.resources;
 
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.MediaType;
 import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
 import org.onap.holmes.common.dcae.entity.SecurityInfo;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
+import org.onap.holmes.common.utils.SpringContextUtil;
 import org.onap.holmes.dsa.dmaappolling.Subscriber;
 import org.onap.holmes.engine.dmaap.SubscriberAction;
 import org.onap.holmes.engine.request.DmaapConfigRequest;
+import org.springframework.web.bind.annotation.*;
 
-@Service
 @Slf4j
-//@Api(tags = {"DMaaP Configurations"})
-@Path("/dmaap")
+@RestController
+@RequestMapping("/dmaap")
 public class DmaapConfigurationService {
-    @PUT
-    @Produces(MediaType.APPLICATION_JSON)
     @ApiOperation(value = "Subscribe to a new topic. "
             + "If the topic already exists, it is replaced with the new configuration.")
-    @Path("/sub")
+    @RequestMapping(value = "/sub", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON)
     public String addSubInfo(
-            @ApiParam (value = "A JSON object with the fields named <b>name</b>"
-                    + " and <b>url</b>. Both fields are required.") DmaapConfigRequest config,
-            @Context HttpServletRequest request){
+            @ApiParam(value = "A JSON object with the fields named <b>name</b>"
+                    + " and <b>url</b>. Both fields are required.")
+            @RequestBody DmaapConfigRequest config) {
         String url = config.getUrl();
         if (url.startsWith("http://") || url.startsWith("https://")) {
             Subscriber subscriber = new Subscriber();
             subscriber.setTopic(config.getName());
             subscriber.setUrl(url);
 
-            SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
-                    .getService(SubscriberAction.class);
+            SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
             subscriberAction.removeSubscriber(subscriber);
             subscriberAction.addSubscriber(subscriber);
 
@@ -67,30 +57,26 @@ public class DmaapConfigurationService {
         return "{\"message\": \"Only the HTTP or HTTPS protocol is supported!\"}";
     }
 
-    @DELETE
     @Path("/sub/{topic}")
     @ApiOperation(value = "Unsubscribe a topic from DMaaP.")
-    @Produces(MediaType.APPLICATION_JSON)
-    public String removeSubInfo(@PathParam("topic") String topic){
+    @RequestMapping(value = "/sub/{topic}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON)
+    public String removeSubInfo(@PathVariable("topic") String topic) {
         Subscriber subscriber = new Subscriber();
         subscriber.setTopic(topic);
 
-        SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
-                .getService(SubscriberAction.class);
+        SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
         subscriberAction.removeSubscriber(subscriber);
 
         return "{\"message\": \"Topic unsubscribed.\"}";
     }
 
-    @PUT
-    @Produces(MediaType.APPLICATION_JSON)
-    @Path("/pub")
     @ApiOperation(value = "Add/Update a publishing topic. "
             + "If the topic already exists, it is replaced with the new configuration.")
+    @RequestMapping(value = "/pub", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON)
     public String updatePubInfo(
-            @ApiParam (value = "A JSON object with the fields named <b>name</b>"
-                + " and <b>url</b>. Both fields are required.") DmaapConfigRequest config,
-            @Context HttpServletRequest request){
+            @ApiParam(value = "A JSON object with the fields named <b>name</b>"
+                    + " and <b>url</b>. Both fields are required.")
+            @RequestBody DmaapConfigRequest config) {
         String url = config.getUrl();
         if (url.startsWith("http://") || url.startsWith("https://")) {
             SecurityInfo securityInfo = new SecurityInfo();
index 0aa3a59..cb41533 100644 (file)
@@ -1,12 +1,12 @@
 /**
  * Copyright 2017 ZTE Corporation.
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
+ * <p>
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 package org.onap.holmes.engine.resources;
 
 
-import com.codahale.metrics.annotation.Timed;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
 import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.ExceptionUtil;
-import org.onap.holmes.common.utils.LanguageUtil;
 import org.onap.holmes.engine.manager.DroolsEngine;
 import org.onap.holmes.engine.request.CompileRuleRequest;
 import org.onap.holmes.engine.request.DeployRuleRequest;
 import org.onap.holmes.engine.response.CorrelationRuleResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import java.util.Locale;
+import jakarta.ws.rs.core.MediaType;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-@Service
-@Path("/rule")
-@Api(tags = {"Holmes Engine Management"})
-@Produces(MediaType.APPLICATION_JSON)
 @Slf4j
+@RestController
+@RequestMapping("/rule")
+@Api(tags = {"Holmes Engine Management"})
 public class EngineResources {
-    @Inject
-    DroolsEngine droolsEngine;
-       private Pattern packagePattern = Pattern.compile("package[\\s]+([^;]+)[;\\s]*");
+    private Pattern packagePattern = Pattern.compile("package[\\s]+([^;]+)[;\\s]*");
     private ClosedLoopControlNameCache closedLoopControlNameCache;
+    private DroolsEngine droolsEngine;
+
+    @Autowired
+    public void setDroolsEngine(DroolsEngine droolsEngine) {
+        this.droolsEngine = droolsEngine;
+    }
 
-    @Inject
+    @Autowired
     public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
         this.closedLoopControlNameCache = closedLoopControlNameCache;
     }
 
-    @PUT
-    @Produces(MediaType.APPLICATION_JSON)
-    @Timed
+    @ResponseBody
+    @PutMapping(produces = MediaType.APPLICATION_JSON)
     public CorrelationRuleResponse deployRule(
             @ApiParam(value = "The request entity of the HTTP call, which comprises three "
                     + "fields: \"content\" , \"loopControlName\" and \"engineId\". "
                     + "The \"content\" should be a valid Drools rule string and the \"engineId\" "
-                    + "has to be \"engine-d\" in the Amsterdam release.", required = true) DeployRuleRequest deployRuleRequest,
-            @Context HttpServletRequest httpRequest) {
+                    + "has to be \"engine-d\" in the Amsterdam release.", required = true)
+            @RequestBody DeployRuleRequest deployRuleRequest) {
 
         CorrelationRuleResponse crResponse = new CorrelationRuleResponse();
-        Locale locale = LanguageUtil.getLocale(httpRequest);
         try {
             String packageName = getPackageName(deployRuleRequest.getContent());
-            if(packageName == null) {
-               throw new CorrelationException("Could not find package name in rule: "+deployRuleRequest.getContent());
+            if (packageName == null) {
+                throw new CorrelationException("Could not find package name in rule: " + deployRuleRequest.getContent());
             }
-            
+
             closedLoopControlNameCache
                     .put(packageName, deployRuleRequest.getLoopControlName());
             String packageNameRet = droolsEngine.deployRule(deployRuleRequest);
@@ -97,15 +92,8 @@ public class EngineResources {
         return crResponse;
     }
 
-    @DELETE
-    @Produces(MediaType.APPLICATION_JSON)
-    @Timed
-    @Path("/{packageName}")
-    public boolean undeployRule(@PathParam("packageName") String packageName,
-            @Context HttpServletRequest httpRequest) {
-
-        Locale locale = LanguageUtil.getLocale(httpRequest);
-
+    @DeleteMapping(value = "/{packageName}")
+    public void undeployRule(@PathVariable("packageName") String packageName) {
         try {
             droolsEngine.undeployRule(packageName);
             closedLoopControlNameCache.remove(packageName);
@@ -113,36 +101,26 @@ public class EngineResources {
             log.error(correlationException.getMessage(), correlationException);
             throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage());
         }
-
-        return true;
     }
 
-
-    @POST
+    @PostMapping
     @ApiOperation(value = "Check the validity of a rule.")
-    @Produces(MediaType.APPLICATION_JSON)
-    @Timed
-    public boolean compileRule(CompileRuleRequest compileRuleRequest,
-            @Context HttpServletRequest httpRequest) {
-
-        Locale locale = LanguageUtil.getLocale(httpRequest);
-
+    public void compileRule(@RequestBody CompileRuleRequest compileRuleRequest) {
         try {
             droolsEngine.compileRule(compileRuleRequest.getContent());
         } catch (CorrelationException correlationException) {
             log.error(correlationException.getMessage(), correlationException);
             throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage());
         }
-        return true;
     }
-    
-    private String getPackageName(String contents){
+
+    private String getPackageName(String contents) {
         Matcher m = packagePattern.matcher(contents);
-        
-        if (m.find( )) {
-           return m.group(1);
-        }else {
-           return null;
+
+        if (m.find()) {
+            return m.group(1);
+        } else {
+            return null;
         }
     }
 }
index c86bf06..44d238a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,24 +19,17 @@ package org.onap.holmes.engine.resources;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.SwaggerDefinition;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-@Service
+@RestController
 @SwaggerDefinition
-@Path("/healthcheck")
+@RequestMapping("/healthcheck")
 @Api(tags = {"Health Check"})
-@Produces(MediaType.TEXT_PLAIN)
-@Slf4j
 public class HealthCheck {
-    @GET
-    @Produces(MediaType.TEXT_PLAIN)
+    @GetMapping
     @ApiOperation(value = "Interface for the health check of the engine management module for Holmes")
-    public boolean healthCheck(){
-        return true;
+    public void healthCheck() {
     }
 }
index 6743b8e..494df77 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.holmes.engine.resources;
 
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import jakarta.ws.rs.core.MediaType;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLDecoder;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
 
-@Service
-@Path("/swagger.json")
-@Produces(MediaType.APPLICATION_JSON)
 @Slf4j
+@RestController
+@RequestMapping("/swagger.json")
 public class SwaggerResource {
 
-    @GET
-    @Produces(MediaType.APPLICATION_JSON)
+    @GetMapping(produces = MediaType.APPLICATION_JSON)
     public String getSwaggerJson() {
         URL url = SwaggerResource.class.getResource("/swagger.json");
         String ret = "{}";
@@ -54,7 +52,7 @@ public class SwaggerResource {
             return ret;
         }
 
-        try(BufferedReader br = new BufferedReader(new FileReader(file))) {
+        try (BufferedReader br = new BufferedReader(new FileReader(file))) {
             StringBuffer buffer = new StringBuffer();
             String line = " ";
             while ((line = br.readLine()) != null) {
index 306bd7f..96913a2 100644 (file)
@@ -1,12 +1,12 @@
 /**
  * Copyright 2017 ZTE Corporation.
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
index c7eb02b..19d6f38 100644 (file)
@@ -1,12 +1,12 @@
 /**
  * Copyright 2017 ZTE Corporation.
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  */
 package org.onap.holmes.engine.utils;
 
+import org.onap.holmes.common.api.stat.Alarm;
+
 import java.util.HashMap;
 import java.util.Map;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.api.stat.Alarm;
 
-@Service
 public class AlarmUtil {
 
     private final static AlarmUtil alarmUtil = new AlarmUtil();
@@ -28,7 +27,7 @@ public class AlarmUtil {
      * Map<ruleId, <ProbableCause-EquipType, priority>>
      */
     private final Map<String, Map<String, Integer>> rootPriorityMap =
-        new HashMap<String, Map<String, Integer>>();
+            new HashMap<String, Map<String, Integer>>();
     /**
      * Map<rule, ProbableCause+EquipType+priority>
      */
@@ -49,7 +48,7 @@ public class AlarmUtil {
         String[] probableCauseStrs = probableCauseStr.replace(" ", "").split(",");
         for (int i = 0; i < probableCauseStrs.length; i++) {
             if (alarm.getProbableCause() == Long.parseLong(probableCauseStrs[i])
-                && alarm.getEquipType().equals(equipTypes[i])) {
+                    && alarm.getEquipType().equals(equipTypes[i])) {
                 return true;
             }
         }
@@ -57,10 +56,10 @@ public class AlarmUtil {
     }
 
     public Integer getPriority(String ruleId, String probableCauseStr, String rootAlarmFeatureStr,
-        String equipTypeStr, Alarm alarm) {
+                               String equipTypeStr, Alarm alarm) {
         if (rootPriorityMap.containsKey(ruleId)) {
             if (!saveRuleMsg.get(ruleId)
-                .equals(probableCauseStr + equipTypeStr + rootAlarmFeatureStr)) {
+                    .equals(probableCauseStr + equipTypeStr + rootAlarmFeatureStr)) {
                 setPriority(ruleId, probableCauseStr, rootAlarmFeatureStr, equipTypeStr);
             }
         } else {
@@ -68,7 +67,7 @@ public class AlarmUtil {
         }
 
         Integer priority =
-            rootPriorityMap.get(ruleId).get(alarm.getProbableCause() + "-" + alarm.getEquipType());
+                rootPriorityMap.get(ruleId).get(alarm.getProbableCause() + "-" + alarm.getEquipType());
         if (priority == null) {
             priority = 0;
         }
@@ -76,7 +75,7 @@ public class AlarmUtil {
     }
 
     private void setPriority(String ruleId, String probableCauseStr, String rootAlarmFeatureStr,
-        String equipTypeStr) {
+                             String equipTypeStr) {
         saveRuleMsg.put(ruleId, probableCauseStr + equipTypeStr + rootAlarmFeatureStr);
 
         Map<String, Integer> map = new HashMap<String, Integer>();
@@ -85,7 +84,7 @@ public class AlarmUtil {
         String[] equipTypes = equipTypeStr.replace(" ", "").split(",");
         for (int i = 0; i < rootAlarmFeatureStrs.length; i++) {
             map.put(probableCauseStrs[i] + "-" + equipTypes[i],
-                Integer.parseInt(rootAlarmFeatureStrs[i]));
+                    Integer.parseInt(rootAlarmFeatureStrs[i]));
         }
 
         rootPriorityMap.put(ruleId, map);
index 1fbbfe7..08ec63e 100644 (file)
@@ -1,12 +1,12 @@
 /**
  * Copyright 2017 ZTE Corporation.
- *
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  */
 package org.onap.holmes.engine.wrapper;
 
-import java.util.List;
-import javax.inject.Inject;
-import javax.inject.Singleton;
 import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.engine.db.CorrelationRuleDao;
 import org.onap.holmes.common.api.entity.CorrelationRule;
 import org.onap.holmes.common.exception.CorrelationException;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.onap.holmes.engine.db.CorrelationRuleDaoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 
 @Service
-@Singleton
 @Slf4j
 public class RuleMgtWrapper {
+    private CorrelationRuleDaoService correlationRuleDaoService;
 
-    @Inject
-    private DbDaoUtil daoUtil;
+    @Autowired
+    public RuleMgtWrapper(CorrelationRuleDaoService correlationRuleDaoService) {
+        this.correlationRuleDaoService = correlationRuleDaoService;
+    }
 
     public List<CorrelationRule> queryRuleByEnable(int enable) throws CorrelationException {
 
-        List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class)
-            .queryRuleByRuleEnable(enable);
+        List<CorrelationRule> ruleTemp = correlationRuleDaoService.queryRuleByRuleEnable(enable);
         return ruleTemp;
     }
 }
diff --git a/engine-d/src/main/resources/logback-spring.xml b/engine-d/src/main/resources/logback-spring.xml
new file mode 100644 (file)
index 0000000..197057e
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="false">
+    <property name="LOG_HOME" value="/var/log/ONAP/holmes"/>
+    <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %msg%n" />
+
+    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>${LOG_PATTERN}</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>debug</level>
+        </filter>
+    </appender>
+
+    <appender name="FileOutputForDebug" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_HOME}/holmes-engine-mgmt-debug.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_HOME}/archived/holmes-engine-mgmt-debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
+            <maxHistory>15</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>${LOG_PATTERN}</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>info</level>
+        </filter>
+    </appender>
+
+    <appender name="FileOutputForError" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_HOME}/holmes-engine-mgmt-error.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_HOME}/archived/holmes-engine-mgmt-error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
+            <maxHistory>15</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>${LOG_PATTERN}</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>error</level>
+            <onMatch>deny</onMatch>
+            <onMismatch>accept</onMismatch>
+        </filter>
+    </appender>
+
+    <root level="info">
+        <appender-ref ref="Console" />
+        <appender-ref ref="FileOutputForDebug" />
+        <appender-ref ref="FileOutputForError" />
+    </root>
+</configuration>
\ No newline at end of file
index ded50b0..9f5fd0f 100644 (file)
@@ -19,7 +19,6 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.onap.holmes.common.api.stat.AlarmAdditionalField;
 import org.onap.holmes.common.api.stat.VesAlarm;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 
index 339a23e..96794ce 100644 (file)
  */
 package org.onap.holmes.dsa.dmaappolling;
 
-import org.glassfish.hk2.api.ServiceLocator;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
-import org.onap.holmes.common.api.stat.AlarmAdditionalField;
 import org.onap.holmes.common.api.stat.VesAlarm;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
 import org.onap.holmes.common.exception.CorrelationException;
 import org.onap.holmes.common.utils.JerseyClient;
+import org.onap.holmes.common.utils.SpringContextUtil;
 import org.powermock.api.easymock.PowerMock;
 import org.powermock.core.classloader.annotations.PowerMockIgnore;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import static org.easymock.EasyMock.*;
@@ -41,7 +39,7 @@ import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({ServiceLocatorHolder.class, JerseyClient.class})
+@PrepareForTest({SpringContextUtil.class, JerseyClient.class})
 @PowerMockIgnore("javax.net.ssl.*")
 public class SubscriberTest {
 
@@ -52,10 +50,8 @@ public class SubscriberTest {
 
     @Before
     public void init() {
-        PowerMock.mockStatic(ServiceLocatorHolder.class);
-        ServiceLocator serviceLocator = PowerMock.createMock(ServiceLocator.class);
-        expect(ServiceLocatorHolder.getLocator()).andReturn(serviceLocator).anyTimes();
-        expect(serviceLocator.getService(DMaaPResponseUtil.class)).andReturn(util).anyTimes();
+        PowerMock.mockStatic(SpringContextUtil.class);
+        expect(SpringContextUtil.getBean(DMaaPResponseUtil.class)).andReturn(util).anyTimes();
     }
 
     @Test
@@ -77,9 +73,9 @@ public class SubscriberTest {
         vesAlarm.setStartEpochMicrosec(500L);
         vesAlarm.setVersion("4.0");
         Map alarmAdditionalFields = new HashMap<String, String>();
-       alarmAdditionalFields.put("addInfo", "addInfo");
-       vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
-       vesAlarm.setAlarmCondition("alarmCondition");
+        alarmAdditionalFields.put("addInfo", "addInfo");
+        vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
+        vesAlarm.setAlarmCondition("alarmCondition");
         vesAlarm.setAlarmInterfaceA("alarmInterfaceA");
         vesAlarm.setEventCategory("eventCategory");
         vesAlarm.setEventSeverity("eventSeverity");
@@ -161,9 +157,9 @@ public class SubscriberTest {
         vesAlarm.setStartEpochMicrosec(500L);
         vesAlarm.setVersion("4.0");
         Map alarmAdditionalFields = new HashMap<String, String>();
-       alarmAdditionalFields.put("addInfo", "addInfo");
-       vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
-       vesAlarm.setAlarmCondition("alarmCondition");
+        alarmAdditionalFields.put("addInfo", "addInfo");
+        vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
+        vesAlarm.setAlarmCondition("alarmCondition");
         vesAlarm.setAlarmInterfaceA("alarmInterfaceA");
         vesAlarm.setEventCategory("eventCategory");
         vesAlarm.setEventSeverity("eventSeverity");
diff --git a/engine-d/src/test/java/org/onap/holmes/engine/EnginedAppConfigTest.java b/engine-d/src/test/java/org/onap/holmes/engine/EnginedAppConfigTest.java
deleted file mode 100644 (file)
index c550b37..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/**\r
- * Copyright 2017 ZTE Corporation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.holmes.engine;\r
-\r
-import io.dropwizard.db.DataSourceFactory;\r
-import org.hamcrest.core.IsEqual;\r
-import org.hamcrest.core.IsNull;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.powermock.api.easymock.PowerMock;\r
-\r
-public class EnginedAppConfigTest {\r
-\r
-    private EngineDAppConfig engineAppConfig;\r
-\r
-    @Before\r
-    public void setUp() {\r
-        engineAppConfig = new EngineDAppConfig();\r
-    }\r
-\r
-    @Test\r
-    public void getDataSourceFactory() {\r
-        Assert.assertThat(engineAppConfig.getDataSourceFactory(), IsNull.<DataSourceFactory>notNullValue());\r
-    }\r
-\r
-    @Test\r
-    public void setDataSourceFactory() {\r
-        DataSourceFactory database = new DataSourceFactory();\r
-        engineAppConfig.setDataSourceFactory(database);\r
-        Assert.assertThat(engineAppConfig.getDataSourceFactory(), IsEqual.equalTo(database));\r
-    }\r
-\r
-    @Test\r
-    public void getApidescription() {\r
-        final String apidescription = "Holmes rule management rest API";\r
-        Assert.assertThat(engineAppConfig.getApidescription(), IsEqual.equalTo(apidescription));\r
-    }\r
-\r
-    @Test\r
-    public void setApidescription() {\r
-        final String apidescription = "set api description";\r
-        engineAppConfig.setApidescription(apidescription);\r
-        Assert.assertThat(engineAppConfig.getApidescription(), IsEqual.equalTo(apidescription));\r
-    }\r
-}\r
index 788c3ae..4dec23d 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2022 ZTE Corporation.
  * <p>
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
@@ -23,7 +23,6 @@ import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
 import org.powermock.api.easymock.PowerMock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.internal.WhiteboxImpl;
 
 import java.util.concurrent.TimeUnit;
 
@@ -47,7 +46,7 @@ public class InitializerTest {
 
         setReadyFlagAfter(3);
 
-        WhiteboxImpl.invokeMethod(initializer, "init");
+        initializer.run(null);
 
         TimeUnit.SECONDS.sleep(6);
 
index 9945322..0eb9049 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
 package org.onap.holmes.engine.db;\r
 \r
 import org.easymock.EasyMock;\r
-import org.hamcrest.core.IsNot;\r
 import org.hamcrest.core.IsNull;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
-import org.junit.Rule;\r
 import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
 import org.onap.holmes.common.api.entity.AlarmInfo;\r
-import org.onap.holmes.common.exception.AlarmInfoException;\r
 import org.powermock.api.easymock.PowerMock;\r
 \r
 import java.util.ArrayList;\r
@@ -34,20 +30,20 @@ import java.util.List;
 public class AlarmInfoDaoTest {\r
 \r
 \r
-    private AlarmInfoDao alarmInfoDao;\r
+    private AlarmInfoDaoService alarmInfoDaoService;\r
 \r
     @Before\r
     public void setUp() {\r
-        alarmInfoDao  = PowerMock.createMock(AlarmInfoDao.class);\r
+        alarmInfoDaoService  = PowerMock.createMock(AlarmInfoDaoService.class);\r
     }\r
 \r
     @Test\r
     public void queryAllAlarm() throws Exception {\r
 \r
-        EasyMock.expect(alarmInfoDao.queryAllAlarm()).andReturn(new ArrayList<AlarmInfo>());\r
+        EasyMock.expect(alarmInfoDaoService.queryAllAlarm()).andReturn(new ArrayList<AlarmInfo>());\r
         PowerMock.replayAll();\r
 \r
-        List<AlarmInfo> alarmInfoList = alarmInfoDao.queryAllAlarm();\r
+        List<AlarmInfo> alarmInfoList = alarmInfoDaoService.queryAllAlarm();\r
         PowerMock.verifyAll();\r
         Assert.assertThat(alarmInfoList, IsNull.<List<AlarmInfo>>notNullValue());\r
     }\r
index 128f58a..01fb585 100644 (file)
@@ -22,6 +22,7 @@ import org.junit.Assert;
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.onap.holmes.common.api.entity.CorrelationRule;\r
+import org.onap.holmes.engine.db.jdbi.CorrelationRuleDao;\r
 import org.powermock.api.easymock.PowerMock;\r
 \r
 import java.util.ArrayList;\r
index b663133..7f01aa4 100644 (file)
 package org.onap.holmes.engine.dcae;
 
 import org.easymock.EasyMock;
-import org.glassfish.hk2.api.ServiceLocator;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
+import org.onap.holmes.common.utils.SpringContextUtil;
 import org.onap.holmes.dsa.dmaappolling.DMaaPResponseUtil;
 import org.onap.holmes.dsa.dmaappolling.Subscriber;
 import org.onap.holmes.engine.dmaap.SubscriberAction;
 import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 import org.powermock.reflect.Whitebox;
 
@@ -33,16 +33,16 @@ import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertThat;
 
 @RunWith(PowerMockRunner.class)
+@PrepareForTest({SpringContextUtil.class})
 public class ConfigFileScanningTaskTest {
 
     @Test
     public void run() {
-        ServiceLocator mockedSl = PowerMock.createMock(ServiceLocator.class);
+        PowerMock.mockStatic(SpringContextUtil.class);
         SubscriberAction mockedSa = PowerMock.createMock(SubscriberAction.class);
-        ServiceLocatorHolder.setLocator(mockedSl);
-        EasyMock.expect(mockedSl.getService(SubscriberAction.class)).andReturn(mockedSa);
+        EasyMock.expect(SpringContextUtil.getBean(SubscriberAction.class)).andReturn(mockedSa);
         // This is invoked while executing new Subscriber().
-        EasyMock.expect(mockedSl.getService(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
+        EasyMock.expect(SpringContextUtil.getBean(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
         mockedSa.addSubscriber(EasyMock.anyObject(Subscriber.class));
         EasyMock.expectLastCall();
 
@@ -60,13 +60,12 @@ public class ConfigFileScanningTaskTest {
 
     @Test
     public void run_config_not_changed() {
-        ServiceLocator mockedSl = PowerMock.createMock(ServiceLocator.class);
+        PowerMock.mockStatic(SpringContextUtil.class);
         SubscriberAction mockedSa = PowerMock.createMock(SubscriberAction.class);
-        ServiceLocatorHolder.setLocator(mockedSl);
         // mocked objects will be only used once
-        EasyMock.expect(mockedSl.getService(SubscriberAction.class)).andReturn(mockedSa);
+        EasyMock.expect(SpringContextUtil.getBean(SubscriberAction.class)).andReturn(mockedSa);
         // This is invoked while executing new Subscriber().
-        EasyMock.expect(mockedSl.getService(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
+        EasyMock.expect(SpringContextUtil.getBean(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
         mockedSa.addSubscriber(EasyMock.anyObject(Subscriber.class));
         EasyMock.expectLastCall();
 
index 74765f5..e809cd8 100644 (file)
@@ -1,12 +1,12 @@
 /**
- * Copyright 2017 ZTE Corporation.
- *
+ * Copyright 2017-2021 ZTE Corporation.
+ * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  */
 package org.onap.holmes.engine.dmaap;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Field;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.holmes.common.api.entity.AlarmInfo;
 import org.onap.holmes.common.api.stat.VesAlarm;
 import org.onap.holmes.dsa.dmaappolling.Subscriber;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
 import org.onap.holmes.engine.manager.DroolsEngine;
 import org.powermock.api.easymock.PowerMock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 import org.powermock.reflect.Whitebox;
 
-@PrepareForTest({Subscriber.class, DroolsEngine.class,DMaaPAlarmPolling.class})
+import java.lang.reflect.Field;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+@PrepareForTest({Subscriber.class, DroolsEngine.class, DMaaPAlarmPolling.class})
 @RunWith(PowerMockRunner.class)
 public class DMaaPAlarmPollingTest {
 
     private DMaaPAlarmPolling dMaaPAlarmPolling;
     private Subscriber subscriber;
     private DroolsEngine droolsEngine;
-    private AlarmInfoDao alarmInfoDao;
+    private AlarmInfoDaoService alarmInfoDaoService;
 
     @Before
     public void setUp() {
         subscriber = PowerMock.createMock(Subscriber.class);
         droolsEngine = PowerMock.createMock(DroolsEngine.class);
-        alarmInfoDao = PowerMock.createMock(AlarmInfoDao.class);
-        dMaaPAlarmPolling = new DMaaPAlarmPolling(subscriber, droolsEngine,alarmInfoDao);
+        alarmInfoDaoService = PowerMock.createMock(AlarmInfoDaoService.class);
+        dMaaPAlarmPolling = new DMaaPAlarmPolling(subscriber, droolsEngine, alarmInfoDaoService);
         PowerMock.replayAll();
     }
 
@@ -72,7 +73,7 @@ public class DMaaPAlarmPollingTest {
         vesAlarm.setRootFlag(0);
 
         PowerMock.replayAll();
-        AlarmInfo alarmInfo = Whitebox.invokeMethod(dMaaPAlarmPolling,"getAlarmInfo",vesAlarm);
+        AlarmInfo alarmInfo = Whitebox.invokeMethod(dMaaPAlarmPolling, "getAlarmInfo", vesAlarm);
         PowerMock.verifyAll();
 
         assertThat(alarmInfo.getAlarmIsCleared(), is(1));
index cb28faa..31f1817 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright 2017-2020 ZTE Corporation.\r
+ * Copyright 2017-2021 ZTE Corporation.\r
  * <p>\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -16,7 +16,6 @@
 \r
 package org.onap.holmes.engine.manager;\r
 \r
-import org.junit.Before;\r
 import org.junit.Rule;\r
 import org.junit.Test;\r
 import org.junit.rules.ExpectedException;\r
@@ -26,11 +25,10 @@ import org.onap.holmes.common.api.stat.VesAlarm;
 import org.onap.holmes.common.config.MicroServiceConfig;\r
 import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;\r
 import org.onap.holmes.common.exception.CorrelationException;\r
-import org.onap.holmes.common.utils.DbDaoUtil;\r
-import org.onap.holmes.engine.db.AlarmInfoDao;\r
+import org.onap.holmes.engine.db.AlarmInfoDaoService;\r
+import org.onap.holmes.engine.db.CorrelationRuleDaoService;\r
 import org.onap.holmes.engine.request.DeployRuleRequest;\r
 import org.onap.holmes.engine.wrapper.RuleMgtWrapper;\r
-import org.powermock.api.easymock.PowerMock;\r
 import org.powermock.reflect.Whitebox;\r
 \r
 import java.util.ArrayList;\r
@@ -47,33 +45,31 @@ public class DroolsEngineTest {
     @Rule\r
     public ExpectedException thrown = ExpectedException.none();\r
 \r
-    private RuleMgtWrapper ruleMgtWrapper;\r
+    private RuleMgtWrapper ruleMgtWrapperMock;\r
 \r
     private DroolsEngine droolsEngine;\r
 \r
-    private DbDaoUtil dbDaoUtilStub;\r
+    private AlarmInfoDaoService alarmInfoDaoServiceStub;\r
+\r
+    private CorrelationRuleDaoService correlationRuleDaoServiceStub;\r
 \r
     private ClosedLoopControlNameCache closedLoopControlNameCache;\r
 \r
     public DroolsEngineTest() throws Exception {\r
         System.setProperty(MicroServiceConfig.HOSTNAME, "127.0.0.1:80");\r
         droolsEngine = new DroolsEngine();\r
-        ruleMgtWrapper = new RuleMgtWrapperStub();\r
-        dbDaoUtilStub = new DbDaoUtilStub();\r
+        alarmInfoDaoServiceStub = new AlarmInfoDaoServiceStub();\r
+        droolsEngine.setAlarmInfoDaoService(alarmInfoDaoServiceStub);\r
+        correlationRuleDaoServiceStub = new CorrelationRuleDaoServiceStub();\r
+        ruleMgtWrapperMock = new RuleMgtWrapperStub(correlationRuleDaoServiceStub);\r
         closedLoopControlNameCache = new ClosedLoopControlNameCache();\r
         droolsEngine.setClosedLoopControlNameCache(closedLoopControlNameCache);\r
-        droolsEngine.setDaoUtil(dbDaoUtilStub);\r
-        droolsEngine.setRuleMgtWrapper(ruleMgtWrapper);\r
+        droolsEngine.setRuleMgtWrapper(ruleMgtWrapperMock);\r
 \r
-        Whitebox.invokeMethod(droolsEngine, "init");\r
+        Whitebox.invokeMethod(droolsEngine, "run", null);\r
         System.clearProperty(MicroServiceConfig.HOSTNAME);\r
     }\r
 \r
-    @Before\r
-    public void setUp() throws Exception {\r
-        PowerMock.resetAll();\r
-    }\r
-\r
     @Test\r
     public void deployRule_rule_is_null() throws CorrelationException {\r
         thrown.expect(NullPointerException.class);\r
@@ -241,78 +237,74 @@ public class DroolsEngineTest {
 \r
         assertThat(packages.contains("packageCheck"), is(true));\r
     }\r
-}\r
-\r
-class RuleMgtWrapperStub extends RuleMgtWrapper {\r
-    private List<CorrelationRule> rules;\r
-\r
-    public RuleMgtWrapperStub() {\r
-        rules = new ArrayList<>();\r
-        CorrelationRule rule = new CorrelationRule();\r
-        rule.setEnabled(1);\r
-        rule.setContent("package org.onap.holmes;");\r
-        rule.setPackageName("UT");\r
-        rule.setClosedControlLoopName(UUID.randomUUID().toString());\r
-        rule.setEngineInstance("127.0.0.1");\r
-        rules.add(rule);\r
-    }\r
-\r
-    public List<CorrelationRule> getRules() {\r
-        return rules;\r
-    }\r
-\r
-    public void setRules(List<CorrelationRule> rules) {\r
-        this.rules = rules;\r
-    }\r
 \r
-    @Override\r
-    public List<CorrelationRule> queryRuleByEnable(int enabled) throws CorrelationException {\r
-        return rules.stream().filter(rule -> rule.getEnabled() == enabled).collect(Collectors.toList());\r
+    class RuleMgtWrapperStub extends RuleMgtWrapper {\r
+        private List<CorrelationRule> rules;\r
+\r
+        public RuleMgtWrapperStub(CorrelationRuleDaoService correlationRuleDaoService) {\r
+            super(correlationRuleDaoService);\r
+            rules = new ArrayList<>();\r
+            CorrelationRule rule = new CorrelationRule();\r
+            rule.setEnabled(1);\r
+            rule.setContent("package org.onap.holmes;");\r
+            rule.setPackageName("UT");\r
+            rule.setClosedControlLoopName(UUID.randomUUID().toString());\r
+            rule.setEngineInstance("127.0.0.1");\r
+            rules.add(rule);\r
+        }\r
+\r
+        public List<CorrelationRule> getRules() {\r
+            return rules;\r
+        }\r
+\r
+        public void setRules(List<CorrelationRule> rules) {\r
+            this.rules = rules;\r
+        }\r
+\r
+        @Override\r
+        public List<CorrelationRule> queryRuleByEnable(int enabled) throws CorrelationException {\r
+            return rules.stream().filter(rule -> rule.getEnabled() == enabled).collect(Collectors.toList());\r
+        }\r
     }\r
-}\r
 \r
-class AlarmInfoDaoStub extends AlarmInfoDao {\r
-\r
-    private List<AlarmInfo> alarms;\r
-\r
-    public AlarmInfoDaoStub() {\r
-        alarms = new ArrayList<>();\r
-        AlarmInfo info = new AlarmInfo();\r
-        info.setEventId("eventId");\r
-        info.setEventName("eventName");\r
-        info.setStartEpochMicroSec(1L);\r
-        info.setLastEpochMicroSec(1L);\r
-        info.setSourceId("sourceId");\r
-        info.setSourceName("sourceName");\r
-        info.setRootFlag(0);\r
-        info.setAlarmIsCleared(1);\r
-        alarms.add(info);\r
+    class AlarmInfoDaoServiceStub extends AlarmInfoDaoService {\r
+\r
+        private List<AlarmInfo> alarms;\r
+\r
+        public AlarmInfoDaoServiceStub() {\r
+            alarms = new ArrayList<>();\r
+            AlarmInfo info = new AlarmInfo();\r
+            info.setEventId("eventId");\r
+            info.setEventName("eventName");\r
+            info.setStartEpochMicroSec(1L);\r
+            info.setLastEpochMicroSec(1L);\r
+            info.setSourceId("sourceId");\r
+            info.setSourceName("sourceName");\r
+            info.setRootFlag(0);\r
+            info.setAlarmIsCleared(1);\r
+            alarms.add(info);\r
+        }\r
+\r
+        @Override\r
+        public AlarmInfo saveAlarm(AlarmInfo alarmInfo) {\r
+            alarms.add(alarmInfo);\r
+            return alarmInfo;\r
+        }\r
+\r
+        @Override\r
+        public List<AlarmInfo> queryAllAlarm() {\r
+            return alarms;\r
+        }\r
+\r
+        @Override\r
+        public void deleteAlarm(AlarmInfo alarmInfo) {\r
+\r
+        }\r
     }\r
 \r
-    @Override\r
-    protected String addAlarm(AlarmInfo alarmInfo) {\r
-        alarms.add(alarmInfo);\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    protected List<AlarmInfo> queryAlarm() {\r
-        return alarms;\r
-    }\r
+    class CorrelationRuleDaoServiceStub extends CorrelationRuleDaoService {\r
 \r
-    @Override\r
-    protected int deleteAlarmByAlarmIsCleared(String alarmName, String sourceName, String sourceId) {\r
-        return 1;\r
     }\r
 }\r
 \r
-class DbDaoUtilStub extends DbDaoUtil {\r
-    private AlarmInfoDao dao = new AlarmInfoDaoStub();\r
 \r
-    @Override\r
-    public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {\r
-\r
-        return (T) dao;\r
-\r
-    }\r
-}\r
index aa2052d..f4ad483 100644 (file)
@@ -26,11 +26,8 @@ import org.onap.holmes.engine.manager.DroolsEngine;
 import org.onap.holmes.engine.request.CompileRuleRequest;\r
 import org.onap.holmes.engine.request.DeployRuleRequest;\r
 import org.powermock.api.easymock.PowerMock;\r
-import org.powermock.reflect.Whitebox;\r
 \r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.ws.rs.WebApplicationException;\r
-import java.util.Locale;\r
+import jakarta.ws.rs.WebApplicationException;\r
 \r
 import static org.easymock.EasyMock.*;\r
 \r
@@ -47,23 +44,20 @@ public class EngineResourcesTest {
         closedLoopControlNameCache = new ClosedLoopControlNameCache();\r
         engineResources = new EngineResources();\r
         engineResources.setClosedLoopControlNameCache(closedLoopControlNameCache);\r
-\r
-        Whitebox.setInternalState(engineResources,"droolsEngine", droolsEngine);\r
+        engineResources.setDroolsEngine(droolsEngine);\r
         PowerMock.resetAll();\r
     }\r
 \r
     @Test\r
     public void deployRule_exception() throws CorrelationException {\r
         DeployRuleRequest deployRuleRequest = new DeployRuleRequest();\r
-        HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
 \r
         thrown.expect(WebApplicationException.class);\r
 \r
-        expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
         expect(droolsEngine.deployRule(anyObject(DeployRuleRequest.class))).\r
                 andThrow(new CorrelationException(""));\r
         PowerMock.replayAll();\r
-        engineResources.deployRule(deployRuleRequest, httpRequest);\r
+        engineResources.deployRule(deployRuleRequest);\r
         PowerMock.verifyAll();\r
     }\r
 \r
@@ -72,66 +66,55 @@ public class EngineResourcesTest {
         DeployRuleRequest deployRuleRequest = new DeployRuleRequest();\r
         deployRuleRequest.setContent("package packageName;\n\nimport xxx.xxx.xxx;");\r
         deployRuleRequest.setLoopControlName("loopControlName");\r
-        HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
 \r
-        expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
         expect(droolsEngine.deployRule(anyObject(DeployRuleRequest.class))).andReturn("packageName");\r
         PowerMock.replayAll();\r
-        engineResources.deployRule(deployRuleRequest, httpRequest);\r
+        engineResources.deployRule(deployRuleRequest);\r
         PowerMock.verifyAll();\r
     }\r
 \r
     @Test\r
     public void undeployRule_exception() throws CorrelationException {\r
         String packageName = "packageName";\r
-        HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
 \r
         thrown.expect(WebApplicationException.class);\r
 \r
-        expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
         droolsEngine.undeployRule(anyObject(String.class));\r
         expectLastCall().andThrow(new CorrelationException(""));\r
         PowerMock.replayAll();\r
-        engineResources.undeployRule(packageName, httpRequest);\r
+        engineResources.undeployRule(packageName);\r
         PowerMock.verifyAll();\r
     }\r
 \r
     @Test\r
     public void undeployRule_normal() throws CorrelationException {\r
         String packageName = "packageName";\r
-        HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
 \r
-        expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
         droolsEngine.undeployRule(anyObject(String.class));\r
         PowerMock.replayAll();\r
-        engineResources.undeployRule(packageName, httpRequest);\r
+        engineResources.undeployRule(packageName);\r
         PowerMock.verifyAll();\r
     }\r
 \r
     @Test\r
     public void compileRule_exception() throws CorrelationException {\r
         CompileRuleRequest compileRuleRequest = new CompileRuleRequest();\r
-        HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
 \r
         thrown.expect(WebApplicationException.class);\r
 \r
-        expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
         droolsEngine.compileRule(anyObject(String.class));\r
         expectLastCall().andThrow(new CorrelationException(""));\r
         PowerMock.replayAll();\r
-        engineResources.compileRule(compileRuleRequest, httpRequest);\r
+        engineResources.compileRule(compileRuleRequest);\r
         PowerMock.verifyAll();\r
     }\r
 \r
     @Test\r
     public void compileRule_normal() throws CorrelationException {\r
         CompileRuleRequest compileRuleRequest = new CompileRuleRequest();\r
-        HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
-\r
-        expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
         droolsEngine.compileRule(anyObject(String.class));\r
         PowerMock.replayAll();\r
-        engineResources.compileRule(compileRuleRequest, httpRequest);\r
+        engineResources.compileRule(compileRuleRequest);\r
         PowerMock.verifyAll();\r
     }\r
 }\r
index cd7aff4..05fb7b5 100644 (file)
@@ -1,5 +1,5 @@
 /**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2021 ZTE Corporation.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
 \r
 package org.onap.holmes.engine.wrapper;\r
 \r
-import static org.easymock.EasyMock.anyInt;\r
-import static org.easymock.EasyMock.anyObject;\r
-import static org.easymock.EasyMock.expect;\r
-\r
-import java.util.ArrayList;\r
 import org.junit.Before;\r
 import org.junit.Rule;\r
 import org.junit.Test;\r
 import org.junit.rules.ExpectedException;\r
-import org.onap.holmes.common.api.entity.CorrelationRule;\r
 import org.onap.holmes.common.exception.CorrelationException;\r
-import org.onap.holmes.common.utils.DbDaoUtil;\r
-import org.onap.holmes.engine.db.CorrelationRuleDao;\r
+import org.onap.holmes.engine.db.CorrelationRuleDaoService;\r
 import org.powermock.api.easymock.PowerMock;\r
-import org.powermock.reflect.Whitebox;\r
+\r
+import java.util.ArrayList;\r
+\r
+import static org.easymock.EasyMock.anyInt;\r
+import static org.easymock.EasyMock.expect;\r
 \r
 public class RuleMgtWrapperTest {\r
 \r
     @Rule\r
     public ExpectedException thrown = ExpectedException.none();\r
-    private DbDaoUtil daoUtil;\r
+    private CorrelationRuleDaoService correlationRuleDaoService;\r
     private RuleMgtWrapper ruleMgtWrapper;\r
 \r
     @Before\r
     public void setUp() {\r
-        daoUtil = PowerMock.createMock(DbDaoUtil.class);\r
-        ruleMgtWrapper = new RuleMgtWrapper();\r
+        correlationRuleDaoService = PowerMock.createMock(CorrelationRuleDaoService.class);\r
+        ruleMgtWrapper = new RuleMgtWrapper(correlationRuleDaoService);\r
 \r
-        Whitebox.setInternalState(ruleMgtWrapper, "daoUtil", daoUtil);\r
         PowerMock.resetAll();\r
     }\r
 \r
     @Test\r
     public void queryRuleByEnable_normal() throws CorrelationException {\r
         int enable = 3;\r
-\r
-        CorrelationRuleDao correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);\r
-        expect(daoUtil.getJdbiDaoByOnDemand(anyObject(Class.class))).andReturn(correlationRuleDao);\r
-        expect(correlationRuleDao.queryRuleByRuleEnable(anyInt())).andReturn(new ArrayList<CorrelationRule>());\r
+        expect(correlationRuleDaoService.queryRuleByRuleEnable(anyInt())).andReturn(new ArrayList());\r
         PowerMock.replayAll();\r
         ruleMgtWrapper.queryRuleByEnable(enable);\r
         PowerMock.verifyAll();\r
diff --git a/pom.xml b/pom.xml
index 831dbb8..83a1104 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!--
-  ~ Copyright 2017-2020 ZTE Corporation.
+  ~ Copyright 2017-2022 ZTE Corporation.
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
 
     <groupId>org.onap.holmes.engine-management</groupId>
     <artifactId>holmes-engine-parent</artifactId>
-    <version>1.3.7-SNAPSHOT</version>
+    <version>1.3.8-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>holmes-engine-management</name>
     <modules>
         <bundle.name>${project.artifactId}-${project.version}</bundle.name>
 
         <drools.version>7.62.0.Final</drools.version>
-        <dropwizard.version>2.0.9</dropwizard.version>
         <powermock.version>2.0.7</powermock.version>
         <jacoco.version>0.8.5</jacoco.version>
+        <springboot.version>2.7.2</springboot.version>
+        <jdbi.version>3.19.0</jdbi.version>
+        <jersey.version>3.0.5</jersey.version>
+        <jakarta.ws.rs.version>3.1.0</jakarta.ws.rs.version>
 
         <packagename>onap-holmes-engine-d</packagename>
         <linux64id>linux64</linux64id>
         </sonar.coverage.jacoco.xmlReportPaths>
     </properties>
 
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${springboot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
     <dependencies>
         <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <version>1.2.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.postgresql</groupId>
-            <artifactId>postgresql</artifactId>
-            <version>42.2.13</version>
-        </dependency>
-        <dependency>
-            <groupId>io.dropwizard</groupId>
-            <artifactId>dropwizard-core</artifactId>
-            <version>${dropwizard.version}</version>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
             <exclusions>
                 <exclusion>
-                    <groupId>org.hibernate.validator</groupId>
-                    <artifactId>hibernate-validator</artifactId>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-json</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>
         <dependency>
-            <groupId>org.hibernate.validator</groupId>
-            <artifactId>hibernate-validator</artifactId>
-            <version>6.1.5.Final</version>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-autoconfigure</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jdbi</groupId>
+            <artifactId>jdbi3-postgres</artifactId>
+            <version>${jdbi.version}</version>
         </dependency>
         <dependency>
-            <groupId>io.dropwizard</groupId>
-            <artifactId>dropwizard-db</artifactId>
-            <version>${dropwizard.version}</version>
+            <groupId>org.jdbi</groupId>
+            <artifactId>jdbi3-sqlobject</artifactId>
+            <version>${jdbi.version}</version>
         </dependency>
         <dependency>
-            <groupId>io.dropwizard</groupId>
-            <artifactId>dropwizard-jdbi</artifactId>
-            <version>2.0.0-rc9</version>
+            <groupId>org.postgresql</groupId>
+            <artifactId>postgresql</artifactId>
+            <version>42.2.13</version>
         </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
-            <version>1.18.4</version>
+            <version>1.18.16</version>
         </dependency>
         <dependency>
             <groupId>org.javassist</groupId>
             <artifactId>commons-collections</artifactId>
             <version>3.2.2</version>
         </dependency>
-        <dependency>
-            <groupId>net.sf.json-lib</groupId>
-            <artifactId>json-lib</artifactId>
-            <version>2.4</version>
-            <classifier>jdk15</classifier>
-            <exclusions>
-                <exclusion>
-                    <groupId>commons-collections</groupId>
-                    <artifactId>commons-collections</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>commons-beanutils</groupId>
-                    <artifactId>commons-beanutils</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
         <dependency>
             <groupId>org.onap.msb.java-sdk</groupId>
             <artifactId>msb-java-sdk</artifactId>
         <dependency>
             <groupId>org.onap.holmes.common</groupId>
             <artifactId>holmes-actions</artifactId>
-            <version>1.4.2</version>
+            <version>1.4.3</version>
             <exclusions>
-                <exclusion>
-                    <groupId>io.dropwizard</groupId>
-                    <artifactId>dropwizard-db</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>io.dropwizard</groupId>
-                    <artifactId>dropwizard-core</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.glassfish.jersey.containers</groupId>
-                    <artifactId>jersey-container-servlet-core</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.glassfish.hk2</groupId>
-                    <artifactId>hk2-locator</artifactId>
-                </exclusion>
                 <exclusion>
                     <groupId>io.swagger</groupId>
                     <artifactId>swagger-jersey2-jaxrs</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>jakarta.ws.rs</groupId>
+            <artifactId>jakarta.ws.rs-api</artifactId>
+            <version>${jakarta.ws.rs.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.xml.bind</groupId>
+            <artifactId>jakarta.xml.bind-api</artifactId>
+            <version>4.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.xml.bind</groupId>
+            <artifactId>jaxb-api</artifactId>
+            <version>2.3.1</version>
+        </dependency>
+
         <dependency>
             <groupId>org.drools</groupId>
             <artifactId>drools-core</artifactId>
             <version>${drools.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.drools</groupId>
-            <artifactId>drools-mvel</artifactId>
-            <version>${drools.version}</version>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.14.1</version>
         </dependency>
         <dependency>
             <groupId>io.swagger</groupId>
         <dependency>
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
-            <version>2.8.9</version>
-        </dependency>
-        <dependency>
-            <groupId>com.squareup.retrofit2</groupId>
-            <artifactId>retrofit</artifactId>
-            <version>2.5.0</version>
+            <version>2.8.6</version>
         </dependency>
         <dependency>
             <groupId>com.thoughtworks.xstream</groupId>
             <artifactId>xstream</artifactId>
-            <version>1.4.18</version>
+            <version>1.4.16</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.inject</groupId>
+            <artifactId>jersey-hk2</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.media</groupId>
+            <artifactId>jersey-media-json-jackson</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-common</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-client</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-server</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <artifactId>jersey-container-servlet-core</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.ext</groupId>
+            <artifactId>jersey-entity-filtering</artifactId>
+            <version>${jersey.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.activation</groupId>
+            <artifactId>jakarta.activation-api</artifactId>
+            <version>2.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.annotation</groupId>
+            <artifactId>jakarta.annotation-api</artifactId>
+            <version>2.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>javax.annotation-api</artifactId>
+            <version>1.3.2</version>
+            <scope>provided</scope>
         </dependency>
 
         <!-- Do NOT remove org.reflections:reflections. Otherwise, the docker will fail to start. -->
             <artifactId>powermock-classloading-xstream</artifactId>
             <version>${powermock.version}</version>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <artifactId>xstream</artifactId>
+                    <groupId>com.thoughtworks.xstream</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.hamcrest</groupId>
             <version>${powermock.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>2.28.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-support</artifactId>
+            <version>2.0.7</version>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.powermock</groupId>
             <artifactId>powermock-api-easymock</artifactId>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.8.2</version>
+            <version>4.13.2</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.8.0</version>
-                <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
-                    <release>11</release>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>${jacoco.version}</version>
-                <executions>
-                    <execution>
-                        <id>prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-                    <execution>
-                        <id>report</id>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                        <configuration>
-                            <dataFile>${project.build.directory}/code-coverage/jacoco.exec</dataFile>
-                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
 </project>