7dc1fabcfc655bfc0c8e907dcc3e50ca35cece90
[holmes/common.git] / holmes-actions / src / test / java / org / openo / holmes / common / api / entity / AlarmsCorrelationTest.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openo.holmes.common.api.entity;
18
19 import static org.hamcrest.core.IsEqual.equalTo;
20 import static org.junit.Assert.assertThat;
21
22 import java.util.Date;
23 import org.junit.Test;
24 import org.junit.Before;
25 import org.junit.After;
26 import sun.util.resources.cldr.ga.LocaleNames_ga;
27
28 public class AlarmsCorrelationTest {
29
30     private AlarmsCorrelation alarmsCorrelation;
31
32     @Before
33     public void before() throws Exception {
34         alarmsCorrelation = new AlarmsCorrelation();
35     }
36
37     @After
38     public void after() throws Exception {
39
40     }
41
42
43     @Test
44     public void getterAndSetter4RuleId() throws Exception {
45         final String ruleId = "ruleId";
46         alarmsCorrelation.setRuleId(ruleId);
47         assertThat(alarmsCorrelation.getRuleId(), equalTo(ruleId));
48     }
49
50
51     @Test
52     public void getterAndSetter4RuleInfo() throws Exception {
53         final String ruleInfo = "ruleInfo";
54         alarmsCorrelation.setRuleInfo(ruleInfo);
55         assertThat(alarmsCorrelation.getRuleInfo(), equalTo(ruleInfo));
56     }
57
58
59     @Test
60     public void getterAndSetter4ResultType() throws Exception {
61         final byte resultType = 1;
62         alarmsCorrelation.setResultType(resultType);
63         assertThat(alarmsCorrelation.getResultType(), equalTo(resultType));
64     }
65
66
67     @Test
68     public void getterAndSetter4CreateTime() throws Exception {
69         final Date createTime = new Date();
70         alarmsCorrelation.setCreateTime(createTime);
71         assertThat(alarmsCorrelation.getCreateTime(), equalTo(createTime));
72     }
73
74
75     @Test
76     public void getterAndSetter4ParentAlarmId() throws Exception {
77         final long pad = 11L;
78         alarmsCorrelation.setParentAlarmId(pad);
79         assertThat(alarmsCorrelation.getParentAlarmId(), equalTo(pad));
80     }
81
82
83     @Test
84     public void getterAndSetter4ChildAlarmId() throws Exception {
85         final long childAlarmId = 11L;
86         alarmsCorrelation.setChildAlarmId(childAlarmId);
87         assertThat(alarmsCorrelation.getChildAlarmId(), equalTo(childAlarmId));
88     }
89
90
91     @Test
92     public void getterAndSetter4Reserve1() throws Exception {
93         final long reserve1 = 11L;
94         alarmsCorrelation.setReserve1(reserve1);
95         assertThat(alarmsCorrelation.getReserve1(), equalTo(reserve1));
96     }
97
98
99     @Test
100     public void getterAndSetter4Reserve2() throws Exception {
101         final long reserve2 = 11L;
102         alarmsCorrelation.setReserve2(reserve2);
103         assertThat(alarmsCorrelation.getReserve2(), equalTo(reserve2));
104     }
105
106
107     @Test
108     public void getterAndSetter4Reserve3() throws Exception {
109         final long reserve3 = 11L;
110         alarmsCorrelation.setReserve3(reserve3);
111         assertThat(alarmsCorrelation.getReserve3(), equalTo(reserve3));
112     }
113
114
115     @Test
116     public void testToString() throws Exception {
117         final AlarmsCorrelation alarmsCorrelationTemp = new AlarmsCorrelation();
118         String ruleId = "ruleId";
119         alarmsCorrelationTemp.setRuleId(ruleId);
120         alarmsCorrelation.setRuleId(ruleId);
121         assertThat(alarmsCorrelation.toString(), equalTo(alarmsCorrelationTemp.toString()));
122     }
123
124
125     @Test
126     public void testEqualsAndHashCode() throws Exception {
127         final AlarmsCorrelation alarmsCorrelationTemp = new AlarmsCorrelation();
128         String ruleId = "ruleId";
129         alarmsCorrelationTemp.setRuleId(ruleId);
130         alarmsCorrelation.setRuleId(ruleId);
131         assertThat(alarmsCorrelation, equalTo(alarmsCorrelationTemp));
132     }
133