diff options
author | Guangrong Fu <fu.guangrong@zte.com.cn> | 2017-10-14 16:41:35 +0800 |
---|---|---|
committer | Guangrong Fu <fu.guangrong@zte.com.cn> | 2017-10-14 16:41:35 +0800 |
commit | 8b2d0be73ab8dcbd573769ed89ad27ecd7c25f88 (patch) | |
tree | f1a9730298b9a5b22c0d8743957e00c0119c622a /rulemgt | |
parent | 049c1722681a7c0d564d625f2740cbc47c15a4be (diff) |
Add DMaaP Configuration APIs for Testing
Change-Id: Iefc0f22da204f30fca8ef81effcd3497a347ebc0
Issue-ID: HOLMES-59
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'rulemgt')
6 files changed, 21 insertions, 25 deletions
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;
}
|