summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-03-02 08:14:07 +0000
committerGerrit Code Review <gerrit@open-o.org>2017-03-02 08:14:07 +0000
commit26c0c7d95d39031ba877be193bcf75eb7ea9f8e2 (patch)
tree83965a50e9657c864e77b93bc0128649bac1eb0d
parent7701ce72c18c46d52d7cc5bc6830cdc71573df7d (diff)
parente9257d9ddcf42d367997443259f345d8b1b301ff (diff)
Merge "Fix in rule management the sonar detected error"
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java10
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java7
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java6
3 files changed, 8 insertions, 15 deletions
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java
index aa2cccc..f800f0c 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java
@@ -67,7 +67,7 @@ public abstract class CorrelationRuleDao {
addRule(correlationRule);
return correlationRule;
} catch (Exception e) {
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR,e);
}
}
@@ -75,7 +75,7 @@ public abstract class CorrelationRuleDao {
try {
updateRuleByRid(correlationRule);
} catch (Exception e) {
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR,e);
}
}
@@ -83,7 +83,7 @@ public abstract class CorrelationRuleDao {
try {
deleteRule2DbInner(correlationRule);
} catch (Exception e) {
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR,e);
}
}
@@ -92,7 +92,7 @@ public abstract class CorrelationRuleDao {
try {
return queryRuleById(rid);
} catch (Exception e) {
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR,e);
}
}
@@ -100,7 +100,7 @@ public abstract class CorrelationRuleDao {
try {
return queryRuleByName(name);
} catch (Exception e) {
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR,e);
}
}
}
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java
index 075da00..d77cc09 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java
@@ -117,11 +117,8 @@ public class CorrelationRuleQueryDao {
}
}
}
- if (whereSql.indexOf("AND") > -1) {
- whereSql = whereSql.trim();
- return whereSql.substring(0, whereSql.length() - "AND".length());
- }
- return "";
+ whereSql = whereSql.trim();
+ return whereSql.substring(0, whereSql.length() - "AND".length());
} catch (Exception e) {
throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED, e);
}
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java
index 8df2074..f241484 100644
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java
+++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java
@@ -30,28 +30,24 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
import org.openo.holmes.common.api.entity.CorrelationRule;
import org.openo.holmes.common.exception.CorrelationException;
import org.openo.holmes.common.utils.DbDaoUtil;
import org.openo.holmes.common.utils.I18nProxy;
import org.openo.holmes.rulemgt.bean.request.RuleQueryCondition;
import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
-import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.powermock.reflect.Whitebox;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.Query;
-
public class CorrelationRuleQueryDaoTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Rule
+ @Rule
public PowerMockRule powerMockRule = new PowerMockRule();
private DbDaoUtil dbDaoUtil;