diff options
Diffstat (limited to 'rulemgt')
8 files changed, 46 insertions, 397 deletions
diff --git a/rulemgt/pom.xml b/rulemgt/pom.xml index f08de1d..deedb06 100644 --- a/rulemgt/pom.xml +++ b/rulemgt/pom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - ~ Copyright 2017 ZTE Corporation. + ~ Copyright 2017-2020 ZTE Corporation. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. @@ -31,305 +31,10 @@ <jetty.version>9.4.18.v20190429</jetty.version> </properties> - <dependencies> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-validator</artifactId> - <version>5.4.2.Final</version> - </dependency> - <dependency> - <groupId>org.onap.msb.java-sdk</groupId> - <artifactId>msb-java-sdk</artifactId> - <exclusions> - <exclusion> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - </exclusion> - <exclusion> - <groupId>com.squareup.okhttp3</groupId> - <artifactId>okhttp</artifactId> - </exclusion> - <exclusion> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.reflections</groupId> - <artifactId>reflections</artifactId> - </dependency> - <dependency> - <groupId>org.onap.holmes.common</groupId> - <artifactId>holmes-actions</artifactId> - <exclusions> - <exclusion> - <groupId>org.glassfish.jersey.containers</groupId> - <artifactId>jersey-container-servlet-core</artifactId> - </exclusion> - <exclusion> - <groupId>io.swagger</groupId> - <artifactId>swagger-jersey2-jaxrs</artifactId> - </exclusion> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - </dependency> - <dependency> - <groupId>io.dropwizard</groupId> - <artifactId>dropwizard-db</artifactId> - </dependency> - <dependency> - <groupId>org.antlr</groupId> - <artifactId>stringtemplate</artifactId> - </dependency> - <dependency> - <groupId>io.dropwizard</groupId> - <artifactId>dropwizard-core</artifactId> - <exclusions> - <exclusion> - <groupId>ch.qos.logback</groupId> - <artifactId>logback</artifactId> - </exclusion> - <exclusion> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-validator</artifactId> - </exclusion> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-http</artifactId> - </exclusion> - <exclusion> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-util</artifactId> - </exclusion> - <exclusion> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - </exclusion> - <exclusion> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - <version>${jetty.version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-http</artifactId> - <version>${jetty.version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-util</artifactId> - <version>${jetty.version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> - <version>${jetty.version}</version> - </dependency> - <dependency> - <groupId>com.squareup.okhttp3</groupId> - <artifactId>okhttp</artifactId> - <version>3.14.1</version> - </dependency> - <dependency> - <groupId>io.dropwizard</groupId> - <artifactId>dropwizard-jdbi</artifactId> - </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </dependency> - <dependency> - <groupId>org.postgresql</groupId> - <artifactId>postgresql</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-junit4</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>io.swagger</groupId> - <artifactId>swagger-jersey2-jaxrs</artifactId> - <exclusions> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.dataformat</groupId> - <artifactId>jackson-dataformat-xml</artifactId> - </exclusion> - </exclusions> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-easymock</artifactId> - <version>1.6.5</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito</artifactId> - <version>1.7.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-junit4-rule</artifactId> - <version>1.6.5</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-classloading-xstream</artifactId> - <version>1.6.5</version> - <exclusions> - <exclusion> - <groupId>com.thoughtworks.xstream</groupId> - <artifactId>xstream</artifactId> - </exclusion> - </exclusions> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.thoughtworks.xstream</groupId> - <artifactId>xstream</artifactId> - <version>1.4.10</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <version>3.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.javassist</groupId> - <artifactId>javassist</artifactId> - <version>3.20.0-GA</version> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <version>4.5.6</version> - </dependency> - <dependency> - <groupId>com.googlecode.json-simple</groupId> - <artifactId>json-simple</artifactId> - <version>1.1.1</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>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <version>3.2.2</version> - </dependency> - <dependency> - <groupId>com.alibaba</groupId> - <artifactId>fastjson</artifactId> - <version>1.2.49</version> - </dependency> - <dependency> - <groupId>org.glassfish.jersey.core</groupId> - <artifactId>jersey-server</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-common</artifactId> - <version>${jersey.version}</version> - </dependency> - <dependency> - <groupId>org.glassfish.jersey.containers</groupId> - <artifactId>jersey-container-servlet-core</artifactId> - <version>${jersey.version}</version> - </dependency> - </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <addDefaultImplementationEntries>true</addDefaultImplementationEntries> - </manifest> - </archive> - </configuration> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> @@ -337,39 +42,6 @@ <target>1.8</target> </configuration> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <configuration> - <createDependencyReducedPom>true</createDependencyReducedPom> - <filters> - <filter> - <artifact>*:*</artifact> - <excludes> - <exclude>META-INF/*.SF</exclude> - <exclude>META-INF/*.DSA</exclude> - <exclude>META-INF/*.RSA</exclude> - </excludes> - </filter> - </filters> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - <configuration> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> - <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> - <mainClass>org.onap.holmes.rulemgt.RuleActiveApp</mainClass> - </transformer> - </transformers> - </configuration> - </execution> - </executions> - </plugin> </plugins> <resources> <resource> diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java index 058aea7..21855f8 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java @@ -17,7 +17,6 @@ package org.onap.holmes.rulemgt; import io.dropwizard.setup.Environment; -import lombok.extern.slf4j.Slf4j; import org.onap.holmes.common.config.MicroServiceConfig; import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication; import org.onap.holmes.common.exception.CorrelationException; @@ -29,6 +28,8 @@ import org.onap.holmes.rulemgt.msb.MsbQuery; import org.onap.holmes.rulemgt.resources.RuleMgtResources; 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 javax.servlet.DispatcherType; import java.util.EnumSet; @@ -38,19 +39,15 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -@Slf4j public class RuleActiveApp extends IOCApplication<RuleAppConfig> { + private Logger log = LoggerFactory.getLogger(RuleActiveApp.class); + public static void main(String[] args) throws Exception { new RuleActiveApp().run(args); } @Override - public String getName() { - return "Holmes Rule Management ActiveApp APP "; - } - - @Override public void run(RuleAppConfig configuration, Environment environment) throws Exception { super.run(configuration, environment); diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDao.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDao.java index b0f0b96..104f74d 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDao.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDao.java @@ -97,7 +97,7 @@ public class CorrelationRuleQueryDao { if (field.getName().contains("jacoco")) {
continue;
}
- PropertyDescriptor pd = new PropertyDescriptor(field.getName(),
+ PropertyDescriptor pd = new PropertyDescriptor((String)field.getName(),
clazz);
Method getMethod = pd.getReadMethod();
Object o = getMethod.invoke(ruleQueryCondition);
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineInsQueryTool.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineInsQueryTool.java index a0eee1f..36b5b6f 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineInsQueryTool.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/msb/EngineInsQueryTool.java @@ -46,24 +46,24 @@ public class EngineInsQueryTool { } public List<String> getInstanceList() throws Exception { - String response; - HttpGet httpGet = new HttpGet(url); - try (CloseableHttpClient httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT)) { - HttpResponse httpResponse = HttpsUtils.get(httpGet, new HashMap<>(), httpClient); - response = HttpsUtils.extractResponseEntity(httpResponse); - } catch (Exception e) { - throw e; - } finally { - httpGet.releaseConnection(); + String response; + HttpGet httpGet = new HttpGet(url); + try (CloseableHttpClient httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT)) { + HttpResponse httpResponse = HttpsUtils.get(httpGet, new HashMap<>(), httpClient); + response = HttpsUtils.extractResponseEntity(httpResponse); + } catch (Exception e) { + throw e; + } finally { + httpGet.releaseConnection(); - } - ServiceEntity service = GsonUtil.jsonToBean(response, ServiceEntity.class); - List<ServiceNode4Query> nodesList = service.getNodes(); - List<String> ipList = new ArrayList<>(); - for (ServiceNode4Query node : nodesList) { - ipList.add(node.getIp()); - } - return ipList; + } + ServiceEntity service = GsonUtil.jsonToBean(response, ServiceEntity.class); + List<ServiceNode4Query> nodesList = service.getNodes(); + List<String> ipList = new ArrayList<>(); + for (ServiceNode4Query node : nodesList) { + ipList.add(node.getIp()); + } + return ipList; } diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/RuleActiveAppTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/RuleActiveAppTest.java index 287d5a3..e34643a 100644 --- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/RuleActiveAppTest.java +++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/RuleActiveAppTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 ZTE Corporation. + * Copyright 2017-2020 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,19 +16,8 @@ package org.onap.holmes.rulemgt; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsEqual.equalTo; - -import org.junit.Test; - public class RuleActiveAppTest { - @Test - public void getName() throws Exception { - RuleActiveApp app = new RuleActiveApp(); - assertThat(app.getName(), equalTo("Holmes Rule Management ActiveApp APP ")); - } - public static void main(String[] args) throws Exception { String filePath = "E:\\Codes\\ONAP\\holmes\\rule-management\\rulemgt-standalone\\src\\main\\assembly\\conf\\rulemgt.yml"; new RuleActiveApp().run(new String[]{"server", filePath}); diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java index e028a2c..0e97e3a 100644 --- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java +++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java @@ -1,5 +1,5 @@ /**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2020 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,38 +16,35 @@ package org.onap.holmes.rulemgt.db;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
import org.easymock.EasyMock;
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.entity.CorrelationRule;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.DbDaoUtil;
import org.onap.holmes.rulemgt.bean.request.RuleQueryCondition;
import org.powermock.api.easymock.PowerMock;
-import org.powermock.modules.junit4.rule.PowerMockRule;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.Query;
+import java.util.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({DbDaoUtil.class, Handle.class, Query.class})
public class CorrelationRuleQueryDaoTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Rule
- public PowerMockRule powerMockRule = new PowerMockRule();
private DbDaoUtil dbDaoUtil;
private Handle handle;
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/send/RuleAllocatorTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/send/RuleAllocatorTest.java index 5dc8281..09fcf93 100644 --- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/send/RuleAllocatorTest.java +++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/send/RuleAllocatorTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 ZTE Corporation. + * Copyright 2017-2020 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. @@ -36,7 +36,6 @@ import org.onap.holmes.rulemgt.wrapper.RuleQueryWrapper; import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.rule.PowerMockRule; import java.util.ArrayList; import java.util.Calendar; @@ -46,6 +45,7 @@ import java.util.stream.Collectors; import static org.onap.holmes.rulemgt.send.RuleAllocator.ENABLE; +@RunWith(PowerMockRunner.class) @PrepareForTest({ServiceLocator.class, RuleMgtWrapper.class, RuleQueryWrapper.class, EngineWrapper.class, EngineInsQueryTool.class, DbDaoUtil.class, ServiceLocatorHolder.class}) public class RuleAllocatorTest { @@ -53,9 +53,6 @@ public class RuleAllocatorTest { @Rule public ExpectedException thrown = ExpectedException.none(); - @Rule - public PowerMockRule rule = new PowerMockRule(); - private RuleMgtWrapper ruleMgtWrapperMock; private RuleQueryWrapper ruleQueryWrapperMock; private EngineWrapper engineWrapperMock; diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java index 4b3e60f..90384ce 100644 --- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java +++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java @@ -16,37 +16,34 @@ package org.onap.holmes.rulemgt.wrapper;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onap.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;
-import org.onap.holmes.rulemgt.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.rulemgt.bean.request.CorrelationDeployRule4Engine;
-import org.onap.holmes.rulemgt.bean.request.RuleCreateRequest;
-import org.onap.holmes.rulemgt.bean.request.RuleDeleteRequest;
-import org.onap.holmes.rulemgt.bean.request.RuleQueryCondition;
-import org.onap.holmes.rulemgt.bean.request.RuleUpdateRequest;
+import org.onap.holmes.rulemgt.bean.request.*;
import org.onap.holmes.rulemgt.bean.response.RuleAddAndUpdateResponse;
import org.onap.holmes.rulemgt.bean.response.RuleQueryListResponse;
import org.onap.holmes.rulemgt.bolt.enginebolt.EngineWrapper;
+import org.onap.holmes.rulemgt.db.CorrelationRuleDao;
import org.onap.holmes.rulemgt.db.CorrelationRuleQueryDao;
import org.onap.holmes.rulemgt.send.Ip4AddingRule;
import org.powermock.api.easymock.PowerMock;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.powermock.reflect.Whitebox;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+
public class RuleMgtWrapperTest {
@Rule
|