<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
</dependencies>
<build>
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;
+import org.jvnet.hk2.annotations.Service;
import org.openo.holmes.common.config.MQConfig;
+@Service
public class EngineDAppConfig extends Configuration {
@NotEmpty
@NotEmpty
private String apidescription = "Holmes rule management rest API";
+ @NotEmpty
+ private String msbServerAddr;
+
@JsonProperty
@NotNull
@Valid
this.database = dataSourceFactory;
}
+ @JsonProperty
+ public String getMsbServerAddr() {
+ return msbServerAddr;
+ }
+
public String getApidescription() {
return apidescription;
}
public abstract class CorrelationRuleDao {
- @SqlQuery("SELECT * FROM APLUS_RULE WHERE enable=:enable")
+ @SqlQuery("SELECT * FROM aplus_rule WHERE enable=:enable")
public abstract List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable);
public List<CorrelationRule> queryRuleByRuleEnable(int enable) {
correlationRule.setModifier(resultSet.getString("updator"));
correlationRule.setUpdateTime(resultSet.getDate("updateTime"));
correlationRule.setParams((Properties) resultSet.getObject("params"));
- correlationRule.setDomain(resultSet.getString("domain"));
correlationRule.setContent(resultSet.getString("content"));
- correlationRule.setIsManual(resultSet.getInt("isManual"));
correlationRule.setVendor(resultSet.getString("vendor"));
correlationRule.setPackageName(resultSet.getString("package"));
return correlationRule;
private void initDeployRule() throws CorrelationException {
List<CorrelationRule> rules = ruleMgtWrapper.queryRuleByEnable(ENABLE);
- if (!rules.isEmpty()) {
- for (CorrelationRule rule : rules) {
- if (rule.getContent() != null) {
- deployRuleFromDB(rule.getContent());
- }
+ if (rules.isEmpty()) {
+ return;
+ }
+ for (CorrelationRule rule : rules) {
+ if (rule.getContent() != null) {
+ deployRuleFromDB(rule.getContent());
}
}
}
List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class)
.queryRuleByRuleEnable(enable);
- if (ruleTemp == null) {
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
- }
return ruleTemp;
}
}
expect(resultSet.getString("updator")).andReturn("");\r
expect(resultSet.getDate("updateTime")).andReturn(new Date(System.currentTimeMillis()));\r
expect(resultSet.getObject("params")).andReturn(new Properties());\r
- expect(resultSet.getString("domain")).andReturn("");\r
expect(resultSet.getString("content")).andReturn("");\r
- expect(resultSet.getInt("isManual")).andReturn(0);\r
expect(resultSet.getString("vendor")).andReturn("");\r
expect(resultSet.getString("package")).andReturn("");\r
\r
PowerMock.resetAll();\r
}\r
\r
- @Test\r
- public void queryRuleByEnable_ruletemp_is_null() throws CorrelationException {\r
- int enable = 3;\r
-\r
- thrown.expect(CorrelationException.class);\r
-\r
- CorrelationRuleDao correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);\r
- expect(daoUtil.getJdbiDaoByOnDemand(anyObject(Class.class))).andReturn(correlationRuleDao);\r
- expect(correlationRuleDao.queryRuleByRuleEnable(anyInt())).andReturn(null);\r
- PowerMock.replayAll();\r
- ruleMgtWrapper.queryRuleByEnable(enable);\r
- PowerMock.verifyAll();\r
- }\r
-\r
@Test\r
public void queryRuleByEnable_normal() throws CorrelationException {\r
int enable = 3;\r
<artifactId>swagger-sdk</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.6</version>
+ </dependency>
</dependencies>
</dependencyManagement>