summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/test/java/org
diff options
context:
space:
mode:
authorFei Tang <tang.fei4@zte.com.cn>2018-03-27 16:26:39 +0800
committerFei Tang <tang.fei4@zte.com.cn>2018-03-27 16:50:32 +0800
commit6c4fde1fd6dcf484d2c567d3fabf0496ed8b30e0 (patch)
tree0c357c36cfda707fa1ec6cd81d5f0f95f53f2bcd /holmes-actions/src/test/java/org
parent131be6f05c41acd5502d637d2d3326d8b20081ce (diff)
add alarm synchronization related operation
Issue-ID: HOLMES-106 Change-Id: I9020c29b69eb0e8bd5a0a33901c671fd02b9f0d1 Signed-off-by: FeiTang <tang.fei4@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/test/java/org')
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmInfoTest.java94
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/exception/AlarmInfoExceptionTest.java27
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java44
3 files changed, 165 insertions, 0 deletions
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmInfoTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmInfoTest.java
new file mode 100644
index 0000000..a2e60ee
--- /dev/null
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmInfoTest.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.api.entity;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class AlarmInfoTest {
+
+ private AlarmInfo alarmInfo;
+
+ @Before
+ public void before() throws Exception {
+ alarmInfo = new AlarmInfo();
+ }
+
+ @After
+ public void after() throws Exception {
+
+ }
+
+ @Test
+ public void getterAndSetter4EventID() throws Exception {
+ final String eventID = "eventId";
+ alarmInfo.setEventId(eventID);
+ assertThat(alarmInfo.getEventId(), equalTo(eventID));
+ }
+
+ @Test
+ public void getterAndSetter4EventName() throws Exception {
+ final String eventName = "eventName";
+ alarmInfo.setEventName(eventName);
+ assertThat(alarmInfo.getEventName(), equalTo(eventName));
+ }
+
+ @Test
+ public void getterAndSetter4StartEpochMicroSec() throws Exception {
+ final long startEpochMicroSec = 1L;
+ alarmInfo.setStartEpochMicroSec(startEpochMicroSec);
+ assertThat(alarmInfo.getStartEpochMicroSec(), equalTo(startEpochMicroSec));
+ }
+
+ @Test
+ public void getterAndSetter4LastEpochMicroSec() throws Exception {
+ final long lastEpochMicroSec = 1L;
+ alarmInfo.setLastEpochMicroSec(lastEpochMicroSec);
+ assertThat(alarmInfo.getLastEpochMicroSec(), equalTo(lastEpochMicroSec));
+ }
+
+ @Test
+ public void getterAndSetter4SourceID() throws Exception {
+ final String sourceID = "sourceId";
+ alarmInfo.setSourceId(sourceID);
+ assertThat(alarmInfo.getSourceId(), equalTo(sourceID));
+ }
+
+ @Test
+ public void getterAndSetter4SourceName() throws Exception {
+ final String sourceName = "sourceName";
+ alarmInfo.setSourceName(sourceName);
+ assertThat(alarmInfo.getSourceName(), equalTo(sourceName));
+ }
+
+ @Test
+ public void getterAndSetter4AlarmIsCleared() throws Exception {
+ final int alarmIsCleared = 1;
+ alarmInfo.setAlarmIsCleared(alarmIsCleared);
+ assertThat(alarmInfo.getAlarmIsCleared(), equalTo(alarmIsCleared));
+ }
+
+ @Test
+ public void getterAndSetter4RootFlag() throws Exception {
+ final int rootFlag = 1;
+ alarmInfo.setRootFlag(rootFlag);
+ assertThat(alarmInfo.getRootFlag(), equalTo(rootFlag));
+ }
+}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/exception/AlarmInfoExceptionTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/exception/AlarmInfoExceptionTest.java
new file mode 100644
index 0000000..1263b73
--- /dev/null
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/exception/AlarmInfoExceptionTest.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.exception;
+
+import org.junit.Test;
+
+public class AlarmInfoExceptionTest {
+ @Test
+ public void testConstructors() throws Exception {
+ AlarmInfoException ae1 = new AlarmInfoException("msg", new Exception());
+ AlarmInfoException ae2 = new AlarmInfoException("msg");
+ }
+}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java
new file mode 100644
index 0000000..06bbfa8
--- /dev/null
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.utils;
+
+import org.junit.Test;
+import org.powermock.api.easymock.PowerMock;
+
+import java.sql.ResultSet;
+
+import static org.easymock.EasyMock.expect;
+
+public class AlarmInfoMapperTest {
+
+ @Test
+ public void map() throws Exception {
+ AlarmInfoMapper mapper = new AlarmInfoMapper();
+ ResultSet resultSet = PowerMock.createMock(ResultSet.class);
+ expect(resultSet.getString("eventid")).andReturn("");
+ expect(resultSet.getString("eventname")).andReturn("");
+ expect(resultSet.getString("sourceid")).andReturn("");
+ expect(resultSet.getString("sourcename")).andReturn("");
+ expect(resultSet.getLong("startepochmicrosec")).andReturn(0L);
+ expect(resultSet.getLong("lastepochmicrosec")).andReturn(0L);
+ expect(resultSet.getInt("alarmiscleared")).andReturn(0);
+ expect(resultSet.getInt("rootflag")).andReturn(0);
+ PowerMock.replay(resultSet);
+ mapper.map(0, resultSet, null);
+ PowerMock.verify(resultSet);
+ }
+}