summaryrefslogtreecommitdiffstats
path: root/holmes-actions
diff options
context:
space:
mode:
authoryoubowu <wu.youbo@zte.com.cn>2017-03-01 10:55:46 +0800
committer6092002067 <wu.youbo@zte.com.cn>2017-03-01 10:55:46 +0800
commit57d0c9e7572a9de13c7e26f57e98e9a0cdd564a7 (patch)
treee04f37e378a668eb4c4fa900132d57a8abc3fbce /holmes-actions
parent4043a64dabad0f27afcb67e9b62272c4e44a4214 (diff)
Fix the sonar detected error
Issue-ID:HOLMES-51 Change-Id: I1ac160651d7cd1382076a447d33482219cdb0def Signed-off-by: youbowu <wu.youbo@zte.com.cn>
Diffstat (limited to 'holmes-actions')
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java126
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json2
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json2
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/producer/MQProducer.java48
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/I18nProxy.java2
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java15
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java4
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java2
-rw-r--r--holmes-actions/src/test/java/org/openo/holmes/common/api/stat/AlarmTest.java6
-rw-r--r--holmes-actions/src/test/java/org/openo/holmes/common/utils/DbDaoUtilTest.java50
-rw-r--r--holmes-actions/src/test/java/org/openo/holmes/common/utils/I18nProxyTest.java23
-rw-r--r--holmes-actions/src/test/java/org/openo/holmes/common/utils/JudgeNullUtilTest.java3
12 files changed, 139 insertions, 144 deletions
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java
index e5eda70..3ea3715 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java
@@ -46,78 +46,83 @@ public class Alarm implements AplusData, Cloneable, Serializable {
public static final byte EVENT_RAISED = 0;
private static final long serialVersionUID = 4520003737132012000L;
-
+ private final static Date clearedServerTime = null;
+ private final Map<Integer, Integer> linkIdNodeIdxMap = new HashMap<Integer, Integer>();
private byte eventType = EVENT_RAISED;
-
private long id = 0L;
-
private String alarmKey = "";
-
private String network = "";
-
private String neType = "";
-
private String equipType = "";
-
private String position1 = "";
-
private String subPosition1 = null;
-
private String position2 = null;
-
private String subPosition2 = null;
-
private byte severity = -1;
-
private byte alarmType = -1;
-
private long probableCause = -1;
-
private String specificProblem = null;
-
private String additionalText = null;
-
private Date raisedTime = new Date();
-
private Date raisedServerTime = new Date();
-
private Date clearedTime = null;
-
- private final Date clearedServerTime = null;
-
private String region = null;
-
private String site = null;
-
private String aid = null;
-
private short systemType = -1;
-
private boolean rootAlarmFlag = false;
-
private int linkId = -1;
-
private int nodeIdx = -1;
-
private Set<Integer> linkIds = new HashSet<Integer>();
-
private HashMap<String, Integer> priorityMap = new HashMap<String, Integer>();
-
private HashMap<String, Integer> rootAlarmTypeMap = new HashMap<String, Integer>();
-
private int rootAlarmType = -1;
-
private boolean keyAlarmFlag = false;
-
private int keyAlarmType = -1;
-
private int networkLevel = -1;
-
private int linkType = -1;
-
private int centerType;
- private final Map<Integer, Integer> linkIdNodeIdxMap = new HashMap<Integer, Integer>();
+ public static Alarm valueOf(String xmlString) {
+ Element element;
+ try {
+ StringReader sb = new StringReader(xmlString);
+ element = new SAXBuilder().build(sb).getRootElement();
+ sb.close();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ Alarm alarm = new Alarm();
+ @SuppressWarnings("unchecked")
+ List<Attribute> list = element.getAttributes();
+ for (Attribute attr : list) {
+ String attrName = attr.getName();
+ try {
+ Field field = Alarm.class.getDeclaredField(attrName);
+ if (!attrName.endsWith("Time")) {
+ String type = field.getType().getSimpleName();
+ if ("byte".equals(type)) {
+ field.set(alarm, Byte.parseByte(attr.getValue()));
+ } else if ("long".equals(type)) {
+ field.set(alarm, Long.parseLong(attr.getValue()));
+ } else if ("String".equals(type)) {
+ field.set(alarm, attr.getValue());
+ } else {
+ throw new RuntimeException("unknow attr type: " + type.toString());
+ }
+ } else {
+ Date date = new Date();
+ date.setTime(Long.parseLong(attr.getValue()));
+ field.set(alarm, date);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return alarm;
+ }
public void addLinkIdNodeIdx(int linkId, int index) {
linkIdNodeIdxMap.put(linkId, index);
@@ -146,11 +151,7 @@ public class Alarm implements AplusData, Cloneable, Serializable {
}
public boolean containNode(int linkId, int index) {
- if (linkIdNodeIdxMap.containsKey(linkId) && linkIdNodeIdxMap.get(linkId) == index) {
- return true;
- } else {
- return false;
- }
+ return linkIdNodeIdxMap.containsKey(linkId) && linkIdNodeIdxMap.get(linkId) == index;
}
@Override
@@ -193,47 +194,6 @@ public class Alarm implements AplusData, Cloneable, Serializable {
return new XMLOutputter().outputString(el);
}
- public static Alarm valueOf(String xmlString) {
- Element element = null;
- try {
- StringReader sb = new StringReader(xmlString);
- element = new SAXBuilder().build(sb).getRootElement();
- sb.close();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- Alarm alarm = new Alarm();
- @SuppressWarnings("unchecked")
- List<Attribute> list = element.getAttributes();
- for (Attribute attr : list) {
- String attrName = attr.getName();
- try {
- Field field = Alarm.class.getDeclaredField(attrName);
- if (!attrName.endsWith("Time")) {
- String type = field.getType().getSimpleName();
- if (type.equals("byte")) {
- field.set(alarm, Byte.parseByte(attr.getValue()));
- } else if (type.equals("long")) {
- field.set(alarm, Long.parseLong(attr.getValue()));
- } else if (type.equals("String")) {
- field.set(alarm, attr.getValue());
- } else {
- throw new RuntimeException("unknow attr type: " + type.toString());
- }
- } else {
- Date date = new Date();
- date.setTime(Long.parseLong(attr.getValue()));
- field.set(alarm, date);
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- return alarm;
- }
-
@Override
public int hashCode() {
return this.getAlarmKey().hashCode();
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json
index 8288f6e..0192d01 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json
@@ -13,7 +13,7 @@
"EXCEPTION_REQUEST_IS_EMPTY": "The request object is empty",
"RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED": "Delete rules from engine call interface failure ",
"RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED": "From the rules engine calls the deployment of interface failure",
- "RULE_MANAGEMENT__CALL_CHECK_RULE_REST_FAILED": "From the rules engine calls the check of interface failure",
+ "RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED": "From the rules engine calls the check of interface failure",
"RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED": "Create query exception",
"RULE_MANAGEMENT_QUERY_RULE_FAILED": "Query rule failed",
"RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY": "Request object is empty",
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json
index 347986a..0b0d007 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json
@@ -9,7 +9,7 @@
"ENGINE_QUERY_CACHE_FAILED":"查询缓存失败",
"RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED": "从引擎调用删除规则接口失败",
"RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED": "从引擎调用部署规则接口失败",
- "RULE_MANAGEMENT__CALL_CHECK_RULE_REST_FAILED": "从引擎调用校验规则接口失败",
+ "RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED": "从引擎调用校验规则接口失败",
"RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED": "创建查询语句异常",
"RULE_MANAGEMENT_QUERY_RULE_FAILED": "查询规则失败",
"RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY":"请求对象为空",
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/producer/MQProducer.java b/holmes-actions/src/main/java/org/openo/holmes/common/producer/MQProducer.java
index e9c38b9..8cb3d2b 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/producer/MQProducer.java
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/producer/MQProducer.java
@@ -15,6 +15,7 @@
*/
package org.openo.holmes.common.producer;
+import java.io.Serializable;
import javax.inject.Inject;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -41,22 +42,33 @@ public class MQProducer {
private ConnectionFactory connectionFactory;
public void sendAlarmMQTopicMsg(Alarm alarm) {
+ sendMQTopicMsg(alarm);
+ }
+
+ public void sendCorrelationMQTopicMsg(String ruleId, long createTimeL, Alarm parentAlarm,
+ Alarm childAlarm) {
+ CorrelationResult correlationResult = getCorrelationResult(ruleId, createTimeL, parentAlarm, childAlarm);
+ sendMQTopicMsg(correlationResult);
+ }
+ private <T> void sendMQTopicMsg(T t) {
+ Serializable msgEntity = (Serializable) t;
Connection connection = null;
Session session;
Destination destination;
MessageProducer messageProducer;
+
try {
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
- destination = session.createTopic(AlarmConst.MQ_TOPIC_NAME_ALARM);
+ destination = session.createTopic(AlarmConst.MQ_TOPIC_NAME_ALARMS_CORRELATION);
messageProducer = session.createProducer(destination);
- ObjectMessage message = session.createObjectMessage(alarm);
+ ObjectMessage message = session.createObjectMessage(msgEntity);
messageProducer.send(message);
session.commit();
} catch (Exception e) {
- log.error("Failed send alarm." + e.getMessage(), e);
+ log.error("Failed send correlation." + e.getMessage(), e);
} finally {
if (connection != null) {
try {
@@ -68,39 +80,13 @@ public class MQProducer {
}
}
- public void sendCorrelationMQTopicMsg(String ruleId, long createTimeL, Alarm parentAlarm,
+ private CorrelationResult getCorrelationResult(String ruleId, long createTimeL, Alarm parentAlarm,
Alarm childAlarm) {
-
CorrelationResult correlationResult = new CorrelationResult();
correlationResult.setRuleId(ruleId);
correlationResult.setCreateTimeL(createTimeL);
correlationResult.setResultType(AplusResult.APLUS_CORRELATION);
correlationResult.setAffectedAlarms(new Alarm[]{parentAlarm, childAlarm});
-
- Connection connection = null;
- Session session;
- Destination destination;
- MessageProducer messageProducer;
-
- try {
- connection = connectionFactory.createConnection();
- connection.start();
- session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
- destination = session.createTopic(AlarmConst.MQ_TOPIC_NAME_ALARMS_CORRELATION);
- messageProducer = session.createProducer(destination);
- ObjectMessage message = session.createObjectMessage(correlationResult);
- messageProducer.send(message);
- session.commit();
- } catch (Exception e) {
- log.error("Failed send correlation." + e.getMessage(), e);
- } finally {
- if (connection != null) {
- try {
- connection.close();
- } catch (JMSException e) {
- log.error("Failed close connection." + e.getMessage(), e);
- }
- }
- }
+ return correlationResult;
}
}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/I18nProxy.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/I18nProxy.java
index 75aacb9..c30eff1 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/I18nProxy.java
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/I18nProxy.java
@@ -38,7 +38,7 @@ public class I18nProxy {
/*-----------------------Rule Management------------------------------- */
public static final String RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED = "RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED";
public static final String RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED = "RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED";
- public static final String RULE_MANAGEMENT__CALL_CHECK_RULE_REST_FAILED = "RULE_MANAGEMENT__CALL_CHECK_RULE_REST_FAILED";
+ public static final String RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED = "RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED";
public static final String RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED = "RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED";
public static final String RULE_MANAGEMENT_QUERY_RULE_FAILED = "RULE_MANAGEMENT_QUERY_RULE_FAILED";
public static final String RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY = "RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY";
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java
index caef0b0..f030d3d 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java
@@ -15,10 +15,7 @@
*/
package org.openo.holmes.common.utils;
-import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
@@ -40,16 +37,4 @@ public class JacksonUtil {
}
return objectMapper.readValue(json, cls);
}
-
- public static <T> T jsonToBeanByMatchAttribute(String json, Class<T> cls)
- throws JsonParseException,
- JsonMappingException, IOException {
- if (JudgeNullUtil.isEmpty(json)) {
- return null;
- }
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- return objectMapper.readValue(json, cls);
- }
-
}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java
index 1c8f72c..930905a 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java
@@ -25,7 +25,7 @@ public class LanguageUtil {
}
public static String getLanguage(HttpServletRequest servletRequest) {
- String language = (String) servletRequest.getHeader("language-option");
+ String language = servletRequest.getHeader("language-option");
if (JudgeNullUtil.isEmpty(language)) {
language = AlarmConst.I18N_EN;
}
@@ -38,7 +38,7 @@ public class LanguageUtil {
}
public static Locale getLocale(HttpServletRequest servletRequest) {
- String language = (String) servletRequest.getHeader("language-option");
+ String language = servletRequest.getHeader("language-option");
if (JudgeNullUtil.isEmpty(language)) {
language = AlarmConst.I18N_EN;
}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java
index 723b489..ec8fda6 100644
--- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java
@@ -26,7 +26,7 @@ public class UserUtil {
public static String getUserName(HttpServletRequest request) {
String userName = AlarmConst.ADMIN;
- String sessionName = (String) request.getHeader("username");
+ String sessionName = request.getHeader("username");
if (sessionName != null) {
userName = sessionName.toLowerCase();
}
diff --git a/holmes-actions/src/test/java/org/openo/holmes/common/api/stat/AlarmTest.java b/holmes-actions/src/test/java/org/openo/holmes/common/api/stat/AlarmTest.java
index b740d87..49858ab 100644
--- a/holmes-actions/src/test/java/org/openo/holmes/common/api/stat/AlarmTest.java
+++ b/holmes-actions/src/test/java/org/openo/holmes/common/api/stat/AlarmTest.java
@@ -170,9 +170,9 @@ public class AlarmTest {
@Test
public void testGetAlarmTypeRuleId_notNull() throws Exception {
final String ruleId = "ruleId";
- final int rootAlarmTyep = 2;
- alarm.getRootAlarmTypeMap().put(ruleId, rootAlarmTyep);
- assertThat(rootAlarmTyep, equalTo(alarm.getRootAlarmType(ruleId)));
+ final int rootAlarmType = 2;
+ alarm.getRootAlarmTypeMap().put(ruleId, rootAlarmType);
+ assertThat(rootAlarmType, equalTo(alarm.getRootAlarmType(ruleId)));
}
@Test
diff --git a/holmes-actions/src/test/java/org/openo/holmes/common/utils/DbDaoUtilTest.java b/holmes-actions/src/test/java/org/openo/holmes/common/utils/DbDaoUtilTest.java
index b56e4ee..18c774e 100644
--- a/holmes-actions/src/test/java/org/openo/holmes/common/utils/DbDaoUtilTest.java
+++ b/holmes-actions/src/test/java/org/openo/holmes/common/utils/DbDaoUtilTest.java
@@ -18,10 +18,13 @@ package org.openo.holmes.common.utils;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.jdbi.DBIFactory;
import io.dropwizard.setup.Environment;
+import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -81,7 +84,7 @@ public class DbDaoUtilTest {
}
@Test
- public void getDao() throws Exception {
+ public void getDao_normal() throws Exception {
Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
expect(jdbi.open(anyObject(Class.class))).andReturn(Class.class);
@@ -93,7 +96,22 @@ public class DbDaoUtilTest {
}
@Test
- public void testGetHandle() throws Exception {
+ public void getDao_exception() throws Exception {
+ Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
+
+ expect(jdbi.open(anyObject(Class.class))).andThrow(new RuntimeException(""));
+
+ PowerMock.replayAll();
+
+ Object o = dbDaoUtil.getDao(String.class);
+
+ PowerMock.verifyAll();
+
+ assertThat(o, equalTo(null));
+ }
+
+ @Test
+ public void getHandle_normal() throws Exception {
Handle handle = PowerMock.createMock(Handle.class);
Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
@@ -105,9 +123,24 @@ public class DbDaoUtilTest {
PowerMock.verifyAll();
}
+ @Test
+ public void getHandle_exception() throws Exception {
+ Handle handle = PowerMock.createMock(Handle.class);
+
+ Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
+ expect(jdbi.open()).andThrow(new RuntimeException(""));
+
+ PowerMock.replayAll();
+
+ Handle handle1 = dbDaoUtil.getHandle();
+
+ PowerMock.verifyAll();
+
+ assertThat(handle1, equalTo(null));
+ }
@Test
- public void testClose() throws Exception {
+ public void close_normal() throws Exception {
Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
jdbi.close(anyObject());
@@ -119,6 +152,17 @@ public class DbDaoUtilTest {
}
@Test
+ public void close_exception() throws Exception {
+ Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
+ jdbi.close(anyObject());
+ EasyMock.expectLastCall().andThrow(new RuntimeException(""));
+ PowerMock.replayAll();
+
+ dbDaoUtil.close(new Object());
+
+ PowerMock.verifyAll();
+ }
+ @Test
public void testGetJdbiDaoByOnDemand() throws Exception {
Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
expect(jdbi.onDemand(anyObject(Class.class))).andReturn(Class.class);
diff --git a/holmes-actions/src/test/java/org/openo/holmes/common/utils/I18nProxyTest.java b/holmes-actions/src/test/java/org/openo/holmes/common/utils/I18nProxyTest.java
index 64b31f4..c3631ac 100644
--- a/holmes-actions/src/test/java/org/openo/holmes/common/utils/I18nProxyTest.java
+++ b/holmes-actions/src/test/java/org/openo/holmes/common/utils/I18nProxyTest.java
@@ -21,6 +21,7 @@ import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import java.util.Locale;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
@@ -34,8 +35,28 @@ public class I18nProxyTest {
}
@Test
- public void testGetValue() {
+ public void getValue_locale_and_key() {
String result = i18nProxy.getValue(new Locale("zh"), "test");
assertThat(result, equalTo(null));
}
+ @Test
+ public void getValueByArgs(){
+ String result = i18nProxy.getValueByArgs(new Locale("zh"), "test",new String[]{"1"});
+ assertThat(result,equalTo(null));
+ }
+ @Test
+ public void getValue_by_key(){
+ Map<String,String> result = i18nProxy.getValue("test");
+ assertThat(result, equalTo(null));
+ }
+ @Test
+ public void jsonI18n(){
+ String result = i18nProxy.jsonI18n("test");
+ assertThat(result,equalTo(null));
+ }
+ @Test
+ public void i18nWithArgs(){
+ String result = i18nProxy.i18nWithArgs("test",new String[]{});
+ assertThat(result,equalTo("null"));
+ }
} \ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/openo/holmes/common/utils/JudgeNullUtilTest.java b/holmes-actions/src/test/java/org/openo/holmes/common/utils/JudgeNullUtilTest.java
index 25da9ac..a2a0542 100644
--- a/holmes-actions/src/test/java/org/openo/holmes/common/utils/JudgeNullUtilTest.java
+++ b/holmes-actions/src/test/java/org/openo/holmes/common/utils/JudgeNullUtilTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
public class JudgeNullUtilTest {
@Test
- public void isEmpty_array() {
+ public void isEmpty_array_length_zero() {
boolean resultShorts = JudgeNullUtil.isEmpty(new short[]{});
boolean resultInts = JudgeNullUtil.isEmpty(new int[]{});
boolean resultLongs = JudgeNullUtil.isEmpty(new long[]{});
@@ -40,5 +40,4 @@ public class JudgeNullUtilTest {
assertThat(true, equalTo(resultStrings));
assertThat(true, equalTo(resultLists));
}
-
} \ No newline at end of file