summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-10-14 16:41:35 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2017-10-14 16:41:35 +0800
commit8b2d0be73ab8dcbd573769ed89ad27ecd7c25f88 (patch)
treef1a9730298b9a5b22c0d8743957e00c0119c622a
parent049c1722681a7c0d564d625f2740cbc47c15a4be (diff)
Add DMaaP Configuration APIs for Testing
Change-Id: Iefc0f22da204f30fca8ef81effcd3497a347ebc0 Issue-ID: HOLMES-59 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
-rw-r--r--rulemgt-standalone/src/main/assembly/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql3
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java2
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java4
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java1
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java28
-rw-r--r--rulemgt/src/test/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java1
-rw-r--r--rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java10
7 files changed, 24 insertions, 25 deletions
diff --git a/rulemgt-standalone/src/main/assembly/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql b/rulemgt-standalone/src/main/assembly/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql
index fb1c86d..cbd3c59 100644
--- a/rulemgt-standalone/src/main/assembly/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql
+++ b/rulemgt-standalone/src/main/assembly/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql
@@ -33,6 +33,7 @@ CREATE ROLE holmes with PASSWORD 'holmespwd' LOGIN;
CREATE TABLE APLUS_RULE (
RID VARCHAR(30) NOT NULL,
NAME VARCHAR(150) NOT NULL,
+ CTRLLOOP VARCHAR(150) NOT NULL,
DESCRIPTION VARCHAR(4000) NULL,
ENABLE SMALLINT NOT NULL,
TEMPLATEID BIGINT NOT NULL,
@@ -50,6 +51,8 @@ CREATE TABLE APLUS_RULE (
UNIQUE (NAME)
);
+CREATE INDEX IDX_APLUS_RULE_NAME ON APLUS_RULE (NAME);
+CREATE INDEX IDX_APLUS_RULE_CTRLLOOP ON APLUS_RULE (CTRLLOOP);
CREATE INDEX IDX_APLUS_RULE_ENABLE ON APLUS_RULE (ENABLE);
CREATE INDEX IDX_APLUS_RULE_TEMPLATEID ON APLUS_RULE (TEMPLATEID);
CREATE INDEX IDX_APLUS_RULE_ENGINEID ON APLUS_RULE (ENGINEID);
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java
index e2811e3..99af585 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java
@@ -30,4 +30,6 @@ public class RuleUpdateRequest {
private int enabled;
@JsonProperty(value="ruleid")
private String ruleId;
+ @JsonProperty(value = "loopcontrolname")
+ private String loopControlName;
}
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java
index 6b55d98..98553c9 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java
@@ -30,10 +30,10 @@ import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
public abstract class CorrelationRuleDao {
@GetGeneratedKeys
- @SqlUpdate("INSERT INTO APLUS_RULE (NAME,DESCRIPTION,ENABLE,TEMPLATEID,ENGINETYPE,CREATOR,UPDATOR,PARAMS,CONTENT ,VENDOR,CREATETIME,UPDATETIME,ENGINEID,PACKAGE,RID) VALUES (:name,:description,:enabled,:templateID,:engineType,:creator,:modifier,:params,:content,:vendor,:createTime,:updateTime,:engineID,:packageName,:rid)")
+ @SqlUpdate("INSERT INTO APLUS_RULE (NAME,CTRLLOOP,DESCRIPTION,ENABLE,TEMPLATEID,ENGINETYPE,CREATOR,UPDATOR,PARAMS,CONTENT ,VENDOR,CREATETIME,UPDATETIME,ENGINEID,PACKAGE,RID) VALUES (:name,:closedControlLoopName,:description,:enabled,:templateID,:engineType,:creator,:modifier,:params,:content,:vendor,:createTime,:updateTime,:engineID,:packageName,:rid)")
protected abstract String addRule(@BindBean CorrelationRule correlationRule);
- @SqlUpdate("UPDATE APLUS_RULE SET DESCRIPTION=:description,ENABLE=:enabled,CONTENT=:content,UPDATOR=:modifier,UPDATETIME=:updateTime, PACKAGE=:packageName WHERE RID=:rid")
+ @SqlUpdate("UPDATE APLUS_RULE SET CTRLLOOP=:closedControlLoopName,DESCRIPTION=:description,ENABLE=:enabled,CONTENT=:content,UPDATOR=:modifier,UPDATETIME=:updateTime, PACKAGE=:packageName WHERE RID=:rid")
protected abstract int updateRuleByRid(@BindBean CorrelationRule correlationRule);
@SqlUpdate("DELETE FROM APLUS_RULE WHERE RID=:rid")
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
index d40253f..98d7d01 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
@@ -42,6 +42,7 @@ public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> {
correlationRule.setContent(resultSet.getString("content"));
correlationRule.setVendor(resultSet.getString("vendor"));
correlationRule.setPackageName(resultSet.getString("package"));
+ correlationRule.setClosedControlLoopName(resultSet.getString("ctrlloop"));
return correlationRule;
}
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
index c1f1917..6ab7576 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
@@ -73,7 +73,7 @@ public class RuleMgtWrapper {
if (ruleTemp != null) {
throw new CorrelationException("A rule with the same name already exists.");
}
- String packageName = deployRule2Engine(correlationRule, ruleCreateRequest.getLoopControlName());
+ String packageName = deployRule2Engine(correlationRule);
correlationRule.setPackageName(packageName);
CorrelationRule result = null;
try {
@@ -135,7 +135,10 @@ public class RuleMgtWrapper {
int oldEnabled = oldCorrelationRule.getEnabled();
String newDes = newCorrelationRule.getDescription();
String oldDes = oldCorrelationRule.getDescription();
- if (newContent.equals(oldContent) && newEnabled == oldEnabled && newDes.equals(oldDes)) {
+ String oldControlLoop = oldCorrelationRule.getClosedControlLoopName();
+ String newControlLoop = newCorrelationRule.getClosedControlLoopName();
+ if (newContent.equals(oldContent) && newEnabled == oldEnabled
+ && newDes.equals(oldDes) && newControlLoop.equals(oldControlLoop)) {
return false;
}
return true;
@@ -178,6 +181,7 @@ public class RuleMgtWrapper {
correlationRule.setCreator(userName);
correlationRule.setModifier(userName);
correlationRule.setEnabled(ruleCreateRequest.getEnabled());
+ correlationRule.setClosedControlLoopName(ruleCreateRequest.getLoopControlName());
return correlationRule;
}
@@ -192,6 +196,7 @@ public class RuleMgtWrapper {
correlationRule.setUpdateTime(new Date());
correlationRule.setModifier(modifier);
correlationRule.setName(ruleName);
+ correlationRule.setClosedControlLoopName(ruleUpdateRequest.getLoopControlName());
return correlationRule;
}
@@ -204,15 +209,6 @@ public class RuleMgtWrapper {
return "";
}
- private String deployRule2Engine(CorrelationRule correlationRule, String loopControlName)
- throws CorrelationException {
- if (engineWarpper.checkRuleFromEngine(correlationRules2CheckRule(correlationRule)) && (
- correlationRule.getEnabled() == RuleMgtConstant.STATUS_RULE_OPEN)) {
- return engineWarpper.deployEngine(correlationRules2DeployRule(correlationRule, loopControlName));
- }
- return "";
- }
-
public RuleQueryListResponse getCorrelationRuleByCondition(
RuleQueryCondition ruleQueryCondition) throws CorrelationException {
List<CorrelationRule> correlationRule = correlationRuleQueryDao
@@ -249,15 +245,7 @@ public class RuleMgtWrapper {
CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
correlationDeployRule4Engine.setContent(correlationRule.getContent());
correlationDeployRule4Engine.setEngineId(correlationRule.getEngineID());
- return correlationDeployRule4Engine;
- }
-
- private CorrelationDeployRule4Engine correlationRules2DeployRule(
- CorrelationRule correlationRule, String loopControlName) {
- CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
- correlationDeployRule4Engine.setContent(correlationRule.getContent());
- correlationDeployRule4Engine.setEngineId(correlationRule.getEngineID());
- correlationDeployRule4Engine.setLoopControlName(loopControlName);
+ correlationDeployRule4Engine.setLoopControlName(correlationRule.getClosedControlLoopName());
return correlationDeployRule4Engine;
}
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java
index bcf56ca..3939994 100644
--- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java
+++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java
@@ -45,6 +45,7 @@ public class CorrelationRuleMapperTest {
expect(resultSet.getString("content")).andReturn("");
expect(resultSet.getString("vendor")).andReturn("");
expect(resultSet.getString("package")).andReturn("");
+ expect(resultSet.getString("ctrlloop")).andReturn("");
PowerMock.replay(resultSet);
mapper.map(0, resultSet, null);
PowerMock.verify(resultSet);
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 9837fc5..d448e40 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
@@ -197,7 +197,8 @@ public class RuleMgtWrapperTest {
oldCorrelationRule.setContent("content");
oldCorrelationRule.setPackageName("testName");
oldCorrelationRule.setEnabled(1);
- RuleUpdateRequest ruleUpdateRequest = createRuleUpdateRequest("rule_1", "des2", "contetnt2", 1);
+ oldCorrelationRule.setClosedControlLoopName("cl-name");
+ RuleUpdateRequest ruleUpdateRequest = createRuleUpdateRequest("rule_1", "cl-name", "des2", "contetnt2", 1);
EasyMock.expect(correlationRuleDaoMock.queryRuleByRid("rule_1")).andReturn(oldCorrelationRule);
EasyMock.expect(engineWrapperMock.deleteRuleFromEngine("testName")).andReturn(true);
@@ -225,7 +226,8 @@ public class RuleMgtWrapperTest {
oldCorrelationRule.setContent("content");
oldCorrelationRule.setPackageName("testName");
oldCorrelationRule.setEnabled(1);
- RuleUpdateRequest ruleUpdateRequest = createRuleUpdateRequest("rule_1", "des1", "content", 1);
+ oldCorrelationRule.setClosedControlLoopName("cl-name");
+ RuleUpdateRequest ruleUpdateRequest = createRuleUpdateRequest("rule_1", "cl-name", "des1", "content", 1);
EasyMock.expect(correlationRuleDaoMock.queryRuleByRid("rule_1")).andReturn(oldCorrelationRule);
@@ -373,12 +375,14 @@ public class RuleMgtWrapperTest {
return rcr;
}
- private RuleUpdateRequest createRuleUpdateRequest(String ruleId, String description, String content, int enabled) {
+ private RuleUpdateRequest createRuleUpdateRequest(String ruleId, String clName, String description,
+ String content, int enabled) {
RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
ruleUpdateRequest.setRuleId(ruleId);
ruleUpdateRequest.setDescription(description);
ruleUpdateRequest.setContent(content);
ruleUpdateRequest.setEnabled(enabled);
+ ruleUpdateRequest.setLoopControlName(clName);
return ruleUpdateRequest;
}